summaryrefslogtreecommitdiff
path: root/print/ghostscript-gpl/files/patch-contrib__pcl3__src__gdevpcl3.c
blob: dd8e850bf6e0c76db925c8246363a5dd2e5888f8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
--- contrib/pcl3/src/gdevpcl3.c.orig	Thu Apr 26 01:27:24 2007
+++ contrib/pcl3/src/gdevpcl3.c	Tue May 15 01:48:00 2007
@@ -338,7 +338,7 @@
   /* First we construct a properly NUL-terminated string */
   s = (char *) malloc(in_value->size + 1);
   if (s == NULL) {
-    fprintf(stderr, ERRPREF
+    eprintf1(ERRPREF
       "Memory allocation failure in get_int_for_string(): %s.\n",
       strerror(errno));
     return_error(gs_error_VMerror);
@@ -434,25 +434,25 @@
   const char *epref = eprn->CUPS_messages? CUPS_ERRPREF: "";
 
   if (eprn->desired_flags == 0) {
-    fprintf(stderr,
+    eprintf2(
       "%s" ERRPREF "The %s does not support the requested media properties.\n",
       epref, eprn->cap->name);
   }
   else if (eprn->desired_flags == MS_BIG_FLAG) {
-    fprintf(stderr, "%s" ERRPREF "The %s does not support banner printing",
+    eprintf2("%s" ERRPREF "The %s does not support banner printing",
       epref, eprn->cap->name);
-    if (!no_match) fputs(" for this size", stderr);
-    fputs(".\n", stderr);
+    if (!no_match) eprintf(" for this size");
+    eprintf(".\n");
   }
   else if (eprn->desired_flags == PCL_CARD_FLAG) {
-    fprintf(stderr, "%s" ERRPREF
+    eprintf2("%s" ERRPREF
       "The %s does not support a `Card' variant for ",
       epref, eprn->cap->name);
-    if (no_match) fputs("any", stderr); else fputs("this", stderr);
-    fputs(" size.\n", stderr);
+    if (no_match) eprintf("any"); else eprintf("this");
+    eprintf(" size.\n");
   }
   else {
-    fprintf(stderr,
+    eprintf1(
       "%s" ERRPREF "Banner printing on postcards?? You must be joking!\n",
       epref);
   }
@@ -699,8 +699,8 @@
   be copied to '*s'.
 
   The function returns a negative ghostscript error code on error and zero
-  otherwise. In the former case an error message will have been issued on
-  stderr, using 'epref' as a prefix for the message.
+  otherwise. In the former case an error message will have been issued, 
+  using 'epref' as a prefix for the message.
 
 ******************************************************************************/
 
@@ -728,7 +728,7 @@
 
     if (s->str == NULL) {
       s->length = 0;
-      fprintf(stderr, "%s" ERRPREF
+      eprintf1("%s" ERRPREF
 	"Memory allocation failure from gs_malloc().\n", epref);
       rc = gs_error_VMerror;
       param_signal_error(plist, pname, rc);
@@ -760,8 +760,7 @@
   copied.
 
   The function returns a negative ghostscript error code on error and zero
-  otherwise. In the former case an error message will have been issued on
-  stderr.
+  otherwise. In the former case an error message will have been issued.
 
 ******************************************************************************/
 
@@ -785,7 +784,7 @@
       "fetch_cstring");
 
     if (*s == NULL) {
-      fprintf(stderr, "%s" ERRPREF
+      eprintf1("%s" ERRPREF
 	"Memory allocation failure from gs_malloc().\n", epref);
       rc = gs_error_VMerror;
       param_signal_error(plist, pname, rc);
@@ -907,9 +906,9 @@
 	eprn_init_device((eprn_Device *)dev, &pcl3_printers[dev->printer].desc);
       }
       else {
-	fprintf(stderr, "%s" ERRPREF "Unknown subdevice name: `", epref);
-	fwrite(string_value.data, sizeof(char), string_value.size, stderr);
-	fputs("'.\n", stderr);
+	eprintf1("%s" ERRPREF "Unknown subdevice name: `", epref);
+	errwrite(string_value.data, sizeof(char)*string_value.size);
+	eprintf("'.\n");
 	last_error = gs_error_rangecheck;
 	param_signal_error(plist, pname, last_error);
       }
@@ -925,8 +924,8 @@
       == 0) {
     if (temp != pcl_cm_none && temp != pcl_cm_rl && temp != pcl_cm_tiff &&
 	temp != pcl_cm_delta && temp != pcl_cm_crdr) {
-      fprintf(stderr,
-	"%s" ERRPREF "Unsupported compression method: %d.\n", epref, temp);
+      eprintf2("%s" ERRPREF "Unsupported compression method: %d.\n",
+	epref, temp);
       last_error = gs_error_rangecheck;
       param_signal_error(plist, pname, last_error);
     }
@@ -934,7 +933,7 @@
       if (temp == pcl_cm_crdr && (dev->printer == HPDeskJet ||
 	  dev->printer == HPDeskJetPlus || dev->printer == HPDJ500)) {
 	/* This I know to be the case for the DJ 500. The others are guessed. */
-	fprintf(stderr,
+	eprintf2(
 	  "%s" ERRPREF "The %s does not support compression method 9.\n",
 	  epref, dev->eprn.cap->name);
 	last_error = gs_error_rangecheck;
@@ -956,7 +955,7 @@
     if (1 <= temp && temp <= 5 && (dev->printer != HPDJ500C || temp <= 3))
       requested.depletion = temp;
     else {
-      fprintf(stderr, "%s" ERRPREF "Invalid value for depletion: %d.\n",
+      eprintf2("%s" ERRPREF "Invalid value for depletion: %d.\n",
 	epref, temp);
       last_error = gs_error_rangecheck;
       param_signal_error(plist, pname, last_error);
@@ -978,7 +977,7 @@
 	    Hence I'm giving an error message only in those cases where HP
 	    explicitly states that the printer does not support the command.
 	  */
-	fprintf(stderr,
+	eprintf2(
 	  "%s" ERRPREF "The %s does not support setting a dry time.\n",
 	  epref, dev->eprn.cap->name);
 	last_error = gs_error_rangecheck;
@@ -987,8 +986,8 @@
       else data->dry_time = temp;
     }
     else {
-      fprintf(stderr,
-	"%s" ERRPREF "Invalid value for the dry time: %d.\n", epref, temp);
+      eprintf2("%s" ERRPREF "Invalid value for the dry time: %d.\n",
+	epref, temp);
       last_error = gs_error_rangecheck;
       param_signal_error(plist, pname, last_error);
     }
@@ -1008,7 +1007,7 @@
 	    dev->Duplex_set = 0;	/* force to "null" */
 	}
 	else {
-	  fprintf(stderr, "%s" ERRPREF
+	  eprintf2("%s" ERRPREF
 	    "You can use a non-trivial value for DuplexCapability\n"
 	    "%s  only for unspec and unspecold.\n", epref, epref);
 	  last_error = gs_error_rangecheck;
@@ -1016,9 +1015,9 @@
 	}
       }
       else {
-	fprintf(stderr, "%s" ERRPREF "Invalid duplex capability: `", epref);
-	fwrite(string_value.data, sizeof(char), string_value.size, stderr);
-	fputs("'.\n", stderr);
+	eprintf1("%s" ERRPREF "Invalid duplex capability: `", epref);
+	errwrite(string_value.data, sizeof(char)*string_value.size);
+	eprintf("'.\n");
 	last_error = gs_error_rangecheck;
 	param_signal_error(plist, pname, last_error);
       }
@@ -1037,12 +1036,12 @@
     if ((rc = param_read_bool(plist, (pname = "Duplex"), &temp)) == 0 &&
 	temp && dev->duplex_capability == Duplex_none) {
       if (dev->printer == pcl3_generic_new || dev->printer == pcl3_generic_old)
-	fprintf(stderr, "%s" ERRPREF
+	eprintf3("%s" ERRPREF
           "The '%s' device does not support duplex printing unless\n"
 	  "%s  'DuplexCapability' is not 'none'.\n",
 	  epref, find_subdevice_name(dev->printer), epref);
       else
-	fprintf(stderr, "%s" ERRPREF
+	eprintf2("%s" ERRPREF
 	  "The %s does not support duplex printing.\n",
 	  epref, dev->eprn.cap->name);
       last_error = gs_error_rangecheck;
@@ -1071,9 +1070,9 @@
     rc = get_int_for_string(&string_value, media_type_list, &temp);
     if (rc != 0) {
       if (rc != gs_error_VMerror) {
-	fprintf(stderr, "%s" ERRPREF "Unknown medium: `", epref);
-	fwrite(string_value.data, sizeof(char), string_value.size, stderr);
-	fputs("'.\n", stderr);
+	eprintf1("%s" ERRPREF "Unknown medium: `", epref);
+	errwrite(string_value.data, sizeof(char)*string_value.size);
+	eprintf("'.\n");
       }
       last_error = rc;
       param_signal_error(plist, pname, last_error);
@@ -1081,7 +1080,7 @@
     else {
       new_quality = true;
       if (temp < 0 || 6 < temp)
-	fprintf(stderr, "%s" WARNPREF "Unknown media type code: %d.\n",
+	eprintf2("%s" WARNPREF "Unknown media type code: %d.\n",
 	  wpref, temp);
       pcl3_set_mediatype(data, temp);
     }
@@ -1107,7 +1106,7 @@
       if (pcl_has_CRD(data->level))
 	data->level = (temp? pcl_level_3plus_CRD_only: pcl_level_3plus_S68);
       else if (temp == true) {
-	fprintf(stderr, "%s" ERRPREF
+	eprintf1("%s" ERRPREF
 	  "OnlyCRD may be set only for group-3 devices.\n", epref);
 	last_error = gs_error_rangecheck;
 	param_signal_error(plist, pname, last_error);
@@ -1140,9 +1139,9 @@
     rc = get_int_for_string(&string_value, print_quality_list, &temp);
     if (rc != 0) {
       if (rc != gs_error_VMerror) {
-	fprintf(stderr, "%s" ERRPREF "Unknown print quality: `", epref);
-	fwrite(string_value.data, sizeof(char), string_value.size, stderr);
-	fputs("'.\n", stderr);
+	eprintf1("%s" ERRPREF "Unknown print quality: `", epref);
+	errwrite(string_value.data, sizeof(char)*string_value.size);
+	eprintf("'.\n");
       }
       last_error = rc;
       param_signal_error(plist, pname, last_error);
@@ -1150,7 +1149,7 @@
     else {
       new_quality = true;
       if (temp < -1 || 1 < temp)
-	fprintf(stderr, "%s" WARNPREF "Unknown print quality: %d.\n",
+	eprintf2("%s" WARNPREF "Unknown print quality: %d.\n",
 	  wpref, temp);
       pcl3_set_printquality(data, temp);
     }
@@ -1165,7 +1164,7 @@
 	== 0) {
     if (0 <= temp && temp <= 2) requested.quality = temp;
     else {
-      fprintf(stderr,
+      eprintf2(
 	"%s" ERRPREF "Invalid value for raster graphics quality: %d.\n",
 	epref, temp);
       last_error = gs_error_rangecheck;
@@ -1186,7 +1185,7 @@
   if ((rc = param_read_int(plist, (pname = "SendNULs"), &temp)) == 0) {
     if (data->NULs_to_send >= 0) data->NULs_to_send = temp;
     else {
-      fprintf(stderr,
+      eprintf2(
 	"%s" ERRPREF "Invalid value for SendNULs parameter: %d.\n",
 	epref, temp);
       last_error = gs_error_rangecheck;
@@ -1202,7 +1201,7 @@
       (rc = param_read_int(plist, pname, &temp)) == 0) {
     if (0 <= temp && temp <= 2) requested.shingling = temp;
     else {
-      fprintf(stderr, "%s" ERRPREF "Invalid value for shingling: %d.\n",
+      eprintf2("%s" ERRPREF "Invalid value for shingling: %d.\n",
 	epref, temp);
       last_error = gs_error_rangecheck;
       param_signal_error(plist, pname, last_error);
@@ -1280,7 +1279,7 @@
   /* Check on rendering parameters */
   if ((dev->eprn.black_levels > 2 || dev->eprn.non_black_levels > 2) &&
       dev->file_data.print_quality == -1)
-    fprintf(stderr,
+    eprintf2(
       "%s" WARNPREF "More than 2 intensity levels and draft quality\n"
       "%s    are unlikely to work in combination.\n", wpref, wpref);
 
@@ -1311,18 +1310,18 @@
       */
       char buffer[50];
 
-      fprintf(stderr, "%s" ERRPREF
+      eprintf2("%s" ERRPREF
 	"The current configuration for this driver has identified the\n"
 	"%s  page setup requested by the document as being for `",
 	epref, epref);
       if (ms_find_name_from_code(buffer, sizeof(buffer),
-	  dev->eprn.code, flag_description) == 0) fputs(buffer, stderr);
-      else fputs("UNKNOWN", stderr);	/* should never happen */
-      fprintf(stderr, "' (%.0f x %.0f bp).\n"
+	  dev->eprn.code, flag_description) == 0) eprintf(buffer);
+      else eprintf("UNKNOWN");	/* should never happen */
+      eprintf3("' (%.0f x %.0f bp).\n"
 	"%s  The driver does not know how to do this in PCL.\n",
 	dev->MediaSize[0], dev->MediaSize[1], epref);
       if (dev->eprn.media_file != NULL)
-	fprintf(stderr,
+	eprintf2(
 	  "%s  You should therefore not include such an entry in the\n"
 	  "%s  media configuration file.\n", epref, epref);
       return_error(gs_error_rangecheck);
@@ -1473,7 +1472,7 @@
       pcl_cm_is_differential(dev->file_data.compression) &&
 	rd.previous == NULL) {
     free(lengths); free(rd.next); free(rd.previous);
-    fprintf(stderr, "%s" ERRPREF "Memory allocation failure from malloc().\n",
+    eprintf1("%s" ERRPREF "Memory allocation failure from malloc().\n",
       epref);
     return_error(gs_error_VMerror);
   }
@@ -1514,7 +1513,7 @@
     free(lengths); free(rd.next); free(rd.previous);
     for (j = 0; j < 2; j++) free(rd.workspace[j]);
 
-    fprintf(stderr, "%s" ERRPREF "Memory allocation failure from malloc().\n",
+    eprintf1("%s" ERRPREF "Memory allocation failure from malloc().\n",
       epref);
     return_error(gs_error_VMerror);
   }