X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Frbuf%2F_info;fp=ccan%2Frbuf%2F_info;h=30232db2cced60ede94bca9dbf6a4e6a3e153f5a;hb=44b37ee8aeb185f6837378fef17d887bda6ff89b;hp=0000000000000000000000000000000000000000;hpb=72ce81407f677cf279eb46b1c90c34316067b674;p=ccan diff --git a/ccan/rbuf/_info b/ccan/rbuf/_info new file mode 100644 index 00000000..30232db2 --- /dev/null +++ b/ccan/rbuf/_info @@ -0,0 +1,52 @@ +#include +#include "config.h" + +/** + * rbuf - buffered I/O input primitive. + * + * This code is like stdio, only simpler and more transparent to the user. + * + * Author: Rusty Russell + * License: BSD-MIT + * + * Example: + * #include + * #include + * #include + * #include + * + * // Dumb demo program to replace ' ' with '*'. + * int main(int argc, char *argv[]) + * { + * struct rbuf in; + * char *word; + * + * if (argv[1]) { + * if (!rbuf_open(&in, argv[1], NULL, 0)) + * err(1, "Failed opening %s", argv[1]); + * } else + * rbuf_init(&in, STDIN_FILENO, NULL, 0); + * + * while ((word = rbuf_read_str(&in, ' ', realloc)) != NULL) + * printf("%s*", word); + * + * if (errno) + * err(1, "Reading %s", argv[1] ? argv[1] : ""); + * + * // Free the buffer, just because we can. + * free(in.buf); + * return 0; + * } + */ +int main(int argc, char *argv[]) +{ + /* Expect exactly one argument */ + if (argc != 2) + return 1; + + if (strcmp(argv[1], "depends") == 0) { + return 0; + } + + return 1; +}