2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $TOG: PrintMsgs.c /main/14 1999/10/14 13:54:53 mgreess $ */
28 * (c) Copyright 1996 Digital Equipment Corporation.
29 * (c) Copyright 1996 Hewlett-Packard Company.
30 * (c) Copyright 1996 International Business Machines Corp.
31 * (c) Copyright 1996 Sun Microsystems, Inc.
32 * (c) Copyright 1996 Novell, Inc.
33 * (c) Copyright 1996 FUJITSU LIMITED.
34 * (c) Copyright 1996 Hitachi.
41 #include <X11/Intrinsic.h>
42 #include <Dt/PrintI.h>
44 #if !defined(NL_CAT_LOCALE)
45 #define NL_CAT_LOCALE 0
48 #define _DTPRINT_CAT_NAME "DtPrint"
53 * ------------------------------------------------------------------------
54 * PrintSetupB module messages
56 const char _DtPrMsgPrintSetupBox_0000[] =
57 "Invalid workAreaLocation resource setting.";
58 const char _DtPrMsgPrintSetupBox_0001[] =
60 const char _DtPrMsgPrintSetupBox_0002[] =
62 const char _DtPrMsgPrintSetupBox_0003[] =
64 const char _DtPrMsgPrintSetupBox_0004[] =
66 const char _DtPrMsgPrintSetupBox_0005[] =
68 const char _DtPrMsgPrintSetupBox_0006[] =
70 const char _DtPrMsgPrintSetupBox_0007[] =
72 const char _DtPrMsgPrintSetupBox_0008[] =
74 const char _DtPrMsgPrintSetupBox_0009[] =
76 const char _DtPrMsgPrintSetupBox_0010[] =
77 "Printer Description:";
78 const char _DtPrMsgPrintSetupBox_0011[] =
79 "Copy count out of range.";
80 const char _DtPrMsgPrintSetupBox_0012[] =
81 "Invalid print setup mode.";
82 const char _DtPrMsgPrintSetupBox_0013[] =
83 "Print setup mode cannot be changed.";
84 const char _DtPrMsgPrintSetupBox_0014[] =
86 const char _DtPrMsgPrintSetupBox_0015[] =
88 const char _DtPrMsgPrintSetupBox_0016[] =
89 "Printer %s not found on X print server %s";
90 const char _DtPrMsgPrintSetupBox_0017[] =
91 "Unable to connect to X print server %s";
92 const char _DtPrMsgPrintSetupBox_0018[] =
93 "X server %s does not support printing";
94 const char _DtPrMsgPrintSetupBox_0019[] =
95 "A default printer could not be determined";
96 const char _DtPrMsgPrintSetupBox_0020[] =
97 "An X print server for %s could not be found";
98 const char _DtPrMsgPrintSetupBox_0021[] =
99 "Printer name missing from specifier: %s";
100 const char _DtPrMsgPrintSetupBox_0022[] =
101 "Invalid print destination.";
102 const char _DtPrMsgPrintSetupBox_0023[] =
103 "Unable to convert from compound text.";
104 const char _DtPrMsgPrintSetupBox_0024[] =
105 "Arguments not needed for resource conversion.";
106 const char _DtPrMsgPrintSetupBox_0025[] =
107 "Select Printer Error";
108 const char _DtPrMsgPrintSetupBox_0026[] =
109 "Unable to find any printers.";
110 const char _DtPrMsgPrintSetupBox_0027[] =
111 "description unavailable";
112 const char _DtPrMsgPrintSetupBox_0028[] =
114 const char _DtPrMsgPrintSetupBox_0029[] =
115 "Printer Information";
116 const char _DtPrMsgPrintSetupBox_0030[] =
118 const char _DtPrMsgPrintSetupBox_0031[] =
120 const char _DtPrMsgPrintSetupBox_0032[] =
122 const char _DtPrMsgPrintSetupBox_0033[] =
124 const char _DtPrMsgPrintSetupBox_0034[] =
126 const char _DtPrMsgPrintSetupBox_0035[] =
128 const char _DtPrMsgPrintSetupBox_0036[] =
129 "Print Setup - Help";
134 * ------------------------------------------------------------------------
135 * _DtPrint Frame widget messages
137 const char _DtPrMsgPrintOption_0000[] = "Margins";
138 const char _DtPrMsgPrintOption_0001[] = "Top:";
139 const char _DtPrMsgPrintOption_0002[] = "Right:";
140 const char _DtPrMsgPrintOption_0003[] = "Bottom:";
141 const char _DtPrMsgPrintOption_0004[] = "Left:";
143 const char _DtPrMsgPrintOption_0005[] = "Headers and Footers";
144 const char _DtPrMsgPrintOption_0006[] = "Top Left:";
145 const char _DtPrMsgPrintOption_0007[] = "Top Right:";
146 const char _DtPrMsgPrintOption_0008[] = "Bottom Left:";
147 const char _DtPrMsgPrintOption_0009[] = "Bottom Right:";
150 * ------------------------------------------------------------------------
151 * Dt Print Dialog Manager module messages
153 const char _DtPrMsgPrintDlgMgr_0000[] = "Send Mail When Done";
154 const char _DtPrMsgPrintDlgMgr_0001[] = "Banner Page Title:";
155 const char _DtPrMsgPrintDlgMgr_0002[] = "Print Command Options:";
157 #if defined(I18N_MSG)
161 * Wrapper around catgets -- this makes sure the message string is saved
162 * in a safe location; so repeated calls to catgets() do not overwrite
163 * the catgets() internal buffer. This has been a problem on HP systems.
165 static char *catgets_cached(nl_catd catd, int set, int num, char *dflt)
167 #define INITIAL_NMSGS_PER_SET 300
168 #define INITIAL_NSETS 50
170 /* array to hold messages from catalog */
171 static char ***cached_msgs = NULL;
172 static int nmsgs_per_set = INITIAL_NMSGS_PER_SET;
173 static int nsets = INITIAL_NSETS;
181 /* convert to a zero based index */
182 int setIdx = set - 1;
183 int numIdx = num - 1;
185 _DtPrintProcessLock();
187 if (NULL == cached_msgs)
189 size = sizeof(char**) * nsets;
190 cached_msgs = (char***) XtMalloc(size);
191 memset((char*) cached_msgs, 0, size);
193 else if (setIdx >= nsets)
195 for (multiplier=2; setIdx > multiplier*nsets; multiplier++) {}
196 size = sizeof(char**) * nsets;
197 cached_msgs = (char***) XtRealloc((char*) cached_msgs, multiplier * size);
198 memset((char*) (cached_msgs + size), 0, multiplier * size);
202 if (NULL == cached_msgs[setIdx])
204 size = sizeof(char*) * nmsgs_per_set;
205 cached_msgs[setIdx] = (char**) XtMalloc(size);
206 memset((char*) cached_msgs[setIdx], 0, size);
208 else if (numIdx >= nmsgs_per_set)
210 for (multiplier=2; numIdx > multiplier*nsets; multiplier++) {}
211 size = sizeof(char*) * nmsgs_per_set;
213 for (i=0; i<nmsgs_per_set; i++)
215 if (NULL != cached_msgs[i])
218 (char**) XtRealloc((char*) cached_msgs[i], multiplier * size);
219 memset((char*) (cached_msgs[i] + size), 0, multiplier * size);
222 nmsgs_per_set *= multiplier;
225 setptr = cached_msgs[setIdx];
226 if (NULL == setptr[numIdx])
227 setptr[numIdx] = strdup(catgets(catd, set, num, dflt));
229 message = setptr[numIdx];
231 _DtPrintProcessUnlock();
239 * ------------------------------------------------------------------------
240 * Name: _DtPrintGetMessage
244 * int set - The message catalog set number.
246 * int n - The message number.
248 * char *s - The default message if the message is not
249 * retrieved from a message catalog.
251 * Returns: the string for set 'set' and number 'n'.
262 static int first = 1;
263 static nl_catd nlmsg_fd;
267 _DtPrintProcessLock();
271 nlmsg_fd = catopen(_DTPRINT_CAT_NAME, NL_CAT_LOCALE);
273 _DtPrintProcessUnlock();
276 msg=catgets_cached(nlmsg_fd,set,n,s);
278 msg=catgets(nlmsg_fd,set,n,s);
283 #endif /* I18N_MSG */