]> git.ozlabs.org Git - ccan/blob - ccan/rbuf/_info
ccan: Correct some poor conventions in _info includes
[ccan] / ccan / rbuf / _info
1 #include "config.h"
2 #include <stdio.h>
3 #include <string.h>
4
5 /**
6  * rbuf - buffered I/O input primitive.
7  *
8  * This code is like stdio, only simpler and more transparent to the user.
9  *
10  * Author: Rusty Russell <rusty@rustcorp.com.au>
11  * License: BSD-MIT
12  *
13  * Example:
14  *      #include <ccan/rbuf/rbuf.h>
15  *      #include <ccan/err/err.h>
16  *      #include <stdlib.h>
17  *      #include <unistd.h>
18  *
19  *      // Dumb demo program to replace ' ' with '*'.
20  *      int main(int argc, char *argv[])
21  *      {
22  *              struct rbuf in;
23  *              char *word;
24  *
25  *              if (argv[1]) {
26  *                      if (!rbuf_open(&in, argv[1], NULL, 0))
27  *                              err(1, "Failed opening %s", argv[1]);
28  *              } else
29  *                      rbuf_init(&in, STDIN_FILENO, NULL, 0);
30  *
31  *              while ((word = rbuf_read_str(&in, ' ', realloc)) != NULL)
32  *                      printf("%s*", word);
33  *
34  *              if (errno)
35  *                      err(1, "Reading %s", argv[1] ? argv[1] : "<stdin>");
36  *
37  *              // Free the buffer, just because we can.
38  *              free(in.buf);
39  *              return 0;
40  *      }
41  */
42 int main(int argc, char *argv[])
43 {
44         /* Expect exactly one argument */
45         if (argc != 2)
46                 return 1;
47
48         if (strcmp(argv[1], "depends") == 0) {
49                 return 0;
50         }
51
52         return 1;
53 }