]> git.ozlabs.org Git - ccan/blob - ccan/json_escape/_info
base64: fix for unsigned chars (e.g. ARM).
[ccan] / ccan / json_escape / _info
1 #include "config.h"
2 #include <stdio.h>
3 #include <string.h>
4
5 /**
6  * json_escape - Escape sequences for JSON strings
7  *
8  * This code helps you format strings into forms useful for JSON.
9  *
10  * Author: Rusty Russell <rusty@rustcorp.com.au>
11  * License: BSD-MIT
12  * Example:
13  *      // Print arguments as a JSON array.
14  *      #include <ccan/json_escape/json_escape.h>
15  *
16  *      int main(int argc, char *argv[])
17  *      {
18  *              printf("[");
19  *              for (int i = 1; i < argc; i++) {
20  *                      struct json_escape *e = json_escape(NULL, argv[i]);
21  *                      printf("%s\"%s\"", i == 1 ? "" : ",", e->s);
22  *              }
23  *              printf("]\n");
24  *              return 0;
25  *      }
26  */
27 int main(int argc, char *argv[])
28 {
29         /* Expect exactly one argument */
30         if (argc != 2)
31                 return 1;
32
33         if (strcmp(argv[1], "depends") == 0) {
34                 printf("ccan/tal\n");
35                 return 0;
36         }
37
38         return 1;
39 }