]> git.ipfire.org Git - thirdparty/cups.git/blame - pstoraster/pstoraster.c
Y2k copyright changes.
[thirdparty/cups.git] / pstoraster / pstoraster.c
CommitLineData
769d0ee3 1/*
71fe22b7 2 * "$Id: pstoraster.c,v 1.11 2000/01/04 13:46:07 mike Exp $"
769d0ee3 3 *
4 * PostScript RIP filter main entry for the Common UNIX Printing System
5 * (CUPS).
6 *
71fe22b7 7 * Copyright 1993-2000 by Easy Software Products.
769d0ee3 8 *
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
14 * at:
15 *
16 * Attn: CUPS Licensing Information
17 * Easy Software Products
18 * 44141 Airport View Drive, Suite 204
19 * Hollywood, Maryland 20636-3111 USA
20 *
21 * Voice: (301) 373-9603
22 * EMail: cups-info@cups.org
23 * WWW: http://www.cups.org
24 *
25 * This code and any derivative of it may be used and distributed
26 * freely under the terms of the GNU General Public License when
27 * used with GNU Ghostscript or its derivatives. Use of the code
28 * (or any derivative of it) with software other than GNU
29 * GhostScript (or its derivatives) is governed by the CUPS license
30 * agreement.
31 *
32 * Contents:
33 *
9958763a 34 * main() - Main entry for pstoraster.
35 * define_string() - Define a string value...
769d0ee3 36 */
37
38/*
39 * Include necessary headers...
40 */
41
7aada6e1 42#define bool bool_ /* (maybe not needed) */
43#define uchar uchar_
44#define uint uint_
45#define ushort ushort_
46#define ulong ulong_
5af8d1d7 47
48#include <cups/cups.h>
49#include <cups/string.h>
9958763a 50#include <stdlib.h>
5af8d1d7 51
7aada6e1 52#undef bool
53#undef uchar
54#undef uint
55#undef ushort
56#undef ulong
5af8d1d7 57
769d0ee3 58#include "ghost.h"
59#include "imain.h"
769d0ee3 60#include "iminst.h"
61#include "ostack.h"
62#include "gscdefs.h"
63#include "store.h"
64
65
5af8d1d7 66/*
67 * Globals...
68 */
69
70const char *cupsProfile = NULL;
71
72
769d0ee3 73/*
74 * Local functions...
75 */
76
77static void define_string(char *, char *);
78
79
80/*
81 * 'main()' - Main entry for pstoraster.
82 */
83
84int /* O - Exit status */
85main(int argc, /* I - Number of command-line arguments */
86 char *argv[]) /* I - Command-line arguments */
87{
88 FILE *stdfiles[3]; /* Copies of stdin, stdout, and stderr */
89 gs_main_instance *minst; /* Interpreter instance */
90 ref vtrue; /* True value */
91 int code; /* Run status code */
92 int exit_code; /* Exit code */
93 ref error_object; /* Error object */
9958763a 94 char *content_type; /* CONTENT_TYPE environment variable */
5af8d1d7 95 int num_options; /* Number of job options */
96 cups_option_t *options; /* Job options */
769d0ee3 97
98
f8981457 99 /*
100 * Force the locale to "C" to avoid bugs...
101 */
102
103 putenv("LANG=C");
104
769d0ee3 105 /*
106 * Create a PostScript interpreter instance...
107 */
108
109 minst = gs_main_instance_default();
110
111 /*
112 * Grab the old stdin/stdout/stderr...
113 */
114
115 gs_get_real_stdio(stdfiles);
116
5af8d1d7 117 /*
118 * Grab any job options...
119 */
120
121 num_options = cupsParseOptions(argv[5], 0, &options);
122
123 cupsProfile = cupsGetOption("profile", num_options, options);
124
769d0ee3 125 /*
126 * Initialize basic interpreter stuff and read from the named file or
127 * from stdin...
128 */
129
130 if (argc > 6)
131 gs_main_init0(minst, fopen(argv[6], "r"), stdfiles[1], stdfiles[2], 8);
132 else
133 gs_main_init0(minst, stdfiles[0], stdfiles[1], stdfiles[2], 8);
134
135 /*
136 * Tell the interpreter where to find its files...
137 */
138
29a6320b 139 minst->lib_path.final = gs_lib_default_path;
769d0ee3 140 gs_main_set_lib_paths(minst);
141
142 /*
143 * Set interpreter options...
144 */
145
146 make_true(&vtrue);
147 gs_main_init1(minst);
148 initial_enter_name("QUIET", &vtrue);
149 initial_enter_name("NOPAUSE", &vtrue);
9958763a 150 if ((content_type = getenv("CONTENT_TYPE")) != NULL &&
151 strcmp(content_type, "application/pdf") == 0)
152 {
ea002b48 153 fputs("INFO: Converting PDF file to PostScript...\n", stderr);
9958763a 154 define_string("PSFile", "%stdout");
155 initial_enter_name("NODISPLAY", &vtrue);
156 }
157 else
158 define_string("OutputFile", "-");
274f9fbb 159 define_string("FONTPATH", CUPS_DATADIR "/fonts");
769d0ee3 160
161 /*
162 * Start the interpreter...
163 */
164
165 gs_main_init2(minst);
166 code = gs_main_run_string(minst, ".runstdin", minst->user_errors,
167 &exit_code, &error_object);
168
169 /*
170 * Make sure that the last page was printed...
171 */
172
173 zflush(osp);
174 zflushpage(osp);
175
176 /*
177 * And the exit when we're done...
178 */
179
180 gs_exit(exit_code);
181
182 return (0);
183}
184
185
186/*
187 * 'define_string()' - Define a string value...
188 */
189
190static void
191define_string(char *name, /* I - Variable to set */
192 char *s) /* I - Value */
193{
194 int len; /* Length of string */
195 char *copy; /* Copy of string */
196 ref value; /* Value object */
197
198
199 /*
200 * Get the string value and copy it using strdup(). Note that this uses
201 * the malloc() function, but since we are only running gsrip on "real"
202 * operating systems (no Windows/PC build), this is not a problem...
203 */
204
205 if (s == NULL)
206 {
207 len = 0;
208 copy = strdup("");
209 }
210 else
211 {
212 len = strlen(s);
213 copy = strdup(s);
214 };
215
216 /*
217 * Enter the name in systemdict...
218 */
219
220 make_const_string(&value, a_readonly | avm_foreign, len, (const byte *)copy);
221 initial_enter_name(name, &value);
222}
223
224
225/*
71fe22b7 226 * End of "$Id: pstoraster.c,v 1.11 2000/01/04 13:46:07 mike Exp $".
769d0ee3 227 */