| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- #include <string.h>
- #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 <rusty@rustcorp.com.au>
- * License: BSD-MIT
- *
- * Example:
- * #include <ccan/rbuf/rbuf.h>
- * #include <ccan/err/err.h>
- * #include <stdlib.h>
- * #include <unistd.h>
- *
- * // 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] : "<stdin>");
- *
- * // 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;
- }
|