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

Function ppdLocalizeIPPReason

cups/ppd-localize.c:225–422  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

223 */
224
225const char * /* O - Value or NULL if not found */
226ppdLocalizeIPPReason(
227 ppd_file_t *ppd, /* I - PPD file */
228 const char *reason, /* I - IPP reason keyword to look up */
229 const char *scheme, /* I - URI scheme or NULL for text */
230 char *buffer, /* I - Value buffer */
231 size_t bufsize) /* I - Size of value buffer */
232{
233 cups_lang_t *lang; /* Current language */
234 ppd_attr_t *locattr; /* Localized attribute */
235 char ll_CC[6], /* Language + country locale */
236 *bufptr, /* Pointer into buffer */
237 *bufend, /* Pointer to end of buffer */
238 *valptr; /* Pointer into value */
239 int ch; /* Hex-encoded character */
240 size_t schemelen; /* Length of scheme name */
241
242
243 /*
244 * Range check input...
245 */
246
247 if (buffer)
248 *buffer = '\0';
249
250 if (!ppd || !reason || (scheme && !*scheme) ||
251 !buffer || bufsize < PPD_MAX_TEXT)
252 return (NULL);
253
254 /*
255 * Get the default language...
256 */
257
258 lang = ppd_ll_CC(ll_CC, sizeof(ll_CC));
259
260 /*
261 * Find the localized attribute...
262 */
263
264 if ((locattr = _ppdLocalizedAttr(ppd, "cupsIPPReason", reason,
265 ll_CC)) == NULL)
266 locattr = ppdFindAttr(ppd, "cupsIPPReason", reason);
267
268 if (!locattr)
269 {
270 if (lang && (!scheme || !strcmp(scheme, "text")) && strcmp(reason, "none"))
271 {
272 /*
273 * Try to localize a standard printer-state-reason keyword...
274 */
275
276 char msgid[1024], /* State message identifier */
277 *ptr; /* Pointer to state suffix */
278 const char *message = NULL; /* Localized message */
279
280 snprintf(msgid, sizeof(msgid), "printer-state-reasons.%s", reason);
281 if ((ptr = strrchr(msgid, '-')) != NULL && (!strcmp(ptr, "-error") || !strcmp(ptr, "-report") || !strcmp(ptr, "-warning")))
282 *ptr = '\0';

Callers 2

mainFunction · 0.85
show_ppdFunction · 0.85

Calls 5

ppd_ll_CCFunction · 0.85
_ppdLocalizedAttrFunction · 0.85
ppdFindAttrFunction · 0.85
_cupsLangStringFunction · 0.85
_cups_isspaceFunction · 0.85

Tested by 2

mainFunction · 0.68
show_ppdFunction · 0.68