| 722 | */ |
| 723 | |
| 724 | static const char * /* O - Start of scheme or @code NULL@ if not found */ |
| 725 | cups_auth_scheme(const char *www_authenticate, /* I - Pointer into WWW-Authenticate header */ |
| 726 | char *scheme, /* I - Scheme name buffer */ |
| 727 | size_t schemesize) /* I - Size of buffer */ |
| 728 | { |
| 729 | const char *start; /* Start of scheme data */ |
| 730 | char *sptr = scheme, /* Pointer into scheme buffer */ |
| 731 | *send = scheme + schemesize - 1;/* End of scheme buffer */ |
| 732 | int param; /* Is this a parameter? */ |
| 733 | |
| 734 | |
| 735 | DEBUG_printf(("8cups_auth_scheme(www_authenticate=\"%s\", scheme=%p, schemesize=%u)", www_authenticate, (void *)scheme, (unsigned)schemesize)); |
| 736 | |
| 737 | while (*www_authenticate) |
| 738 | { |
| 739 | /* |
| 740 | * Skip leading whitespace and commas... |
| 741 | */ |
| 742 | |
| 743 | while (isspace(*www_authenticate & 255) || *www_authenticate == ',') |
| 744 | www_authenticate ++; |
| 745 | |
| 746 | /* |
| 747 | * Parse the scheme name or param="value" string... |
| 748 | */ |
| 749 | |
| 750 | for (sptr = scheme, start = www_authenticate, param = 0; *www_authenticate && *www_authenticate != ',' && !isspace(*www_authenticate & 255); www_authenticate ++) |
| 751 | { |
| 752 | if (*www_authenticate == '=') |
| 753 | param = 1; |
| 754 | else if (!param && sptr < send) |
| 755 | *sptr++ = *www_authenticate; |
| 756 | else if (*www_authenticate == '\"') |
| 757 | { |
| 758 | /* |
| 759 | * Skip quoted value... |
| 760 | */ |
| 761 | |
| 762 | |
| 763 | do |
| 764 | www_authenticate ++; |
| 765 | while (*www_authenticate && *www_authenticate != '\"'); |
| 766 | } |
| 767 | } |
| 768 | |
| 769 | if (sptr > scheme && !param) |
| 770 | { |
| 771 | *sptr = '\0'; |
| 772 | |
| 773 | DEBUG_printf(("9cups_auth_scheme: Returning \"%s\".", start)); |
| 774 | |
| 775 | return (start); |
| 776 | } |
| 777 | } |
| 778 | |
| 779 | *scheme = '\0'; |
| 780 | |
| 781 | DEBUG_puts("9cups_auth_scheme: Returning NULL."); |
no outgoing calls
no test coverage detected