| 1201 | */ |
| 1202 | |
| 1203 | ipp_attribute_t * /* O - New attribute */ |
| 1204 | ippAddStrings( |
| 1205 | ipp_t *ipp, /* I - IPP message */ |
| 1206 | ipp_tag_t group, /* I - IPP group */ |
| 1207 | ipp_tag_t value_tag, /* I - Type of attribute */ |
| 1208 | const char *name, /* I - Name of attribute */ |
| 1209 | int num_values, /* I - Number of values */ |
| 1210 | const char *language, /* I - Language code (@code NULL@ for default) */ |
| 1211 | const char * const *values) /* I - Values */ |
| 1212 | { |
| 1213 | int i; /* Looping var */ |
| 1214 | ipp_tag_t temp_tag; /* Temporary value tag (masked) */ |
| 1215 | ipp_attribute_t *attr; /* New attribute */ |
| 1216 | _ipp_value_t *value; /* Current value */ |
| 1217 | char code[32]; /* Language/charset value buffer */ |
| 1218 | |
| 1219 | |
| 1220 | DEBUG_printf(("ippAddStrings(ipp=%p, group=%02x(%s), value_tag=%02x(%s), name=\"%s\", num_values=%d, language=\"%s\", values=%p)", (void *)ipp, group, ippTagString(group), value_tag, ippTagString(value_tag), name, num_values, language, (void *)values)); |
| 1221 | |
| 1222 | /* |
| 1223 | * Range check input... |
| 1224 | */ |
| 1225 | |
| 1226 | temp_tag = (ipp_tag_t)((int)value_tag & IPP_TAG_CUPS_MASK); |
| 1227 | |
| 1228 | #if 0 |
| 1229 | if (!ipp || !name || group < IPP_TAG_ZERO || |
| 1230 | group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE || |
| 1231 | (temp_tag < IPP_TAG_TEXT && temp_tag != IPP_TAG_TEXTLANG && |
| 1232 | temp_tag != IPP_TAG_NAMELANG) || temp_tag > IPP_TAG_MIMETYPE || |
| 1233 | num_values < 1) |
| 1234 | return (NULL); |
| 1235 | |
| 1236 | if ((temp_tag == IPP_TAG_TEXTLANG || temp_tag == IPP_TAG_NAMELANG) |
| 1237 | != (language != NULL)) |
| 1238 | return (NULL); |
| 1239 | #else |
| 1240 | if (!ipp || !name || group < IPP_TAG_ZERO || |
| 1241 | group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE || |
| 1242 | num_values < 1) |
| 1243 | return (NULL); |
| 1244 | #endif /* 0 */ |
| 1245 | |
| 1246 | /* |
| 1247 | * See if we need to map charset, language, or locale values... |
| 1248 | */ |
| 1249 | |
| 1250 | if (language && ((int)value_tag & IPP_TAG_CUPS_CONST) && |
| 1251 | strcmp(language, ipp_lang_code(language, code, sizeof(code)))) |
| 1252 | value_tag = temp_tag; /* Don't do a fast copy */ |
| 1253 | else if (values && value_tag == (ipp_tag_t)(IPP_TAG_CHARSET | IPP_TAG_CUPS_CONST)) |
| 1254 | { |
| 1255 | for (i = 0; i < num_values; i ++) |
| 1256 | if (strcmp(values[i], ipp_get_code(values[i], code, sizeof(code)))) |
| 1257 | { |
| 1258 | value_tag = temp_tag; /* Don't do a fast copy */ |
| 1259 | break; |
| 1260 | } |