static int nextword(const char **bufp_io, const char **word_r, int *l_r) { const char *p, *q; p= *bufp_io; while (ctype_whitespace(*p)) p++; if (!*p) return 0; q= p; while (*q && !ctype_whitespace(*q)) q++; *l_r= q-p; *word_r= p; *bufp_io= q; return 1; }
static void readconfiggeneric(adns_state ads, const char *filename, int (*getline)(adns_state ads, getline_ctx*, const char *filename, int lno, char *buf, int buflen), /* Returns >=0 for success, -1 for EOF or error * (error will have been reported), or -2 for * bad line was encountered, try again. */ getline_ctx gl_ctx) { char linebuf[2000], *p, *q; int lno, l, dirl; const struct configcommandinfo *ccip; for (lno=1; (l= getline(ads,&gl_ctx, filename,lno, linebuf,sizeof(linebuf))) != -1; lno++) { if (l == -2) continue; while (l>0 && ctype_whitespace(linebuf[l-1])) l--; linebuf[l]= 0; p= linebuf; while (ctype_whitespace(*p)) p++; if (*p == '#' || !*p) continue; q= p; while (*q && !ctype_whitespace(*q)) q++; dirl= q-p; for (ccip=configcommandinfos; ccip->name && !(strlen(ccip->name)==dirl && !memcmp(ccip->name,p,q-p)); ccip++); if (!ccip->name) { adns__diag(ads,-1,0,"%s:%d: unknown configuration directive `%.*s'", filename,lno,q-p,p); continue; } while (ctype_whitespace(*q)) q++; ccip->fn(ads,filename,lno,q); } }