X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fgrab_file%2Fgrab_file.h;h=bcd728e610a2e7cdc342f4585f8f14a1b8f5c883;hb=fe21b246647e4694da5f76e0fd00e9a9f9e8c72e;hp=5f7e37c6de004a634d04441dcdb031b197581cfd;hpb=9965fc25fcc92dc76d1cd4cf9595dc3dc9ebc586;p=ccan diff --git a/ccan/grab_file/grab_file.h b/ccan/grab_file/grab_file.h index 5f7e37c6..bcd728e6 100644 --- a/ccan/grab_file/grab_file.h +++ b/ccan/grab_file/grab_file.h @@ -1,3 +1,4 @@ +/* Licensed under LGPLv2+ - see LICENSE file for details */ #ifndef CCAN_GRAB_FILE_H #define CCAN_GRAB_FILE_H #include // For size_t @@ -14,17 +15,18 @@ * byte after the end of the content will always be NUL. * * Example: - * // Return all of standard input, as lines. - * char **read_as_lines(void) + * // Return the first line. + * static char *read_stdin_firstline(void) * { - * char **lines, *all; + * char *all, *nl; * * all = grab_fd(NULL, 0, NULL); * if (!all) * return NULL; - * lines = strsplit(NULL, all, "\n", NULL); - * talloc_free(all); - * return lines; + * nl = strchr(all, '\n'); + * if (nl) + * *nl = '\0'; + * return all; * } */ void *grab_fd(const void *ctx, int fd, size_t *size); @@ -41,17 +43,17 @@ void *grab_fd(const void *ctx, int fd, size_t *size); * after the end of the content will always be NUL. * * Example: - * // Return all of a given file, as lines. - * char **read_as_lines(const char *filename) + * static char *read_file_firstline(const char *filename) * { - * char **lines, *all; + * char *nl, *all; * * all = grab_file(NULL, filename, NULL); * if (!all) * return NULL; - * lines = strsplit(NULL, all, "\n", NULL); - * talloc_free(all); - * return lines; + * nl = strchr(all, '\n'); + * if (nl) + * *nl = '\0'; + * return all; * } */ void *grab_file(const void *ctx, const char *filename, size_t *size);