2 Unix SMB/Netbios implementation.
4 display print functions
5 Copyright (C) Andrew Tridgell 2001
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 this module provides functions for printing internal strings in the "display charset"
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
35 int d_vfprintf(FILE *f, const char *format, va_list ap)
38 int ret, maxlen, clen;
41 /* do any message translations */
42 msgstr = lang_msg(format);
43 if (!msgstr) return -1;
45 ret = vasprintf(&p, msgstr, ap);
47 lang_msg_free(msgstr);
49 if (ret <= 0) return ret;
51 /* now we have the string in unix format, convert it to the display
52 charset, but beware of it growing */
60 clen = convert_string(CH_UNIX, CH_DISPLAY, p, ret, p2, maxlen);
63 /* it didn't fit - try a larger buffer */
69 /* good, its converted OK */
71 ret = fwrite(p2, 1, clen, f);
78 int d_fprintf(FILE *f, const char *format, ...)
84 ret = d_vfprintf(f, format, ap);
92 int d_printf(const char *format, ...)
97 if (!outfile) outfile = stdout;
100 ret = d_vfprintf(outfile, format, ap);
106 /* interactive programs need a way of tell d_*() to write to stderr instead
108 void display_set_stderr(void)