| 614 | */ |
| 615 | |
| 616 | static const char * /* O - Parameter value or @code NULL@ if not present */ |
| 617 | cups_auth_param(const char *scheme, /* I - Pointer to auth data */ |
| 618 | const char *name, /* I - Name of parameter */ |
| 619 | char *value, /* I - Value buffer */ |
| 620 | size_t valsize) /* I - Size of value buffer */ |
| 621 | { |
| 622 | char *valptr = value, /* Pointer into value buffer */ |
| 623 | *valend = value + valsize - 1; /* Pointer to end of buffer */ |
| 624 | size_t namelen = strlen(name); /* Name length */ |
| 625 | int param; /* Is this a parameter? */ |
| 626 | |
| 627 | |
| 628 | DEBUG_printf(("8cups_auth_param(scheme=\"%s\", name=\"%s\", value=%p, valsize=%d)", scheme, name, (void *)value, (int)valsize)); |
| 629 | |
| 630 | while (!isspace(*scheme & 255) && *scheme) |
| 631 | scheme ++; |
| 632 | |
| 633 | while (*scheme) |
| 634 | { |
| 635 | while (isspace(*scheme & 255) || *scheme == ',') |
| 636 | scheme ++; |
| 637 | |
| 638 | if (!strncmp(scheme, name, namelen) && scheme[namelen] == '=') |
| 639 | { |
| 640 | /* |
| 641 | * Found the parameter, copy the value... |
| 642 | */ |
| 643 | |
| 644 | scheme += namelen + 1; |
| 645 | if (*scheme == '\"') |
| 646 | { |
| 647 | scheme ++; |
| 648 | |
| 649 | while (*scheme && *scheme != '\"') |
| 650 | { |
| 651 | if (valptr < valend) |
| 652 | *valptr++ = *scheme; |
| 653 | |
| 654 | scheme ++; |
| 655 | } |
| 656 | } |
| 657 | else |
| 658 | { |
| 659 | while (*scheme && strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~+/=", *scheme)) |
| 660 | { |
| 661 | if (valptr < valend) |
| 662 | *valptr++ = *scheme; |
| 663 | |
| 664 | scheme ++; |
| 665 | } |
| 666 | } |
| 667 | |
| 668 | *valptr = '\0'; |
| 669 | |
| 670 | DEBUG_printf(("9cups_auth_param: Returning \"%s\".", value)); |
| 671 | |
| 672 | return (value); |
| 673 | } |
no outgoing calls
no test coverage detected