Merge branch 'rfc822'
[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 = tal_strsplit(textfile, textfile, "\n", STR_EMPTY_OK);
28  *
29  *              // Join them back together with two linefeeds.
30  *              printf("%s", tal_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 #ifdef TAL_USE_TALLOC
48                 printf("ccan/tal/talloc\n");
49 #else
50                 printf("ccan/tal\n");
51 #endif
52                 printf("ccan/take\n");
53                 return 0;
54         }
55
56         return 1;
57 }