]> git.ozlabs.org Git - ccan/blob - ccan/str_talloc/_info.c
3186b2bacbc68e70e09536d06ca910ce841ba6cf
[ccan] / ccan / str_talloc / _info.c
1 #include <stdio.h>
2 #include <string.h>
3 #include "config.h"
4
5 /**
6  * str_talloc - string helper routines which use talloc
7  *
8  * This is a grab bag of fnctions for string operations, designed to enhance
9  * the standard string.h; these are separated from the non-talloc-needing
10  * string utilities in "str.h".
11  *
12  * Example:
13  *      #include "str_talloc/str_talloc.h"
14  *      #include "talloc/talloc.h"
15  *      #include "grab_file/grab_file.h"
16  *      #include <err.h>
17  *      
18  *      // Dumb demo program to double-linespace a file.
19  *      int main(int argc, char *argv[])
20  *      {
21  *              char *textfile;
22  *              char **lines;
23  *      
24  *              // Grab lines in file.
25  *              textfile = grab_file(NULL, argv[1], NULL);
26  *              if (!textfile)
27  *                      err(1, "Failed reading %s", argv[1]);
28  *              lines = strsplit(textfile, textfile, "\n", NULL);
29  *      
30  *              // Join them back together with two linefeeds.
31  *              printf("%s", strjoin(textfile, lines, "\n\n"));
32  *
33  *              // Free everything, just because we can.
34  *              talloc_free(textfile);
35  *              return 0;
36  *      }
37  *
38  * Licence: LGPL (2 or any later version)
39  */
40 int main(int argc, char *argv[])
41 {
42         if (argc != 2)
43                 return 1;
44
45         if (strcmp(argv[1], "depends") == 0) {
46                 printf("ccan/talloc\n");
47                 printf("ccan/noerr\n");
48                 return 0;
49         }
50
51         return 1;
52 }