path:
root/
lemon/
readcfg.h (
plain)
blob: 0a05c55faf458772ae70631e081135ecffb58250
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
|
typedef struct {
char *name;
int port;
} server_t;
typedef struct {
int line;
char *file;
int rc;
server_t *top;
} parse_t;
char *slurp(char *file, size_t *len);
int tok(char **c, size_t *bsz, size_t *toksz, int *line);
void new_server(parse_t *ps);
#define newtop(out,ary) \
do { \
if (ary ## _left == 0) { \
void *nary = realloc(ary,(ary ## _used+10)*sizeof(*ary)); \
if (!nary) { \
printf("out of memory\n"); \
exit(-1); \
} \
ary = nary; \
ary ## _left = 10; \
} \
out = &ary[ary ## _used]; \
(ary ## _left)--; \
(ary ## _used)++; \
} while(0);
|