ctopts.c revision 0bbfda8a
1/*
2 * Compile-time options
3 */
4
5#include "ctwm.h"
6
7#include <stdio.h>
8#include <stdlib.h>
9#include <string.h>
10
11#include "ctopts.h"
12
13
14/*
15 * What options we're build with
16 */
17static char *ctopts[] = {
18	"I18N",     // Used to be optional, now standard.  Remove?
19#ifdef XPM
20	"XPM",
21#endif
22#ifdef JPEG
23	"JPEG",
24#endif
25#ifdef USEM4
26	"USEM4",
27#endif
28#ifdef SOUNDS
29	"SOUNDS",
30#endif
31#ifdef EWMH
32	"EWMH",
33#endif
34#ifdef DEBUG
35	"DEBUG",
36#endif
37	NULL
38};
39
40
41/*
42 * Build a string of our compile-time opts
43 */
44char *
45ctopts_string(char *sep)
46{
47	char *cto;
48	size_t slen, tlen;
49	int i;
50
51	/* Figure out how long our string would be */
52	slen = strlen(sep);
53	tlen = 0;
54	i = -1;
55	while(ctopts[++i]) {
56		tlen += strlen(ctopts[i]);
57		if(i > 0) {
58			tlen += slen;
59		}
60	}
61
62	/* Now make it */
63	cto = malloc(tlen + 1);
64	*cto = '\0';
65	i = -1;
66	while(ctopts[++i]) {
67		if(i > 0) {
68			strcat(cto, sep);
69		}
70		strcat(cto, ctopts[i]);
71	}
72
73	return cto;
74}
75