]> git.ozlabs.org Git - ccan/blob - ccan/tal/str/_info
base64: fix for unsigned chars (e.g. ARM).
[ccan] / ccan / tal / str / _info
1 #include "config.h"
2 #include <stdio.h>
3 #include <string.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".  Each string created by this library
11  * will have tal_count() equal to strlen() + 1 (assuming you didn't create
12  * a string containing a NUL, such as using tal_fmt("%c", 0)).
13  *
14  * Example:
15  *      #include <ccan/tal/str/str.h>
16  *      #include <ccan/tal/grab_file/grab_file.h>
17  *      #include <err.h>
18  *
19  *      // Dumb demo program to double-linespace a file.
20  *      int main(int argc, char *argv[])
21  *      {
22  *              char *textfile;
23  *              char **lines;
24  *
25  *              if (argc > 2)
26  *                      errx(1, "Takes 0 or 1 arguments");
27  *              // Grab lines in file.
28  *              textfile = grab_file(NULL, argv[1]);
29  *              if (!textfile)
30  *                      err(1, "Failed reading %s", argv[1]);
31  *              lines = tal_strsplit(textfile, textfile, "\n", STR_EMPTY_OK);
32  *
33  *              // Join them back together with two linefeeds.
34  *              printf("%s", tal_strjoin(textfile, lines, "\n\n", STR_TRAIL));
35  *
36  *              // Free everything, just because we can.
37  *              tal_free(textfile);
38  *              return 0;
39  *      }
40  *
41  * License: BSD-MIT
42  * Author: Rusty Russell <rusty@rustcorp.com.au>
43  */
44 int main(int argc, char *argv[])
45 {
46         if (argc != 2)
47                 return 1;
48
49         if (strcmp(argv[1], "depends") == 0) {
50                 printf("ccan/str\n");
51 #ifdef TAL_USE_TALLOC
52                 printf("ccan/tal/talloc\n");
53 #else
54                 printf("ccan/tal\n");
55 #endif
56                 printf("ccan/take\n");
57                 return 0;
58         }
59
60         return 1;
61 }