| 1083 | */ |
| 1084 | |
| 1085 | void |
| 1086 | _cupsSetError(ipp_status_t status, /* I - IPP status code */ |
| 1087 | const char *message, /* I - status-message value */ |
| 1088 | int localize) /* I - Localize the message? */ |
| 1089 | { |
| 1090 | _cups_globals_t *cg; /* Global data */ |
| 1091 | |
| 1092 | |
| 1093 | if (!message && errno) |
| 1094 | { |
| 1095 | message = strerror(errno); |
| 1096 | localize = 0; |
| 1097 | } |
| 1098 | |
| 1099 | cg = _cupsGlobals(); |
| 1100 | cg->last_error = status; |
| 1101 | |
| 1102 | if (cg->last_status_message) |
| 1103 | { |
| 1104 | _cupsStrFree(cg->last_status_message); |
| 1105 | |
| 1106 | cg->last_status_message = NULL; |
| 1107 | } |
| 1108 | |
| 1109 | if (message) |
| 1110 | { |
| 1111 | if (localize) |
| 1112 | { |
| 1113 | /* |
| 1114 | * Get the message catalog... |
| 1115 | */ |
| 1116 | |
| 1117 | if (!cg->lang_default) |
| 1118 | cg->lang_default = cupsLangDefault(); |
| 1119 | |
| 1120 | cg->last_status_message = _cupsStrAlloc(_cupsLangString(cg->lang_default, |
| 1121 | message)); |
| 1122 | } |
| 1123 | else |
| 1124 | cg->last_status_message = _cupsStrAlloc(message); |
| 1125 | } |
| 1126 | |
| 1127 | DEBUG_printf(("4_cupsSetError: last_error=%s, last_status_message=\"%s\"", |
| 1128 | ippErrorString(cg->last_error), cg->last_status_message)); |
| 1129 | } |
| 1130 | |
| 1131 | |
| 1132 | /* |
no test coverage detected