MCPcopy Create free account
hub / github.com/OpenPrinting/cups / get_cupsd_conf

Function get_cupsd_conf

cups/adminutil.c:1354–1447  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1352 */
1353
1354static http_status_t /* O - Status of request */
1355get_cupsd_conf(
1356 http_t *http, /* I - Connection to server */
1357 _cups_globals_t *cg, /* I - Global data */
1358 time_t last_update, /* I - Last update time for file */
1359 char *name, /* I - Filename buffer */
1360 size_t namesize, /* I - Size of filename buffer */
1361 int *remote) /* O - Remote file? */
1362{
1363 int fd; /* Temporary file descriptor */
1364#ifndef _WIN32
1365 struct stat info; /* cupsd.conf file information */
1366#endif /* _WIN32 */
1367 http_status_t status; /* Status of getting cupsd.conf */
1368 char host[HTTP_MAX_HOST]; /* Hostname for connection */
1369
1370
1371 /*
1372 * See if we already have the data we need...
1373 */
1374
1375 httpGetHostname(http, host, sizeof(host));
1376
1377 if (_cups_strcasecmp(cg->cupsd_hostname, host))
1378 invalidate_cupsd_cache(cg);
1379
1380 snprintf(name, namesize, "%s/cupsd.conf", cg->cups_serverroot);
1381 *remote = 0;
1382
1383#ifndef _WIN32
1384 if (!_cups_strcasecmp(host, "localhost") && !access(name, R_OK))
1385 {
1386 /*
1387 * Read the local file rather than using HTTP...
1388 */
1389
1390 if (stat(name, &info))
1391 {
1392 char message[1024]; /* Message string */
1393
1394
1395 snprintf(message, sizeof(message),
1396 _cupsLangString(cupsLangDefault(), _("stat of %s failed: %s")),
1397 name, strerror(errno));
1398 _cupsSetError(IPP_STATUS_ERROR_INTERNAL, message, 0);
1399
1400 *name = '\0';
1401
1402 return (HTTP_STATUS_SERVER_ERROR);
1403 }
1404 else if (last_update && info.st_mtime <= last_update)
1405 status = HTTP_STATUS_NOT_MODIFIED;
1406 else
1407 status = HTTP_STATUS_OK;
1408 }
1409 else
1410#endif /* !_WIN32 */
1411 {

Callers 2

Calls 12

httpGetHostnameFunction · 0.85
_cups_strcasecmpFunction · 0.85
invalidate_cupsd_cacheFunction · 0.85
_cupsLangStringFunction · 0.85
cupsLangDefaultFunction · 0.85
_cupsSetErrorFunction · 0.85
cupsTempFdFunction · 0.85
httpClearFieldsFunction · 0.85
httpSetFieldFunction · 0.85
httpGetDateStringFunction · 0.85
cupsGetFdFunction · 0.85
statClass · 0.70

Tested by

no test coverage detected