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

Function _cupsLangPrintFilter

cups/langprintf.c:91–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89 */
90
91int /* O - Number of bytes written */
92_cupsLangPrintFilter(
93 FILE *fp, /* I - File to write to */
94 const char *prefix, /* I - Non-localized message prefix */
95 const char *message, /* I - Message string to use */
96 ...) /* I - Additional arguments as needed */
97{
98 ssize_t bytes; /* Number of bytes formatted */
99 char temp[2048], /* Temporary format buffer */
100 buffer[2048], /* Message buffer */
101 output[8192]; /* Output buffer */
102 va_list ap; /* Pointer to additional arguments */
103 _cups_globals_t *cg; /* Global data */
104
105
106 /*
107 * Range check...
108 */
109
110 if (!fp || !message)
111 return (-1);
112
113 cg = _cupsGlobals();
114
115 if (!cg->lang_default)
116 cg->lang_default = cupsLangDefault();
117
118 /*
119 * Format the string...
120 */
121
122 va_start(ap, message);
123 snprintf(temp, sizeof(temp), "%s: %s\n", prefix,
124 _cupsLangString(cg->lang_default, message));
125 vsnprintf(buffer, sizeof(buffer), temp, ap);
126 va_end(ap);
127
128 /*
129 * Transcode to the destination charset...
130 */
131
132 bytes = cupsUTF8ToCharset(output, (cups_utf8_t *)buffer, sizeof(output),
133 cg->lang_default->encoding);
134
135 /*
136 * Write the string and return the number of bytes written...
137 */
138
139 if (bytes > 0)
140 return ((int)fwrite(output, 1, (size_t)bytes, fp));
141 else
142 return ((int)bytes);
143}
144
145
146/*

Callers 15

backendDrainOutputFunction · 0.85
backendRunLoopFunction · 0.85
backendLookupFunction · 0.85
mainFunction · 0.85
print_deviceFunction · 0.85
find_device_cbFunction · 0.85
status_timer_cbFunction · 0.85
parse_optionsFunction · 0.85
run_legacy_backendFunction · 0.85
print_deviceFunction · 0.85
mainFunction · 0.85
print_deviceFunction · 0.85

Calls 4

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

Tested by

no test coverage detected