]>
git.ipfire.org Git - thirdparty/cups.git/blob - cups/langprintf.c
a1f28b6a4c0cbcf078922bb138f2f56fc63dd0db
4 * Localized printf/puts functions for the Common UNIX Printing
7 * Copyright 2002-2006 by Easy Software Products.
9 * These coded instructions, statements, and computer programs are the
10 * property of Easy Software Products and are protected by Federal
11 * copyright law. Distribution and use rights are outlined in the file
12 * "LICENSE.txt" which should have been included with this file. If this
13 * file is missing or damaged please contact Easy Software Products
16 * Attn: CUPS Licensing Information
17 * Easy Software Products
18 * 44141 Airport View Drive, Suite 204
19 * Hollywood, Maryland 20636 USA
21 * Voice: (301) 373-9600
22 * EMail: cups-info@cups.org
23 * WWW: http://www.cups.org
25 * This file is subject to the Apple OS-Developed Software exception.
29 * _cupsLangPrintf() - Print a formatted message string to a file.
30 * _cupsLangPuts() - Print a static message string to a file.
34 * Include necessary headers...
42 * '_cupsLangPrintf()' - Print a formatted message string to a file.
45 int /* O - Number of bytes written */
46 _cupsLangPrintf(FILE *fp
, /* I - File to write to */
47 const char *message
, /* I - Message string to use */
48 ...) /* I - Additional arguments as needed */
50 int bytes
; /* Number of bytes formatted */
51 char buffer
[2048], /* Message buffer */
52 output
[8192]; /* Output buffer */
53 va_list ap
; /* Pointer to additional arguments */
54 _cups_globals_t
*cg
; /* Global data */
66 if (!cg
->lang_default
)
67 cg
->lang_default
= cupsLangDefault();
70 * Format the string...
73 va_start(ap
, message
);
74 bytes
= vsnprintf(buffer
, sizeof(buffer
),
75 _cupsLangString(cg
->lang_default
, message
), ap
);
79 * Transcode to the destination charset...
82 bytes
= cupsUTF8ToCharset(output
, (cups_utf8_t
*)buffer
, sizeof(output
),
83 cg
->lang_default
->encoding
);
86 * Write the string and return the number of bytes written...
90 return (fwrite(output
, 1, bytes
, fp
));
97 * '_cupsLangPuts()' - Print a static message string to a file.
100 int /* O - Number of bytes written */
101 _cupsLangPuts(FILE *fp
, /* I - File to write to */
102 const char *message
) /* I - Message string to use */
104 int bytes
; /* Number of bytes formatted */
105 char output
[2048]; /* Message buffer */
106 _cups_globals_t
*cg
; /* Global data */
118 if (!cg
->lang_default
)
119 cg
->lang_default
= cupsLangDefault();
122 * Transcode to the destination charset...
125 bytes
= cupsUTF8ToCharset(output
,
126 (cups_utf8_t
*)_cupsLangString(cg
->lang_default
,
128 sizeof(output
), cg
->lang_default
->encoding
);
131 * Write the string and return the number of bytes written...
135 return (fwrite(output
, 1, bytes
, fp
));