| 5821 | */ |
| 5822 | |
| 5823 | static int /* O - 1 on match, 0 on non-match */ |
| 5824 | with_value(ipptool_test_t *data, /* I - Test data */ |
| 5825 | cups_array_t *errors, /* I - Errors array */ |
| 5826 | char *value, /* I - Value string */ |
| 5827 | int flags, /* I - Flags for match */ |
| 5828 | ipp_attribute_t *attr, /* I - Attribute to compare */ |
| 5829 | char *matchbuf, /* I - Buffer to hold matching value */ |
| 5830 | size_t matchlen) /* I - Length of match buffer */ |
| 5831 | { |
| 5832 | int i, /* Looping var */ |
| 5833 | count, /* Number of values */ |
| 5834 | match; /* Match? */ |
| 5835 | char temp[1024], /* Temporary value string */ |
| 5836 | *valptr; /* Pointer into value */ |
| 5837 | const char *name; /* Attribute name */ |
| 5838 | |
| 5839 | |
| 5840 | *matchbuf = '\0'; |
| 5841 | match = (flags & IPPTOOL_WITH_ALL) ? 1 : 0; |
| 5842 | |
| 5843 | /* |
| 5844 | * NULL matches everything. |
| 5845 | */ |
| 5846 | |
| 5847 | if (!value || !*value) |
| 5848 | return (1); |
| 5849 | |
| 5850 | /* |
| 5851 | * Compare the value string to the attribute value. |
| 5852 | */ |
| 5853 | |
| 5854 | name = ippGetName(attr); |
| 5855 | count = ippGetCount(attr); |
| 5856 | |
| 5857 | switch (ippGetValueTag(attr)) |
| 5858 | { |
| 5859 | case IPP_TAG_INTEGER : |
| 5860 | case IPP_TAG_ENUM : |
| 5861 | for (i = 0; i < count; i ++) |
| 5862 | { |
| 5863 | char op, /* Comparison operator */ |
| 5864 | *nextptr; /* Next pointer */ |
| 5865 | int intvalue, /* Integer value */ |
| 5866 | attrvalue = ippGetInteger(attr, i), |
| 5867 | /* Attribute value */ |
| 5868 | valmatch = 0; /* Does the current value match? */ |
| 5869 | |
| 5870 | valptr = value; |
| 5871 | |
| 5872 | while (isspace(*valptr & 255) || isdigit(*valptr & 255) || |
| 5873 | *valptr == '-' || *valptr == ',' || *valptr == '<' || |
| 5874 | *valptr == '=' || *valptr == '>') |
| 5875 | { |
| 5876 | op = '='; |
| 5877 | while (*valptr && !isdigit(*valptr & 255) && *valptr != '-') |
| 5878 | { |
| 5879 | if (*valptr == '<' || *valptr == '>' || *valptr == '=') |
| 5880 | op = *valptr; |
no test coverage detected