| 25 | */ |
| 26 | |
| 27 | ppd_attr_t * /* O - Attribute or @code NULL@ if not found */ |
| 28 | ppdFindAttr(ppd_file_t *ppd, /* I - PPD file data */ |
| 29 | const char *name, /* I - Attribute name */ |
| 30 | const char *spec) /* I - Specifier string or @code NULL@ */ |
| 31 | { |
| 32 | ppd_attr_t key, /* Search key */ |
| 33 | *attr; /* Current attribute */ |
| 34 | |
| 35 | |
| 36 | DEBUG_printf(("2ppdFindAttr(ppd=%p, name=\"%s\", spec=\"%s\")", ppd, name, |
| 37 | spec)); |
| 38 | |
| 39 | /* |
| 40 | * Range check input... |
| 41 | */ |
| 42 | |
| 43 | if (!ppd || !name || ppd->num_attrs == 0) |
| 44 | return (NULL); |
| 45 | |
| 46 | /* |
| 47 | * Search for a matching attribute... |
| 48 | */ |
| 49 | |
| 50 | memset(&key, 0, sizeof(key)); |
| 51 | strlcpy(key.name, name, sizeof(key.name)); |
| 52 | |
| 53 | /* |
| 54 | * Return the first matching attribute, if any... |
| 55 | */ |
| 56 | |
| 57 | if ((attr = (ppd_attr_t *)cupsArrayFind(ppd->sorted_attrs, &key)) != NULL) |
| 58 | { |
| 59 | if (spec) |
| 60 | { |
| 61 | /* |
| 62 | * Loop until we find the first matching attribute for "spec"... |
| 63 | */ |
| 64 | |
| 65 | while (attr && _cups_strcasecmp(spec, attr->spec)) |
| 66 | { |
| 67 | if ((attr = (ppd_attr_t *)cupsArrayNext(ppd->sorted_attrs)) != NULL && |
| 68 | _cups_strcasecmp(attr->name, name)) |
| 69 | attr = NULL; |
| 70 | } |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | return (attr); |
| 75 | } |
| 76 | |
| 77 | |
| 78 | /* |