12static char inbuf[2048];
13static stralloc line = {0};
14static stralloc me = {0};
20static void striptrailingwhitespace(stralloc *
sa)
23 switch (
sa->s[
sa->len - 1]) {
24 case '\n':
case ' ':
case '\t':
47 if (flagme)
if (meok)
return stralloc_copy(
sa,&me) ? 1 : -1;
59 if (
fd == -1) {
if (errno == ENOENT)
return 0;
return -1; }
63 if (getln(&
b,
sa,&
match,
'\n') == -1) { close(
fd);
return -1; }
65 striptrailingwhitespace(
sa);
79 if (!stralloc_0(&line))
return -1;
80 if (!scan_ulong(line.s,&u))
return 0;
96 if (errno == ENOENT) {
98 if (!stralloc_copy(
sa,&me))
return -1;
99 if (!stralloc_0(
sa))
return -1;
110 if (getln(&
b,&line,&
match,
'\n') == -1)
break;
111 if (!
match && !line.len) { close(
fd);
return 1; }
112 striptrailingwhitespace(&line);
113 if (!stralloc_0(&line))
break;
115 if (line.s[0] !=
'#')
116 if (!stralloc_cat(
sa,&line))
break;
117 if (!
match) { close(
fd);
return 1; }
int control_readint(int *i, char *fn)
int control_readline(stralloc *sa, char *fn)
int control_rldef(stralloc *sa, char *fn, int flagme, char *def)
int control_readfile(stralloc *sa, char *fn, int flagme)
int stralloc_copys(stralloc *, char const *)