-
-
-/*
- * 'write_option()' - Write a CUPS option to a PPD file.
- */
-
-static void
-write_option(cups_file_t *dstfp, /* I - PPD file */
- int order, /* I - Order dependency */
- const char *name, /* I - Option name */
- const char *text, /* I - Option text */
- const char *attrname, /* I - Attribute name */
- ipp_attribute_t *suppattr, /* I - IPP -supported attribute */
- ipp_attribute_t *defattr, /* I - IPP -default attribute */
- int defval, /* I - Default value number */
- int valcount) /* I - Number of values */
-{
- int i; /* Looping var */
-
-
- cupsFilePrintf(dstfp, "*JCLOpenUI *%s/%s: PickOne\n"
- "*OrderDependency: %d JCLSetup *%s\n",
- name, text, order, name);
-
- if (defattr->value_tag == IPP_TAG_INTEGER)
- {
- /*
- * Do numeric options with a range or list...
- */
-
- cupsFilePrintf(dstfp, "*Default%s: %d\n", name,
- defattr->values[defval].integer);
-
- if (suppattr->value_tag == IPP_TAG_RANGE)
- {
- /*
- * List each number in the range...
- */
-
- for (i = suppattr->values[0].range.lower;
- i <= suppattr->values[0].range.upper;
- i ++)
- {
- cupsFilePrintf(dstfp, "*%s %d: \"", name, i);
-
- if (valcount == 1)
- cupsFilePrintf(dstfp, "%%cupsJobTicket: %s=%d\n\"\n*End\n",
- attrname, i);
- else if (defval == 0)
- cupsFilePrintf(dstfp, "%%cupsJobTicket: %s=%d\"\n", attrname, i);
- else if (defval < (valcount - 1))
- cupsFilePrintf(dstfp, ",%d\"\n", i);
- else
- cupsFilePrintf(dstfp, ",%d\n\"\n*End\n", i);
- }
- }
- else
- {
- /*
- * List explicit numbers...
- */
-
- for (i = 0; i < suppattr->num_values; i ++)
- {
- cupsFilePrintf(dstfp, "*%s %d: \"", name, suppattr->values[i].integer);
-
- if (valcount == 1)
- cupsFilePrintf(dstfp, "%%cupsJobTicket: %s=%d\n\"\n*End\n", attrname,
- suppattr->values[i].integer);
- else if (defval == 0)
- cupsFilePrintf(dstfp, "%%cupsJobTicket: %s=%d\"\n", attrname,
- suppattr->values[i].integer);
- else if (defval < (valcount - 1))
- cupsFilePrintf(dstfp, ",%d\"\n", suppattr->values[i].integer);
- else
- cupsFilePrintf(dstfp, ",%d\n\"\n*End\n", suppattr->values[i].integer);
- }
- }
- }
- else
- {
- /*
- * Do text options with a list...
- */
-
- cupsFilePrintf(dstfp, "*Default%s: %s\n", name,
- defattr->values[defval].string.text);
-
- for (i = 0; i < suppattr->num_values; i ++)
- {
- cupsFilePrintf(dstfp, "*%s %s: \"", name,
- suppattr->values[i].string.text);
-
- if (valcount == 1)
- cupsFilePrintf(dstfp, "%%cupsJobTicket: %s=%s\n\"\n*End\n", attrname,
- suppattr->values[i].string.text);
- else if (defval == 0)
- cupsFilePrintf(dstfp, "%%cupsJobTicket: %s=%s\"\n", attrname,
- suppattr->values[i].string.text);
- else if (defval < (valcount - 1))
- cupsFilePrintf(dstfp, ",%s\"\n", suppattr->values[i].string.text);
- else
- cupsFilePrintf(dstfp, ",%s\n\"\n*End\n",
- suppattr->values[i].string.text);
- }
- }
-
- cupsFilePrintf(dstfp, "*JCLCloseUI: *%s\n\n", name);
-}