12 if (
c->flagconf)
return 0;
14 if (!stralloc_copys(&
c->sa,s))
return -1;
21 if (
c->flagconf)
return 0;
22 if (!
d->flagconf)
return 0;
23 if (!stralloc_copy(&
c->sa,&
d->sa))
return -1;
30 if (
c->flagconf)
return 0;
33 if (!stralloc_copys(&
c->sa,s))
return -1;
38static void process(stralloc *sa)
43 switch(sa->s[sa->len - 1]) {
44 case '\n':
case ' ':
case '\t':
47 for (i = 0;i < sa->len;++i)
54static char inbuf[128];
55static stralloc
line = {0};
63 if (
c->flagconf)
return 0;
67 if (
errno == error_noent)
return 0;
70 buffer_init(&
bi,read,fd,inbuf,
sizeof inbuf);
79 if (!stralloc_copy(&
c->sa,&
line))
return -1;
90 if (
c->flagconf)
return 0;
92 if (!stralloc_copys(&
c->sa,
""))
return -1;
96 if (
errno == error_noent)
return 0;
99 buffer_init(&
bi,read,fd,inbuf,
sizeof(inbuf));
102 if (getln(&
bi,&
line,&
match,
'\n') == -1) { close(fd);
return -1; }
104 if (!stralloc_0(&
line)) { close(fd);
return -1; }
106 if (
line.s[0] !=
'#')
107 if (!stralloc_cat(&
c->sa,&
line)) { close(fd);
return -1; }
int config_readline(config_str *c, char *fn)
int config_copy(config_str *c, config_str *d)
int config_env(config_str *c, char *s)
int config_default(config_str *c, char *s)
int config_readfile(config_str *c, char *fn)
void d(char *, char *, int, int, int)
void c(char *, char *, char *, int, int, int)