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

Function parse_variable

scheduler/conf.c:2690–3510  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2688 */
2689
2690static int /* O - 1 on success, 0 on failure */
2691parse_variable(
2692 const char *filename, /* I - Name of configuration file */
2693 int linenum, /* I - Line in configuration file */
2694 const char *line, /* I - Line from configuration file */
2695 const char *value, /* I - Value from configuration file */
2696 size_t num_vars, /* I - Number of variables */
2697 const cupsd_var_t *vars) /* I - Variables */
2698{
2699 size_t i; /* Looping var */
2700 const cupsd_var_t *var; /* Variables */
2701 char temp[1024]; /* Temporary string */
2702
2703
2704 for (i = num_vars, var = vars; i; i --, var ++)
2705 if (!_cups_strcasecmp(line, var->name))
2706 break;
2707
2708 if (i == 0)
2709 {
2710 /*
2711 * Unknown directive! Output an error message and continue...
2712 *
2713 * Return value 1 is on purpose - we ignore unknown directives to log
2714 * error, but do not stop the scheduler in case error in configuration
2715 * is set to be fatal.
2716 */
2717
2718 cupsdLogMessage(CUPSD_LOG_ERROR, "Unknown directive %s on line %d of %s.",
2719 line, linenum, filename);
2720
2721 return (1);
2722 }
2723
2724 switch (var->type)
2725 {
2726 case CUPSD_VARTYPE_INTEGER :
2727 if (!value)
2728 {
2729 cupsdLogMessage(CUPSD_LOG_ERROR, "Missing integer value for %s on line %d of %s.", line, linenum, filename);
2730 return (0);
2731 }
2732 else if (!isdigit(*value & 255))
2733 {
2734 cupsdLogMessage(CUPSD_LOG_ERROR, "Bad integer value for %s on line %d of %s.", line, linenum, filename);
2735 return (0);
2736 }
2737 else
2738 {
2739 long n; /* Number */
2740 char *ptr; /* Remaining text */
2741
2742 n = strtol(value, &ptr, 0);
2743
2744 if (n < 0 || n > INT_MAX || (ptr && *ptr))
2745 {
2746 cupsdLogMessage(CUPSD_LOG_ERROR, "Bad integer value for %s on line %d of %s.", line, linenum, filename);
2747 return (0);

Callers 1

read_cups_files_confFunction · 0.85

Calls 5

_cups_strcasecmpFunction · 0.85
cupsdLogMessageFunction · 0.85
_cupsStrScandFunction · 0.85
_cups_strncasecmpFunction · 0.85
cupsdSetStringFunction · 0.85

Tested by

no test coverage detected