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

Function parse_protocols

scheduler/conf.c:2626–2683  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2624 */
2625
2626static int /* O - Browse protocol bits */
2627parse_protocols(const char *s) /* I - Space-delimited protocols */
2628{
2629 int protocols; /* Browse protocol bits */
2630 char value[1024], /* Value string */
2631 *valstart, /* Pointer into value */
2632 *valend; /* End of value */
2633
2634
2635 /*
2636 * Empty protocol line yields NULL pointer...
2637 */
2638
2639 if (!s)
2640 return (0);
2641
2642 /*
2643 * Loop through the value string,...
2644 */
2645
2646 strlcpy(value, s, sizeof(value));
2647
2648 protocols = 0;
2649
2650 for (valstart = value; *valstart;)
2651 {
2652 /*
2653 * Get the current space/comma-delimited protocol name...
2654 */
2655
2656 for (valend = valstart; *valend; valend ++)
2657 if (_cups_isspace(*valend) || *valend == ',')
2658 break;
2659
2660 if (*valend)
2661 *valend++ = '\0';
2662
2663 /*
2664 * Add the protocol to the bitmask...
2665 */
2666
2667 if (!_cups_strcasecmp(valstart, "dnssd") ||
2668 !_cups_strcasecmp(valstart, "dns-sd") ||
2669 !_cups_strcasecmp(valstart, "bonjour"))
2670 protocols |= BROWSE_DNSSD;
2671 else if (!_cups_strcasecmp(valstart, "all"))
2672 protocols |= BROWSE_ALL;
2673 else if (_cups_strcasecmp(valstart, "none"))
2674 cupsdLogMessage(CUPSD_LOG_ERROR,
2675 "Unknown browse protocol \"%s\" ignored.", valstart);
2676
2677 for (valstart = valend; *valstart; valstart ++)
2678 if (!_cups_isspace(*valstart) || *valstart != ',')
2679 break;
2680 }
2681
2682 return (protocols);
2683}

Callers 2

cupsdReadConfigurationFunction · 0.85
read_cupsd_confFunction · 0.85

Calls 3

_cups_isspaceFunction · 0.85
_cups_strcasecmpFunction · 0.85
cupsdLogMessageFunction · 0.85

Tested by

no test coverage detected