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

Function parse_groups

scheduler/conf.c:2543–2619  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2541 */
2542
2543static int /* O - 1 on success, 0 on failure */
2544parse_groups(const char *s, /* I - Space-delimited groups */
2545 int linenum) /* I - Line number in cups-files.conf */
2546{
2547 int status; /* Return status */
2548 char value[1024], /* Value string */
2549 *valstart, /* Pointer into value */
2550 *valend, /* End of value */
2551 quote; /* Quote character */
2552 struct group *group; /* Group */
2553
2554
2555 /*
2556 * Make a copy of the string and parse out the groups...
2557 */
2558
2559 strlcpy(value, s, sizeof(value));
2560
2561 status = 1;
2562 valstart = value;
2563
2564 while (*valstart && NumSystemGroups < MAX_SYSTEM_GROUPS)
2565 {
2566 if (*valstart == '\'' || *valstart == '\"')
2567 {
2568 /*
2569 * Scan quoted name...
2570 */
2571
2572 quote = *valstart++;
2573
2574 for (valend = valstart; *valend; valend ++)
2575 if (*valend == quote)
2576 break;
2577 }
2578 else
2579 {
2580 /*
2581 * Scan space or comma-delimited name...
2582 */
2583
2584 for (valend = valstart; *valend; valend ++)
2585 if (_cups_isspace(*valend) || *valend == ',')
2586 break;
2587 }
2588
2589 if (*valend)
2590 *valend++ = '\0';
2591
2592 group = getgrnam(valstart);
2593 if (group)
2594 {
2595 cupsdSetString(SystemGroups + NumSystemGroups, valstart);
2596 SystemGroupIDs[NumSystemGroups] = group->gr_gid;
2597
2598 NumSystemGroups ++;
2599 }
2600 else

Callers 2

cupsdReadConfigurationFunction · 0.85
read_cups_files_confFunction · 0.85

Calls 3

_cups_isspaceFunction · 0.85
cupsdSetStringFunction · 0.85
cupsdLogMessageFunction · 0.85

Tested by

no test coverage detected