| 150 | */ |
| 151 | |
| 152 | cups_array_t * /* O - Array of objects */ |
| 153 | cgiGetIPPObjects(ipp_t *response, /* I - IPP response */ |
| 154 | void *search) /* I - Search filter */ |
| 155 | { |
| 156 | int i; /* Looping var */ |
| 157 | cups_array_t *objs; /* Array of objects */ |
| 158 | ipp_attribute_t *attr, /* Current attribute */ |
| 159 | *first; /* First attribute for object */ |
| 160 | ipp_tag_t group; /* Current group tag */ |
| 161 | int add; /* Add this object to the array? */ |
| 162 | |
| 163 | |
| 164 | if (!response) |
| 165 | return (0); |
| 166 | |
| 167 | for (add = 0, first = NULL, objs = cupsArrayNew(NULL, NULL), |
| 168 | group = IPP_TAG_ZERO, attr = response->attrs; |
| 169 | attr; |
| 170 | attr = attr->next) |
| 171 | { |
| 172 | if (attr->group_tag != group) |
| 173 | { |
| 174 | group = attr->group_tag; |
| 175 | |
| 176 | if (group != IPP_TAG_ZERO && group != IPP_TAG_OPERATION) |
| 177 | { |
| 178 | first = attr; |
| 179 | add = 0; |
| 180 | } |
| 181 | else if (add && first) |
| 182 | { |
| 183 | cupsArrayAdd(objs, first); |
| 184 | |
| 185 | add = 0; |
| 186 | first = NULL; |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | if (attr->name && attr->group_tag != IPP_TAG_OPERATION && !add) |
| 191 | { |
| 192 | if (!search) |
| 193 | { |
| 194 | /* |
| 195 | * Add all objects if there is no search... |
| 196 | */ |
| 197 | |
| 198 | add = 1; |
| 199 | } |
| 200 | else |
| 201 | { |
| 202 | /* |
| 203 | * Check the search string against the string and integer values. |
| 204 | */ |
| 205 | |
| 206 | switch (attr->value_tag) |
| 207 | { |
| 208 | case IPP_TAG_TEXTLANG : |
| 209 | case IPP_TAG_NAMELANG : |
no test coverage detected