]> git.ozlabs.org Git - ccan/blob - ccan/str_talloc/_info
tdb2: more stats
[ccan] / ccan / str_talloc / _info
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 <ccan/str_talloc/str_talloc.h>
14  *      #include <ccan/talloc/talloc.h>
15  *      #include <ccan/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");
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  * License: LGPL (2 or any later version)
39  * Author: Rusty Russell <rusty@rustcorp.com.au>
40  */
41 int main(int argc, char *argv[])
42 {
43         if (argc != 2)
44                 return 1;
45
46         if (strcmp(argv[1], "depends") == 0) {
47                 printf("ccan/str\n");
48                 printf("ccan/talloc\n");
49                 printf("ccan/noerr\n");
50                 return 0;
51         }
52
53         return 1;
54 }