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

Function _cupsLangPrintError

cups/langprintf.c:23–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21 */
22
23void
24_cupsLangPrintError(const char *prefix, /* I - Non-localized message prefix */
25 const char *message)/* I - Message */
26{
27 ssize_t bytes; /* Number of bytes formatted */
28 int last_errno; /* Last error */
29 char buffer[2048], /* Message buffer */
30 *bufptr, /* Pointer into buffer */
31 output[8192]; /* Output buffer */
32 _cups_globals_t *cg; /* Global data */
33
34
35 /*
36 * Range check...
37 */
38
39 if (!message)
40 return;
41
42 /*
43 * Save the errno value...
44 */
45
46 last_errno = errno;
47
48 /*
49 * Get the message catalog...
50 */
51
52 cg = _cupsGlobals();
53
54 if (!cg->lang_default)
55 cg->lang_default = cupsLangDefault();
56
57 /*
58 * Format the message...
59 */
60
61 if (prefix)
62 {
63 snprintf(buffer, sizeof(buffer), "%s:", prefix);
64 bufptr = buffer + strlen(buffer);
65 }
66 else
67 bufptr = buffer;
68
69 snprintf(bufptr, sizeof(buffer) - (size_t)(bufptr - buffer),
70 /* TRANSLATORS: Message is "subject: error" */
71 _cupsLangString(cg->lang_default, _("%s: %s")),
72 _cupsLangString(cg->lang_default, message), strerror(last_errno));
73 strlcat(buffer, "\n", sizeof(buffer));
74
75 /*
76 * Convert and write to stderr...
77 */
78
79 bytes = cupsUTF8ToCharset(output, (cups_utf8_t *)buffer, sizeof(output),
80 cg->lang_default->encoding);

Callers 15

create_printerFunction · 0.85
get_job_fileFunction · 0.85
backendDrainOutputFunction · 0.85
backendRunLoopFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
print_deviceFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
add_pageFunction · 0.85
copy_bytesFunction · 0.85

Calls 4

_cupsGlobalsFunction · 0.85
cupsLangDefaultFunction · 0.85
_cupsLangStringFunction · 0.85
cupsUTF8ToCharsetFunction · 0.85

Tested by

no test coverage detected