| 89 | */ |
| 90 | |
| 91 | int /* 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 | /* |
no test coverage detected