| 2085 | */ |
| 2086 | |
| 2087 | const char * /* O - Enum string */ |
| 2088 | ippEnumString(const char *attrname, /* I - Attribute name */ |
| 2089 | int enumvalue) /* I - Enum value */ |
| 2090 | { |
| 2091 | _cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */ |
| 2092 | |
| 2093 | |
| 2094 | /* |
| 2095 | * Check for standard enum values... |
| 2096 | */ |
| 2097 | |
| 2098 | if (!strcmp(attrname, "document-state") && enumvalue >= 3 && enumvalue < (3 + (int)(sizeof(ipp_document_states) / sizeof(ipp_document_states[0])))) |
| 2099 | return (ipp_document_states[enumvalue - 3]); |
| 2100 | else if (!strcmp(attrname, "finishings") || !strcmp(attrname, "finishings-actual") || !strcmp(attrname, "finishings-default") || !strcmp(attrname, "finishings-ready") || !strcmp(attrname, "finishings-supported") || !strcmp(attrname, "job-finishings") || !strcmp(attrname, "job-finishings-default") || !strcmp(attrname, "job-finishings-supported")) |
| 2101 | { |
| 2102 | if (enumvalue >= 3 && enumvalue < (3 + (int)(sizeof(ipp_finishings) / sizeof(ipp_finishings[0])))) |
| 2103 | return (ipp_finishings[enumvalue - 3]); |
| 2104 | else if (enumvalue >= 0x40000000 && enumvalue < (0x40000000 + (int)(sizeof(ipp_finishings_vendor) / sizeof(ipp_finishings_vendor[0])))) |
| 2105 | return (ipp_finishings_vendor[enumvalue - 0x40000000]); |
| 2106 | } |
| 2107 | else if ((!strcmp(attrname, "job-collation-type") || !strcmp(attrname, "job-collation-type-actual")) && enumvalue >= 3 && enumvalue < (3 + (int)(sizeof(ipp_job_collation_types) / sizeof(ipp_job_collation_types[0])))) |
| 2108 | return (ipp_job_collation_types[enumvalue - 3]); |
| 2109 | else if (!strcmp(attrname, "job-state") && enumvalue >= IPP_JSTATE_PENDING && enumvalue <= IPP_JSTATE_COMPLETED) |
| 2110 | return (ipp_job_states[enumvalue - IPP_JSTATE_PENDING]); |
| 2111 | else if (!strcmp(attrname, "operations-supported")) |
| 2112 | return (ippOpString((ipp_op_t)enumvalue)); |
| 2113 | else if ((!strcmp(attrname, "orientation-requested") || !strcmp(attrname, "orientation-requested-actual") || !strcmp(attrname, "orientation-requested-default") || !strcmp(attrname, "orientation-requested-supported")) && enumvalue >= 3 && enumvalue < (3 + (int)(sizeof(ipp_orientation_requesteds) / sizeof(ipp_orientation_requesteds[0])))) |
| 2114 | return (ipp_orientation_requesteds[enumvalue - 3]); |
| 2115 | else if ((!strcmp(attrname, "print-quality") || !strcmp(attrname, "print-quality-actual") || !strcmp(attrname, "print-quality-default") || !strcmp(attrname, "print-quality-supported")) && enumvalue >= 3 && enumvalue < (3 + (int)(sizeof(ipp_print_qualities) / sizeof(ipp_print_qualities[0])))) |
| 2116 | return (ipp_print_qualities[enumvalue - 3]); |
| 2117 | else if (!strcmp(attrname, "printer-state") && enumvalue >= IPP_PSTATE_IDLE && enumvalue <= IPP_PSTATE_STOPPED) |
| 2118 | return (ipp_printer_states[enumvalue - IPP_PSTATE_IDLE]); |
| 2119 | else if (!strcmp(attrname, "resource-state") && enumvalue >= IPP_RSTATE_PENDING && enumvalue <= IPP_RSTATE_ABORTED) |
| 2120 | return (ipp_resource_states[enumvalue - IPP_RSTATE_PENDING]); |
| 2121 | else if (!strcmp(attrname, "system-state") && enumvalue >= IPP_SSTATE_IDLE && enumvalue <= IPP_SSTATE_STOPPED) |
| 2122 | return (ipp_system_states[enumvalue - IPP_SSTATE_IDLE]); |
| 2123 | |
| 2124 | /* |
| 2125 | * Not a standard enum value, just return the decimal equivalent... |
| 2126 | */ |
| 2127 | |
| 2128 | snprintf(cg->ipp_unknown, sizeof(cg->ipp_unknown), "%d", enumvalue); |
| 2129 | return (cg->ipp_unknown); |
| 2130 | } |
| 2131 | |
| 2132 | |
| 2133 | /* |