]> git.ozlabs.org Git - ccan/blob - ccan/tal/str/_info
63081a1b189b101d378450752ce7873e64260bde
[ccan] / ccan / tal / str / _info
1 #include <stdio.h>
2 #include <string.h>
3 #include "config.h"
4
5 /**
6  * tal/str - string helper routines which use tal
7  *
8  * This is a grab bag of functions for string operations, designed to enhance
9  * the standard string.h; these are separated from the non-tal-needing
10  * string utilities in "str.h".
11  *
12  * Example:
13  *      #include <ccan/tal/str/str.h>
14  *      #include <ccan/grab_file/grab_file.h>
15  *      #include <err.h>
16  *
17  *      // Dumb demo program to double-linespace a file.
18  *      int main(int argc, char *argv[])
19  *      {
20  *              char *textfile;
21  *              char **lines;
22  *
23  *              // Grab lines in file.
24  *              textfile = grab_file(NULL, argv[1], NULL);
25  *              if (!textfile)
26  *                      err(1, "Failed reading %s", argv[1]);
27  *              lines = strsplit(textfile, textfile, "\n", STR_EMPTY_OK);
28  *
29  *              // Join them back together with two linefeeds.
30  *              printf("%s", strjoin(textfile, lines, "\n\n", STR_TRAIL));
31  *
32  *              // Free everything, just because we can.
33  *              tal_free(textfile);
34  *              return 0;
35  *      }
36  *
37  * License: BSD-MIT
38  * Author: Rusty Russell <rusty@rustcorp.com.au>
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/str\n");
47                 printf("ccan/tal\n");
48                 return 0;
49         }
50
51         return 1;
52 }