| 1378 | */ |
| 1379 | |
| 1380 | int /* O - 1 on a match, 0 on no match */ |
| 1381 | ippContainsString( |
| 1382 | ipp_attribute_t *attr, /* I - Attribute */ |
| 1383 | const char *value) /* I - String value */ |
| 1384 | { |
| 1385 | int i; /* Looping var */ |
| 1386 | _ipp_value_t *avalue; /* Current attribute value */ |
| 1387 | |
| 1388 | |
| 1389 | DEBUG_printf(("ippContainsString(attr=%p, value=\"%s\")", (void *)attr, value)); |
| 1390 | |
| 1391 | /* |
| 1392 | * Range check input... |
| 1393 | */ |
| 1394 | |
| 1395 | if (!attr || !value) |
| 1396 | { |
| 1397 | DEBUG_puts("1ippContainsString: Returning 0 (bad input)"); |
| 1398 | return (0); |
| 1399 | } |
| 1400 | |
| 1401 | /* |
| 1402 | * Compare... |
| 1403 | */ |
| 1404 | |
| 1405 | DEBUG_printf(("1ippContainsString: attr %s, %s with %d values.", |
| 1406 | attr->name, ippTagString(attr->value_tag), |
| 1407 | attr->num_values)); |
| 1408 | |
| 1409 | switch (attr->value_tag & IPP_TAG_CUPS_MASK) |
| 1410 | { |
| 1411 | case IPP_TAG_CHARSET : |
| 1412 | case IPP_TAG_KEYWORD : |
| 1413 | case IPP_TAG_LANGUAGE : |
| 1414 | case IPP_TAG_URI : |
| 1415 | case IPP_TAG_URISCHEME : |
| 1416 | for (i = attr->num_values, avalue = attr->values; |
| 1417 | i > 0; |
| 1418 | i --, avalue ++) |
| 1419 | { |
| 1420 | DEBUG_printf(("1ippContainsString: value[%d]=\"%s\"", |
| 1421 | attr->num_values - i, avalue->string.text)); |
| 1422 | |
| 1423 | if (!strcmp(value, avalue->string.text)) |
| 1424 | { |
| 1425 | DEBUG_puts("1ippContainsString: Returning 1 (match)"); |
| 1426 | return (1); |
| 1427 | } |
| 1428 | } |
| 1429 | |
| 1430 | case IPP_TAG_MIMETYPE : |
| 1431 | case IPP_TAG_NAME : |
| 1432 | case IPP_TAG_NAMELANG : |
| 1433 | case IPP_TAG_TEXT : |
| 1434 | case IPP_TAG_TEXTLANG : |
| 1435 | for (i = attr->num_values, avalue = attr->values; |
| 1436 | i > 0; |
| 1437 | i --, avalue ++) |