| 435 | } |
| 436 | |
| 437 | int poptReadDefaultConfig(poptContext con, UNUSED(int useEnv)) |
| 438 | { |
| 439 | char * home; |
| 440 | struct stat sb; |
| 441 | int rc = 0; /* assume success */ |
| 442 | |
| 443 | if (con->appName == NULL) goto exit; |
| 444 | |
| 445 | rc = poptReadConfigFile(con, POPT_SYSCONFDIR "/popt"); |
| 446 | if (rc) goto exit; |
| 447 | |
| 448 | #if defined(HAVE_GLOB_H) |
| 449 | if (!stat(POPT_SYSCONFDIR "/popt.d", &sb) && S_ISDIR(sb.st_mode)) { |
| 450 | const char ** av = NULL; |
| 451 | int ac = 0; |
| 452 | int i; |
| 453 | |
| 454 | if ((rc = poptGlob(con, POPT_SYSCONFDIR "/popt.d/*", &ac, &av)) == 0) { |
| 455 | for (i = 0; rc == 0 && i < ac; i++) { |
| 456 | const char * fn = av[i]; |
| 457 | if (!poptSaneFile(fn)) |
| 458 | continue; |
| 459 | rc = poptReadConfigFile(con, fn); |
| 460 | free((void *)av[i]); |
| 461 | av[i] = NULL; |
| 462 | } |
| 463 | free(av); |
| 464 | av = NULL; |
| 465 | } |
| 466 | } |
| 467 | if (rc) goto exit; |
| 468 | #endif |
| 469 | |
| 470 | if ((home = getenv("HOME"))) { |
| 471 | char * fn = malloc(strlen(home) + 20); |
| 472 | if (fn != NULL) { |
| 473 | (void) stpcpy(stpcpy(fn, home), "/.popt"); |
| 474 | rc = poptReadConfigFile(con, fn); |
| 475 | free(fn); |
| 476 | } else |
| 477 | rc = POPT_ERROR_ERRNO; |
| 478 | if (rc) goto exit; |
| 479 | } |
| 480 | |
| 481 | exit: |
| 482 | return rc; |
| 483 | } |
| 484 | |
| 485 | poptContext |
| 486 | poptFini(poptContext con) |
no test coverage detected