6 * grab_file - file helper routines
8 * This contains simple functions for getting the contents of a file.
14 * #include <ccan/grab_file/grab_file.h>
15 * #include <ccan/talloc/talloc.h> // For talloc_free()
17 * int main(int argc, char *argv[])
22 * file = grab_file(NULL, argv[1], &len);
24 * err(1, "Could not read file %s", argv[1]);
25 * if (strlen(file) != len)
26 * printf("File contains NUL characters\n");
28 * printf("File contains nothing\n");
29 * else if (strchr(file, '\n'))
30 * printf("File contains multiple lines\n");
32 * printf("File contains one line\n");
38 * License: LGPL (2 or any later version)
39 * Author: Rusty Russell <rusty@rustcorp.com.au>
41 int main(int argc, char *argv[])
46 if (strcmp(argv[1], "depends") == 0) {
47 printf("ccan/str_talloc\n"); /* Needed for tests. */
48 printf("ccan/talloc\n");
49 printf("ccan/noerr\n");