MCPcopy Create free account
hub / github.com/OpenPrinting/cups / _cupsEncodeOption

Function _cupsEncodeOption

cups/encode.c:388–689  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

386 */
387
388ipp_attribute_t * /* O - New attribute or @code NULL@ on error */
389_cupsEncodeOption(
390 ipp_t *ipp, /* I - IPP request/response/collection */
391 ipp_tag_t group_tag, /* I - Group tag */
392 _ipp_option_t *map, /* I - Option mapping, if any */
393 const char *name, /* I - Attribute name */
394 const char *value, /* I - Value */
395 int depth) /* I - Depth of values */
396{
397 int i, /* Looping var */
398 count; /* Number of values */
399 char *s, /* Pointer into option value */
400 *val, /* Pointer to option value */
401 *copy, /* Copy of option value */
402 *sep, /* Option separator */
403 quote; /* Quote character */
404 ipp_attribute_t *attr; /* IPP attribute */
405 ipp_tag_t value_tag; /* IPP value tag */
406 ipp_t *collection; /* Collection value */
407 int num_cols; /* Number of collection values */
408 cups_option_t *cols; /* Collection values */
409
410
411 DEBUG_printf(("_cupsEncodeOption(ipp=%p(%s), group=%s, map=%p, name=\"%s\", value=\"%s\")", (void *)ipp, ipp ? ippOpString(ippGetOperation(ipp)) : "", ippTagString(group_tag), (void *)map, name, value));
412
413 /*
414 * Figure out the attribute syntax for encoding...
415 */
416
417 if (!map)
418 map = _ippFindOption(name);
419
420 if (map)
421 value_tag = map->value_tag;
422 else if (!_cups_strcasecmp(value, "true") || !_cups_strcasecmp(value, "false"))
423 value_tag = IPP_TAG_BOOLEAN;
424 else if (value[0] == '{')
425 value_tag = IPP_TAG_BEGIN_COLLECTION;
426 else
427 value_tag = IPP_TAG_NAME;
428
429 /*
430 * Count the number of values...
431 */
432
433 if (map && map->multivalue)
434 {
435 for (count = 1, sep = (char *)value, quote = 0; *sep; sep ++)
436 {
437 if (*sep == quote)
438 quote = 0;
439 else if (!quote && (*sep == '\'' || *sep == '\"'))
440 {
441 /*
442 * Skip quoted option value...
443 */
444
445 quote = *sep;

Callers 3

cupsEncodeOptionFunction · 0.85
encode_optionsFunction · 0.85
cups_test_constraintsFunction · 0.85

Calls 15

ippOpStringFunction · 0.85
ippGetOperationFunction · 0.85
ippTagStringFunction · 0.85
_ippFindOptionFunction · 0.85
_cups_strcasecmpFunction · 0.85
ippAddStringsFunction · 0.85
ippDeleteAttributeFunction · 0.85
ippSetIntegerFunction · 0.85
ippSetBooleanFunction · 0.85
ippSetRangeFunction · 0.85
ippSetResolutionFunction · 0.85
ippSetOctetStringFunction · 0.85

Tested by

no test coverage detected