MCPcopy Index your code
hub / github.com/RsyncProject/rsync / poptReadConfigFile

Function poptReadConfigFile

popt/poptconfig.c:342–392  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

340}
341
342int poptReadConfigFile(poptContext con, const char * fn)
343{
344 char * b = NULL, *be;
345 size_t nb = 0;
346 const char *se;
347 char *t = NULL, *te;
348 int rc;
349
350 if ((rc = poptReadFile(fn, &b, &nb, POPT_READFILE_TRIMNEWLINES)) != 0)
351 return (errno == ENOENT ? 0 : rc);
352 if (b == NULL || nb == 0) {
353 rc = POPT_ERROR_BADCONFIG;
354 goto exit;
355 }
356
357 if ((t = malloc(nb + 1)) == NULL)
358 goto exit;
359 te = t;
360
361 be = (b + nb);
362 for (se = b; se < be; se++) {
363 switch (*se) {
364 case '\n':
365 *te = '\0';
366 te = t;
367 while (*te && _isspaceptr(te)) te++;
368 if (*te && *te != '#')
369 if ((rc = poptConfigLine(con, te)) != 0)
370 goto exit;
371 break;
372 case '\\':
373 *te = *se++;
374 /* \ at the end of a line does not insert a \n */
375 if (se < be && *se != '\n') {
376 te++;
377 *te++ = *se;
378 }
379 break;
380 default:
381 *te++ = *se;
382 break;
383 }
384 }
385 rc = 0;
386
387exit:
388 free(t);
389 if (b)
390 free(b);
391 return rc;
392}
393
394int poptReadConfigFiles(poptContext con, const char * paths)
395{

Callers 2

poptReadConfigFilesFunction · 0.85
poptReadDefaultConfigFunction · 0.85

Calls 2

poptReadFileFunction · 0.85
poptConfigLineFunction · 0.85

Tested by

no test coverage detected