2 Test code for line based I/O over fds
4 Copyright (C) Amitay Isaacs 2018
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, see <http://www.gnu.org/licenses/>.
21 #include "system/filesys.h"
26 #include "common/line.c"
28 static int line_print(char *line
, void *private_data
)
36 int main(int argc
, const char **argv
)
44 if (argc
< 2 || argc
> 3) {
45 fprintf(stderr
, "Usage: %s <filename> [<hint>]\n", argv
[0]);
52 value
= atol(argv
[2]);
70 fd
= open(argv
[1], O_RDONLY
);
74 n
= read(fd
, buffer
, sizeof(buffer
));
75 assert(n
>= 0 && n
<= sizeof(buffer
));
81 n2
= write(pipefd
[1], buffer
, n
);
93 mem_ctx
= talloc_new(NULL
);
94 assert(mem_ctx
!= NULL
);
96 ret
= line_read(pipefd
[0], hint
, NULL
, line_print
, NULL
, &lines
);