1 /* $TOG: PrintMsgs.c /main/14 1999/10/14 13:54:53 mgreess $ */
6 * (c) Copyright 1996 Digital Equipment Corporation.
7 * (c) Copyright 1996 Hewlett-Packard Company.
8 * (c) Copyright 1996 International Business Machines Corp.
9 * (c) Copyright 1996 Sun Microsystems, Inc.
10 * (c) Copyright 1996 Novell, Inc.
11 * (c) Copyright 1996 FUJITSU LIMITED.
12 * (c) Copyright 1996 Hitachi.
19 #include <X11/Intrinsic.h>
20 #include <Dt/PrintI.h>
22 #if !defined(NL_CAT_LOCALE)
23 #define NL_CAT_LOCALE 0
26 #define _DTPRINT_CAT_NAME "DtPrint"
31 * ------------------------------------------------------------------------
32 * PrintSetupB module messages
34 const char _DtPrMsgPrintSetupBox_0000[] =
35 "Invalid workAreaLocation resource setting.";
36 const char _DtPrMsgPrintSetupBox_0001[] =
38 const char _DtPrMsgPrintSetupBox_0002[] =
40 const char _DtPrMsgPrintSetupBox_0003[] =
42 const char _DtPrMsgPrintSetupBox_0004[] =
44 const char _DtPrMsgPrintSetupBox_0005[] =
46 const char _DtPrMsgPrintSetupBox_0006[] =
48 const char _DtPrMsgPrintSetupBox_0007[] =
50 const char _DtPrMsgPrintSetupBox_0008[] =
52 const char _DtPrMsgPrintSetupBox_0009[] =
54 const char _DtPrMsgPrintSetupBox_0010[] =
55 "Printer Description:";
56 const char _DtPrMsgPrintSetupBox_0011[] =
57 "Copy count out of range.";
58 const char _DtPrMsgPrintSetupBox_0012[] =
59 "Invalid print setup mode.";
60 const char _DtPrMsgPrintSetupBox_0013[] =
61 "Print setup mode cannot be changed.";
62 const char _DtPrMsgPrintSetupBox_0014[] =
64 const char _DtPrMsgPrintSetupBox_0015[] =
66 const char _DtPrMsgPrintSetupBox_0016[] =
67 "Printer %s not found on X print server %s";
68 const char _DtPrMsgPrintSetupBox_0017[] =
69 "Unable to connect to X print server %s";
70 const char _DtPrMsgPrintSetupBox_0018[] =
71 "X server %s does not support printing";
72 const char _DtPrMsgPrintSetupBox_0019[] =
73 "A default printer could not be determined";
74 const char _DtPrMsgPrintSetupBox_0020[] =
75 "An X print server for %s could not be found";
76 const char _DtPrMsgPrintSetupBox_0021[] =
77 "Printer name missing from specifier: %s";
78 const char _DtPrMsgPrintSetupBox_0022[] =
79 "Invalid print destination.";
80 const char _DtPrMsgPrintSetupBox_0023[] =
81 "Unable to convert from compound text.";
82 const char _DtPrMsgPrintSetupBox_0024[] =
83 "Arguments not needed for resource conversion.";
84 const char _DtPrMsgPrintSetupBox_0025[] =
85 "Select Printer Error";
86 const char _DtPrMsgPrintSetupBox_0026[] =
87 "Unable to find any printers.";
88 const char _DtPrMsgPrintSetupBox_0027[] =
89 "description unavailable";
90 const char _DtPrMsgPrintSetupBox_0028[] =
92 const char _DtPrMsgPrintSetupBox_0029[] =
93 "Printer Information";
94 const char _DtPrMsgPrintSetupBox_0030[] =
96 const char _DtPrMsgPrintSetupBox_0031[] =
98 const char _DtPrMsgPrintSetupBox_0032[] =
100 const char _DtPrMsgPrintSetupBox_0033[] =
102 const char _DtPrMsgPrintSetupBox_0034[] =
104 const char _DtPrMsgPrintSetupBox_0035[] =
106 const char _DtPrMsgPrintSetupBox_0036[] =
107 "Print Setup - Help";
112 * ------------------------------------------------------------------------
113 * _DtPrint Frame widget messages
115 const char _DtPrMsgPrintOption_0000[] = "Margins";
116 const char _DtPrMsgPrintOption_0001[] = "Top:";
117 const char _DtPrMsgPrintOption_0002[] = "Right:";
118 const char _DtPrMsgPrintOption_0003[] = "Bottom:";
119 const char _DtPrMsgPrintOption_0004[] = "Left:";
121 const char _DtPrMsgPrintOption_0005[] = "Headers and Footers";
122 const char _DtPrMsgPrintOption_0006[] = "Top Left:";
123 const char _DtPrMsgPrintOption_0007[] = "Top Right:";
124 const char _DtPrMsgPrintOption_0008[] = "Bottom Left:";
125 const char _DtPrMsgPrintOption_0009[] = "Bottom Right:";
128 * ------------------------------------------------------------------------
129 * Dt Print Dialog Manager module messages
131 const char _DtPrMsgPrintDlgMgr_0000[] = "Send Mail When Done";
132 const char _DtPrMsgPrintDlgMgr_0001[] = "Banner Page Title:";
133 const char _DtPrMsgPrintDlgMgr_0002[] = "Print Command Options:";
135 #if defined(I18N_MSG)
139 * Wrapper around catgets -- this makes sure the message string is saved
140 * in a safe location; so repeated calls to catgets() do not overwrite
141 * the catgets() internal buffer. This has been a problem on HP systems.
143 static char *catgets_cached(nl_catd catd, int set, int num, char *dflt)
145 #define INITIAL_NMSGS_PER_SET 300
146 #define INITIAL_NSETS 50
148 /* array to hold messages from catalog */
149 static char ***cached_msgs = NULL;
150 static int nmsgs_per_set = INITIAL_NMSGS_PER_SET;
151 static int nsets = INITIAL_NSETS;
159 /* convert to a zero based index */
160 int setIdx = set - 1;
161 int numIdx = num - 1;
163 _DtPrintProcessLock();
165 if (NULL == cached_msgs)
167 size = sizeof(char**) * nsets;
168 cached_msgs = (char***) XtMalloc(size);
169 memset((char*) cached_msgs, 0, size);
171 else if (setIdx >= nsets)
173 for (multiplier=2; setIdx > multiplier*nsets; multiplier++) {}
174 size = sizeof(char**) * nsets;
175 cached_msgs = (char***) XtRealloc((char*) cached_msgs, multiplier * size);
176 memset((char*) (cached_msgs + size), 0, multiplier * size);
180 if (NULL == cached_msgs[setIdx])
182 size = sizeof(char*) * nmsgs_per_set;
183 cached_msgs[setIdx] = (char**) XtMalloc(size);
184 memset((char*) cached_msgs[setIdx], 0, size);
186 else if (numIdx >= nmsgs_per_set)
188 for (multiplier=2; numIdx > multiplier*nsets; multiplier++) {}
189 size = sizeof(char*) * nmsgs_per_set;
191 for (i=0; i<nmsgs_per_set; i++)
193 if (NULL != cached_msgs[i])
196 (char**) XtRealloc((char*) cached_msgs[i], multiplier * size);
197 memset((char*) (cached_msgs[i] + size), 0, multiplier * size);
200 nmsgs_per_set *= multiplier;
203 setptr = cached_msgs[setIdx];
204 if (NULL == setptr[numIdx])
205 setptr[numIdx] = strdup(catgets(catd, set, num, dflt));
207 message = setptr[numIdx];
209 _DtPrintProcessUnlock();
217 * ------------------------------------------------------------------------
218 * Name: _DtPrintGetMessage
222 * int set - The message catalog set number.
224 * int n - The message number.
226 * char *s - The default message if the message is not
227 * retrieved from a message catalog.
229 * Returns: the string for set 'set' and number 'n'.
240 static int first = 1;
241 static nl_catd nlmsg_fd;
245 _DtPrintProcessLock();
249 nlmsg_fd = catopen(_DTPRINT_CAT_NAME, NL_CAT_LOCALE);
251 _DtPrintProcessUnlock();
254 msg=catgets_cached(nlmsg_fd,set,n,s);
256 msg=catgets(nlmsg_fd,set,n,s);
261 #endif /* I18N_MSG */