summaryrefslogtreecommitdiff
path: root/ccan/stringbuilder/_info
blob: 802914c2bc509163c08da1e932a8228a67ea7f36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "config.h"
#include <stdio.h>
#include <string.h>

/**
 * stringbuilder - join lists of strings
 *
 * This is a small set of functions for building up strings from a list.
 * The destination buffer is bounds-checked, the functions return failure
 * if the concatenated strings overflow the buffer.
 *
 * Example:
 *	#include <stdio.h>
 *	#include <string.h>
 *	#include <errno.h>
 *	#include <ccan/stringbuilder/stringbuilder.h>
 *
 *	int main(int argc, char *argv[])
 *	{
 *		char mystring[128];
 *		int res;
 *
 *		res = stringbuilder_array(mystring, 128, "', '",
 *			argc, (const char**)argv);
 *		if (!res)
 *			printf("My arguments: '%s'\n", mystring);
 *		else
 *			printf("Failed to join arguments: %s\n",
 *				strerror(res));
 *		if (!res) {
 *			res = stringbuilder(mystring, 128, ", ",
 *				"This", "Is", "A", "Test");
 *			if (!res)
 *				printf("My string: '%s'\n", mystring);
 *			else
 *				printf("Failed to join strings: %s\n",
 *					strerror(res));
 *		}
 *		return 0;
 *	}
 *
 * License: CC0 (Public domain)
 * Author: Stuart Longland <stuartl@longlandclan.yi.org>
 */
int main(int argc, char *argv[])
{
	if (argc != 2)
		return 1;

	if (strcmp(argv[1], "depends") == 0) {
		return 0;
	}

	if (strcmp(argv[1], "testdepends") == 0) {
		printf("ccan/str\n");
		return 0;
	}

	return 1;
}