2 Unix SMB/CIFS implementation.
3 display print functions
4 Copyright (C) Andrew Tridgell 2001
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 this module provides functions for printing internal strings in the
25 This charset may be quite different from the chosen unix charset.
27 Eventually these functions will need to take care of column count constraints
29 The d_ prefix on print functions in Samba refers to the display character set
34 #include "system/locale.h"
36 _PUBLIC_ int d_vfprintf(FILE *f, const char *format, va_list ap) _PRINTF_ATTRIBUTE(2,0)
39 int ret, maxlen, clen;
42 /* do any message translations */
44 ret = vasprintf(&p, format, ap2);
47 if (ret <= 0) return ret;
49 /* now we have the string in unix format, convert it to the display
50 charset, but beware of it growing */
53 p2 = (char *)malloc(maxlen);
58 clen = convert_string(global_smb_iconv_convenience, CH_UNIX, CH_DISPLAY, p, ret, p2, maxlen);
60 /* the string can't be converted - do the best we can,
61 filling in non-printing chars with '?' */
64 if (isprint(p[i]) || isspace(p[i])) {
77 /* it didn't fit - try a larger buffer */
83 /* good, its converted OK */
85 ret = fwrite(p2, 1, clen, f);
92 _PUBLIC_ int d_fprintf(FILE *f, const char *format, ...) _PRINTF_ATTRIBUTE(2,3)
98 ret = d_vfprintf(f, format, ap);
104 _PUBLIC_ int d_printf(const char *format, ...) _PRINTF_ATTRIBUTE(1,2)
109 va_start(ap, format);
110 ret = d_vfprintf(stdout, format, ap);