blob: c9672f4adedb385bdac9bed84881b8af44a06465 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "iri.h"
int
main(void)
{
struct iri iri;
const char *errstr = NULL;
char buf[64];
char *line = NULL;
size_t linesize = 0;
ssize_t linelen;
if ((linelen = getline(&line, &linesize, stdin)) == -1)
return (1);
if (line[linelen-1] == '\n')
line[--linelen] = '\0';
if (parse_iri(line, &iri, &errstr)) {
if (serialize_iri(&iri, buf, sizeof(buf)))
puts(buf);
}
free(line);
if (ferror(stdin)) {
perror("getline");
return (1);
}
return (0);
}
|