| 369 | */ |
| 370 | |
| 371 | ipp_attribute_t * /* O - New attribute */ |
| 372 | ippAddInteger(ipp_t *ipp, /* I - IPP message */ |
| 373 | ipp_tag_t group, /* I - IPP group */ |
| 374 | ipp_tag_t value_tag, /* I - Type of attribute */ |
| 375 | const char *name, /* I - Name of attribute */ |
| 376 | int value) /* I - Value of attribute */ |
| 377 | { |
| 378 | ipp_attribute_t *attr; /* New attribute */ |
| 379 | |
| 380 | |
| 381 | DEBUG_printf(("ippAddInteger(ipp=%p, group=%02x(%s), type=%02x(%s), name=\"%s\", value=%d)", (void *)ipp, group, ippTagString(group), value_tag, ippTagString(value_tag), name, value)); |
| 382 | |
| 383 | value_tag &= IPP_TAG_CUPS_MASK; |
| 384 | |
| 385 | /* |
| 386 | * Special-case for legacy usage: map out-of-band attributes to new ippAddOutOfBand |
| 387 | * function... |
| 388 | */ |
| 389 | |
| 390 | if (value_tag >= IPP_TAG_UNSUPPORTED_VALUE && value_tag <= IPP_TAG_ADMINDEFINE) |
| 391 | return (ippAddOutOfBand(ipp, group, value_tag, name)); |
| 392 | |
| 393 | /* |
| 394 | * Range check input... |
| 395 | */ |
| 396 | |
| 397 | #if 0 |
| 398 | if (!ipp || !name || group < IPP_TAG_ZERO || |
| 399 | group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE || |
| 400 | (value_tag != IPP_TAG_INTEGER && value_tag != IPP_TAG_ENUM)) |
| 401 | return (NULL); |
| 402 | #else |
| 403 | if (!ipp || !name || group < IPP_TAG_ZERO || |
| 404 | group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE) |
| 405 | return (NULL); |
| 406 | #endif /* 0 */ |
| 407 | |
| 408 | /* |
| 409 | * Create the attribute... |
| 410 | */ |
| 411 | |
| 412 | if ((attr = ipp_add_attr(ipp, name, group, value_tag, 1)) == NULL) |
| 413 | return (NULL); |
| 414 | |
| 415 | attr->values[0].integer = value; |
| 416 | |
| 417 | return (attr); |
| 418 | } |
| 419 | |
| 420 | |
| 421 | /* |