summaryrefslogtreecommitdiff
path: root/print/ghostscript-gpl/files/patch-contrib__pcl3__eprn__eprnparm.c
blob: 5d0443b4ff75937a8450a664d9367f89060ba336 (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
--- contrib/pcl3/eprn/eprnparm.c.orig	Thu Apr 26 01:27:24 2007
+++ contrib/pcl3/eprn/eprnparm.c	Tue May 15 02:02:42 2007
@@ -146,7 +146,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 eprn_get_int(): %s.\n",
       strerror(errno));
     return_error(gs_error_VMerror);
@@ -352,8 +352,7 @@
   'eprn->media_overrides' should be NULL.
 
   The function returns zero on success and a non-zero ghostscript error value
-  otherwise. In the latter case, an error message will have been issued on
-  stderr.
+  otherwise. In the latter case, an error message will have been issued.
 
 ******************************************************************************/
 
@@ -379,7 +378,7 @@
 
   /* Open the file */
   if ((f = fopen(eprn->media_file, "r")) == NULL) {
-    fprintf(stderr, "%s" ERRPREF "Error opening the media configuration file\n"
+    eprintf5("%s" ERRPREF "Error opening the media configuration file\n"
       "%s    `%s'\n%s  for reading: %s.\n",
       epref, epref, eprn->media_file, epref, strerror(errno));
     return_error(gs_error_invalidfileaccess);
@@ -395,7 +394,7 @@
 
     /* Check for buffer overflow */
     if ((s = strchr(buffer, '\n')) == NULL && fgetc(f) != EOF) {
-      fprintf(stderr, "%s" ERRPREF "Exceeding line length %d in "
+      eprintf5("%s" ERRPREF "Exceeding line length %d in "
 	  "media configuration file\n%s  %s, line %d.\n",
 	epref, BUFFER_SIZE - 2 /* '\n'+'\0' */, epref, eprn->media_file, line);
       cleanup();
@@ -453,7 +452,7 @@
       new_list = (eprn_PageDescription *)
 	realloc(list, (read+1)*sizeof(eprn_PageDescription));
       if (new_list == NULL) {
-	fprintf(stderr, "%s" ERRPREF
+	eprintf2("%s" ERRPREF
 	  "Memory allocation failure in eprn_read_media_data(): %s.\n",
 	  epref, strerror(errno));
 	cleanup();
@@ -477,14 +476,14 @@
     {
       ms_MediaCode code = ms_find_code_from_name(s, eprn->flag_desc);
       if (code == ms_none) {
-	fprintf(stderr, "%s" ERRPREF "Unknown media name (%s) in "
+	eprintf5("%s" ERRPREF "Unknown media name (%s) in "
 	    "media configuration file\n%s  %s, line %d.\n",
 	  epref, s, epref, eprn->media_file, line);
 	cleanup();
 	return_error(gs_error_rangecheck);
       }
       if (code & MS_ROTATED_FLAG) {
-	fprintf(stderr, "%s" ERRPREF "Invalid substring \"" MS_ROTATED_STRING
+	eprintf5("%s" ERRPREF "Invalid substring \"" MS_ROTATED_STRING
 	    "\" in media name (%s)\n"
 	  "%s  in media configuration file %s, line %d.\n",
 	  epref, s, epref, eprn->media_file, line);
@@ -499,7 +498,7 @@
 	  &current->bottom, &current->right, &current->top, &chars_read) != 4 ||
 	t[chars_read] != '\0') {
       if (*t != '\0') *(t-1) = ' ';	/* remove NUL after media name */
-      fprintf(stderr, "%s" ERRPREF
+      eprintf5("%s" ERRPREF
 	"Syntax error in media configuration file %s, line %d:\n%s    %s\n",
 	epref, eprn->media_file, line, epref, buffer);
       cleanup();
@@ -509,7 +508,7 @@
     /* Check for sign */
     if (current->left < 0 || current->bottom < 0 || current->right < 0 ||
 	current->top < 0) {
-      fprintf(stderr, "%s" ERRPREF
+      eprintf4("%s" ERRPREF
 	"Ghostscript does not support negative margins (line %d in the\n"
 	"%s  media configuration file %s).\n",
 	epref, line, epref, eprn->media_file);
@@ -530,14 +529,14 @@
        The user might not notice the reason without help, hence we check. */
     if (ms_without_flags(current->code) == ms_CustomPageSize &&
 	eprn->cap->custom == NULL)
-      fprintf(stderr, "%s" WARNPREF "The media configuration file %s\n"
+      eprintf6("%s" WARNPREF "The media configuration file %s\n"
 	"%s    contains a custom page size entry in line %d, "
 	  "but custom page sizes\n"
 	"%s    are not supported by the %s.\n",
 	wpref, eprn->media_file, wpref, line, wpref, eprn->cap->name);
   }
   if (ferror(f)) {
-    fprintf(stderr, "%s" ERRPREF
+    eprintf2("%s" ERRPREF
       "Unidentified system error while reading `%s'.\n",
       epref, eprn->media_file);
     cleanup();
@@ -547,7 +546,7 @@
 
   /* Was the file empty? */
   if (read == 0) {
-    fprintf(stderr, "%s" ERRPREF "The media configuration file %s\n"
+    eprintf3("%s" ERRPREF "The media configuration file %s\n"
       "%s  does not contain any media information.\n",
       epref, eprn->media_file, epref);
     return_error(gs_error_rangecheck);
@@ -557,7 +556,7 @@
   eprn->media_overrides = (eprn_PageDescription *) gs_malloc(gs_lib_ctx_get_non_gc_memory_t(), read + 1,
     sizeof(eprn_PageDescription), "eprn_read_media_data");
   if (eprn->media_overrides == NULL) {
-    fprintf(stderr, "%s" ERRPREF
+    eprintf1("%s" ERRPREF
       "Memory allocation failure from gs_malloc() in eprn_read_media_data().\n",
       epref);
     free(list);
@@ -585,8 +584,7 @@
   from the specified media configuration file.
 
   The return code will be zero an success and a ghostscript error code
-  otherwise. In the latter case, an error message will have been issued on
-  stderr.
+  otherwise. In the latter case, an error message will have been issued.
 
   The 'length' may be positive in which case it denotes the length of the
   string 'media_file' or zero in which case the string is assumed to be
@@ -629,7 +627,7 @@
     eprn->media_file = (char *)gs_malloc(gs_lib_ctx_get_non_gc_memory_t(), length + 1, sizeof(char),
       "eprn_set_media_data");
     if (eprn->media_file == NULL) {
-      fprintf(stderr, "%s" ERRPREF
+      eprintf1("%s" ERRPREF
 	"Memory allocation failure from gs_malloc() in "
 	"eprn_set_media_data().\n",
 	epref);
@@ -928,9 +926,9 @@
     rc = eprn_get_int(&string_value, eprn_colour_model_list, &temp);	\
     if (rc != 0) {							\
       if (rc != gs_error_VMerror) {					\
-	fprintf(stderr, "%s" ERRPREF "Unknown colour model: `", epref);	\
-	fwrite(string_value.data, sizeof(char), string_value.size, stderr); \
-	fputs("'.\n", stderr);						\
+	eprintf1("%s" ERRPREF "Unknown colour model: `", epref);	\
+	errwrite(string_value.data, sizeof(char)*string_value.size);	\
+	eprintf("'.\n");						\
       }									\
       last_error = rc;							\
       param_signal_error(plist, pname, last_error);			\
@@ -994,7 +992,7 @@
       eprn->black_levels = temp;
     }
     else {
-      fprintf(stderr, "%s" ERRPREF
+      eprintf2("%s" ERRPREF
 	"The value for BlackLevels is outside the range permitted: %d.\n",
 	epref, temp);
       last_error = gs_error_rangecheck;
@@ -1011,7 +1009,7 @@
       eprn->non_black_levels = temp;
     }
     else {
-      fprintf(stderr, "%s" ERRPREF
+      eprintf2("%s" ERRPREF
 	"The value for CMYLevels is outside the range permitted: %d.\n",
 	epref, temp);
       last_error = gs_error_rangecheck;
@@ -1025,8 +1023,8 @@
     bool temp;
     if ((rc = param_read_bool(plist, "CUPSAccounting", &temp)) == 0) {
       if (eprn->CUPS_accounting && !temp)
-	fputs(CUPS_WARNPREF WARNPREF
-	  "Attempt to set CUPSAccounting from true to false.\n", stderr);
+	eprintf(CUPS_WARNPREF WARNPREF
+	  "Attempt to set CUPSAccounting from true to false.\n");
       else eprn->CUPS_accounting = temp;
     }
     else if (rc < 0) last_error = rc;
@@ -1042,10 +1040,10 @@
       eprn->intensity_rendering = temp;
     }
     else {
-      fprintf(stderr, "%s" ERRPREF "Invalid method for IntensityRendering: `",
+      eprintf1("%s" ERRPREF "Invalid method for IntensityRendering: `",
         epref);
-      fwrite(string_value.data, sizeof(char), string_value.size, stderr);
-      fputs("'.\n", stderr);
+      errwrite(string_value.data, sizeof(char)*string_value.size);
+      eprintf("'.\n");
       last_error = gs_error_rangecheck;
       param_signal_error(plist, pname, last_error);
     }
@@ -1066,7 +1064,7 @@
       eprn->default_orientation = temp;
     }
     else {
-      fprintf(stderr,
+      eprintf2(
 	"%s" ERRPREF "LeadingEdge may only have values 0 to 3, not %d.\n",
 	epref, temp);
       last_error = gs_error_rangecheck;
@@ -1111,7 +1109,7 @@
     /* Current (up to at least gs 6.50) ghostscript versions do not accept
        negative MediaPosition values. */
     if (eprn->media_position < 0)
-      fprintf(stderr, "%s" WARNPREF
+      eprintf3("%s" WARNPREF
 	"Ghostscript does not accept negative values (%d) for the\n"
 	  "%s    `MediaPosition' parameter.\n",
 	wpref, eprn->media_position, wpref);
@@ -1145,7 +1143,7 @@
       eprn->pagecount_file = (char *)gs_malloc(gs_lib_ctx_get_non_gc_memory_t(), string_value.size + 1,
 	sizeof(char), "eprn_put_params");
       if (eprn->pagecount_file == NULL) {
-	fprintf(stderr, "%s" ERRPREF
+	eprintf1( "%s" ERRPREF
 	  "Memory allocation failure from gs_malloc() in eprn_put_params().\n",
 	  epref);
 	last_error = gs_error_VMerror;
@@ -1167,7 +1165,7 @@
       eprn->non_black_levels = temp;
     }
     else {
-      fprintf(stderr, "%s" ERRPREF
+      eprintf2("%s" ERRPREF
 	"The value for RGBLevels is outside the range permitted: %d.\n",
 	epref, temp);
       last_error = gs_error_rangecheck;
@@ -1187,7 +1185,7 @@
   */
   if ((rc = param_read_int(plist, (pname = "BitsPerPixel"), &temp)) == 0) {
     if (temp != dev->color_info.depth) {
-      fprintf(stderr, "%s" ERRPREF
+      eprintf3("%s" ERRPREF
 	"Attempt to set `BitsPerPixel' to a value (%d)\n"
 	"%s  other than the one selected by the driver.\n",
 	epref, temp, epref);