5 * rbuf - buffered I/O input primitive.
7 * This code is like stdio, only simpler and more transparent to the user.
9 * Author: Rusty Russell <rusty@rustcorp.com.au>
13 * #include <ccan/rbuf/rbuf.h>
14 * #include <ccan/err/err.h>
18 * // Dumb demo program to replace ' ' with '*'.
19 * int main(int argc, char *argv[])
25 * if (!rbuf_open(&in, argv[1], NULL, 0))
26 * err(1, "Failed opening %s", argv[1]);
28 * rbuf_init(&in, STDIN_FILENO, NULL, 0);
30 * while ((word = rbuf_read_str(&in, ' ', realloc)) != NULL)
31 * printf("%s*", word);
34 * err(1, "Reading %s", argv[1] ? argv[1] : "<stdin>");
36 * // Free the buffer, just because we can.
41 int main(int argc, char *argv[])
43 /* Expect exactly one argument */
47 if (strcmp(argv[1], "depends") == 0) {