X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftal%2Fgrab_file%2F_info;fp=ccan%2Ftal%2Fgrab_file%2F_info;h=3b323d3325d232ac9136b311ca56123f7c42fa29;hp=0000000000000000000000000000000000000000;hb=fbad46cd37018923bf0a7de2df37e35e90792c32;hpb=db4e16e71cd1bb474307c971c6312389bb254053 diff --git a/ccan/tal/grab_file/_info b/ccan/tal/grab_file/_info new file mode 100644 index 00000000..3b323d33 --- /dev/null +++ b/ccan/tal/grab_file/_info @@ -0,0 +1,56 @@ +#include +#include +#include "config.h" + +/** + * tal/grab_file - file helper routines + * + * This contains simple functions for getting the contents of a file. + * + * Example: + * #include + * #include + * #include + * #include + * #include // for tal_free + * + * int main(int argc, char *argv[]) + * { + * char *file; + * + * file = grab_file(NULL, argv[1]); + * if (!file) + * err(1, "Could not read file %s", argv[1]); + * if (strlen(file)+1 != tal_count(file)) + * printf("File contains NUL characters\n"); + * else if (tal_count(file) == 1) + * printf("File contains nothing\n"); + * else if (strchr(file, '\n')) + * printf("File contains multiple lines\n"); + * else + * printf("File contains one line\n"); + * tal_free(file); + * + * return 0; + * } + * + * License: LGPL (v2.1 or any later version) + * Author: Rusty Russell + */ +int main(int argc, char *argv[]) +{ + if (argc != 2) + return 1; + + if (strcmp(argv[1], "depends") == 0) { + printf("ccan/tal\n"); + printf("ccan/noerr\n"); + return 0; + } + if (strcmp(argv[1], "testdepends") == 0) { + printf("ccan/tal/str\n"); + return 0; + } + + return 1; +}