]> git.ozlabs.org Git - ccan/blob - ccan/stringbuilder/_info
base64: fix for unsigned chars (e.g. ARM).
[ccan] / ccan / stringbuilder / _info
1 #include "config.h"
2 #include <stdio.h>
3 #include <string.h>
4
5 /**
6  * stringbuilder - join lists of strings
7  *
8  * This is a small set of functions for building up strings from a list.
9  * The destination buffer is bounds-checked, the functions return failure
10  * if the concatenated strings overflow the buffer.
11  *
12  * Example:
13  *      #include <stdio.h>
14  *      #include <string.h>
15  *      #include <errno.h>
16  *      #include <ccan/stringbuilder/stringbuilder.h>
17  *
18  *      int main(int argc, char *argv[])
19  *      {
20  *              char mystring[128];
21  *              int res;
22  *
23  *              res = stringbuilder_array(mystring, 128, "', '",
24  *                      argc, (const char**)argv);
25  *              if (!res)
26  *                      printf("My arguments: '%s'\n", mystring);
27  *              else
28  *                      printf("Failed to join arguments: %s\n",
29  *                              strerror(res));
30  *              if (!res) {
31  *                      res = stringbuilder(mystring, 128, ", ",
32  *                              "This", "Is", "A", "Test");
33  *                      if (!res)
34  *                              printf("My string: '%s'\n", mystring);
35  *                      else
36  *                              printf("Failed to join strings: %s\n",
37  *                                      strerror(res));
38  *              }
39  *              return 0;
40  *      }
41  *
42  * License: CC0 (Public domain)
43  * Author: Stuart Longland <stuartl@longlandclan.yi.org>
44  */
45 int main(int argc, char *argv[])
46 {
47         if (argc != 2)
48                 return 1;
49
50         if (strcmp(argv[1], "depends") == 0) {
51                 return 0;
52         }
53
54         if (strcmp(argv[1], "testdepends") == 0) {
55                 printf("ccan/str\n");
56                 return 0;
57         }
58
59         return 1;
60 }