14static stralloc line = {0};
15static stralloc me = {0};
21static void striptrailingwhitespace(stralloc *
sa)
24 switch (
sa->s[
sa->len - 1]) {
25 case '\n':
case ' ':
case '\t':
48 if (flagme)
if (meok)
return stralloc_copy(
sa,&me) ? 1 : -1;
60 if (
fd == -1) {
if (errno == ENOENT)
return 0;
return -1; }
64 if (getln(&
b,
sa,&
match,
'\n') == -1) { close(
fd);
return -1; }
66 striptrailingwhitespace(
sa);
80 if (!stralloc_0(&line))
return -1;
81 if (!scan_ulong(line.s,&u))
return 0;
97 if (errno == ENOENT) {
99 if (!stralloc_copy(
sa,&me))
return -1;
100 if (!stralloc_0(
sa))
return -1;
111 if (getln(&
b,&line,&
match,
'\n') == -1)
break;
112 if (!
match && !line.len) { close(
fd);
return 1; }
113 striptrailingwhitespace(&line);
114 if (!stralloc_0(&line))
break;
116 if (line.s[0] !=
'#')
117 if (!stralloc_cat(
sa,&line))
break;
118 if (!
match) { close(
fd);
return 1; }
int control_readint(unsigned long *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 *)