Added module ccan_tokenizer from snapshot at:
[ccan] / ccan / read_write_all / _info
1 #include <stdio.h>
2 #include <string.h>
3 #include "config.h"
4
5 /**
6  * read_write_all - read_all and write_all routines.
7  *
8  * Successful read and write calls may only partly complete if a
9  * signal is received or they are not operating on a normal file.
10  *
11  * read_all() and write_all() do the looping for you.
12  *
13  * Example:
14  *      #include <err.h>
15  *      #include <stdio.h>
16  *      #include <unistd.h>
17  *      #include <ccan/read_write_all/read_write_all.h>
18  *
19  *      #define BUFFER_SIZE 10
20  *      int main(int argc, char *argv[])
21  *      {
22  *              char buffer[BUFFER_SIZE+1];
23  *
24  *              if (!read_all(STDIN_FILENO, buffer, BUFFER_SIZE))
25  *                      err(1, "Could not read %u characters", BUFFER_SIZE);
26  *              buffer[BUFFER_SIZE] = '\0';
27  *              printf("I read '%.*s'\n", BUFFER_SIZE, buffer);
28  *              return 0;
29  *      }
30  *
31  * Licence: LGPL (2 or any later version)
32  */
33 int main(int argc, char *argv[])
34 {
35         if (argc != 2)
36                 return 1;
37
38         if (strcmp(argv[1], "depends") == 0) {
39                 return 0;
40         }
41
42         return 1;
43 }