]> git.ozlabs.org Git - ccan/blob - ccan/read_write_all/_info
tools/ccanlint: add args to main.
[ccan] / ccan / read_write_all / _info
1 #include "config.h"
2 #include <stdio.h>
3 #include <string.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(void)
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  * License: LGPL (v2.1 or any later version)
32  * Author: Rusty Russell <rusty@rustcorp.com.au>
33  */
34 int main(int argc, char *argv[])
35 {
36         if (argc != 2)
37                 return 1;
38
39         if (strcmp(argv[1], "depends") == 0) {
40                 return 0;
41         }
42
43         return 1;
44 }