]> git.ipfire.org Git - thirdparty/cups.git/blob - pstoraster/gp.h
Import cups.org releases
[thirdparty/cups.git] / pstoraster / gp.h
1 /* Copyright (C) 1991, 1995 Aladdin Enterprises. All rights reserved.
2
3 This file is part of GNU Ghostscript.
4
5 GNU Ghostscript is distributed in the hope that it will be useful, but
6 WITHOUT ANY WARRANTY. No author or distributor accepts responsibility to
7 anyone for the consequences of using it or for whether it serves any
8 particular purpose or works at all, unless he says so in writing. Refer to
9 the GNU General Public License for full details.
10
11 Everyone is granted permission to copy, modify and redistribute GNU
12 Ghostscript, but only under the conditions described in the GNU General
13 Public License. A copy of this license is supposed to have been given to
14 you along with GNU Ghostscript so you can know your rights and
15 responsibilities. It should be in a file named COPYING. Among other
16 things, the copyright notice and this notice must be preserved on all
17 copies.
18
19 Aladdin Enterprises is not affiliated with the Free Software Foundation or
20 the GNU Project. GNU Ghostscript, as distributed by Aladdin Enterprises,
21 does not depend on any other GNU software.
22 */
23
24 /* gp.h */
25 /* Interface to platform-specific routines */
26 /* Requires gsmemory.h, gstypes.h */
27
28 /*
29 * This file defines the interface to ***ALL*** platform-specific routines.
30 * The routines are implemented in a gp_*.c file specific to each platform.
31 * We try very hard to keep this list short!
32 */
33
34 /* ------ Initialization/termination ------ */
35
36 /*
37 * This routine is called early in the initialization.
38 * It should do as little as possible. In particular, it should not
39 * do things like open display connections: that is the responsibility
40 * of the display device driver.
41 */
42 void gp_init(P0());
43
44 /*
45 * This routine is called just before the program exits (normally or
46 * abnormally). It too should do as little as possible.
47 */
48 void gp_exit(P2(int exit_status, int code));
49
50 /*
51 * Exit the program. Normally this just calls the `exit' library procedure,
52 * but it does something different on a few platforms.
53 */
54 void gp_do_exit(P1(int exit_status));
55
56 /* ------ Miscellaneous ------ */
57
58 /*
59 * Get the string corresponding to an OS error number.
60 * If no string is available, return NULL. The caller may assume
61 * the string is allocated statically and permanently.
62 */
63 const char *gp_strerror(P1(int));
64
65 /* ------ Date and time ------ */
66
67 /*
68 * Read the current time (in seconds since an implementation-defined epoch)
69 * into ptm[0], and fraction (in nanoseconds) into ptm[1].
70 */
71 void gp_get_realtime(P1(long ptm[2]));
72
73 /*
74 * Read the current user CPU time (in seconds) into ptm[0],
75 * and fraction (in nanoseconds) into ptm[1].
76 */
77 void gp_get_usertime(P1(long ptm[2]));
78
79 /* ------ Screen management ------ */
80
81 /*
82 * The following routines are only relevant in a single-window environment
83 * such as a PC; on platforms with window systems, the 'make current'
84 * routines do nothing.
85 */
86
87 #ifndef gx_device_DEFINED
88 # define gx_device_DEFINED
89 typedef struct gx_device_s gx_device;
90 #endif
91
92 /* Initialize the console. */
93 void gp_init_console(P0());
94
95 /* Write a string to the console. */
96 void gp_console_puts(P2(const char *, uint));
97
98 /* Make the console current on the screen. */
99 int gp_make_console_current(P1(gx_device *));
100
101 /* Make the graphics current on the screen. */
102 int gp_make_graphics_current(P1(gx_device *));
103
104 /*
105 * The following are only relevant for X Windows.
106 */
107
108 /* Get the environment variable that specifies the display to use. */
109 const char *gp_getenv_display(P0());
110
111 /* ------ Printer accessing ------ */
112
113 /*
114 * Open a connection to a printer. A null file name means use the
115 * standard printer connected to the machine, if any.
116 * If possible, support "|command" for opening an output pipe.
117 * Return NULL if the connection could not be opened.
118 */
119 FILE *gp_open_printer(P2(char *fname, int binary_mode));
120
121 /* Close the connection to the printer. */
122 void gp_close_printer(P2(FILE *pfile, const char *fname));
123
124 /* ------ File naming and accessing ------ */
125
126 /* Define the character used for separating file names in a list. */
127 extern const char gp_file_name_list_separator;
128
129 /* Define the default scratch file name prefix. */
130 extern const char gp_scratch_file_name_prefix[];
131
132 /* Define the name of the null output file. */
133 extern const char gp_null_file_name[];
134
135 /* Define the name that designates the current directory. */
136 extern const char gp_current_directory_name[];
137
138 /* Define the string to be concatenated with the file mode */
139 /* for opening files without end-of-line conversion. */
140 /* This is always either "" or "b". */
141 extern const char gp_fmode_binary_suffix[];
142 /* Define the file modes for binary reading or writing. */
143 /* (This is just a convenience: they are "r" or "w" + the suffix.) */
144 extern const char gp_fmode_rb[];
145 extern const char gp_fmode_wb[];
146
147 /* Create and open a scratch file with a given name prefix. */
148 /* Write the actual file name at fname. */
149 FILE *gp_open_scratch_file(P3(const char *prefix, char *fname,
150 const char *mode));
151
152 /* Open a file with the given name, as a stream of uninterpreted bytes. */
153 FILE *gp_fopen(P2(const char *fname, const char *mode));
154
155 /* Answer whether a file name contains a directory/device specification, */
156 /* i.e. is absolute (not directory- or device-relative). */
157 bool gp_file_name_is_absolute(P2(const char *fname, uint len));
158
159 /* Answer the string to be used for combining a directory/device prefix */
160 /* with a base file name. The file name is known to not be absolute. */
161 const char *gp_file_name_concat_string(P4(const char *prefix, uint plen,
162 const char *fname, uint len));
163
164 /* ------ File enumeration ------ */
165
166 #ifndef file_enum_DEFINED /* also defined in iodev.h */
167 # define file_enum_DEFINED
168 struct file_enum_s; /* opaque to client, defined by implementor */
169 typedef struct file_enum_s file_enum;
170 #endif
171
172 /*
173 * Begin an enumeration. pat is a C string that may contain *s or ?s.
174 * The implementor should copy the string to a safe place.
175 * If the operating system doesn't support correct, arbitrarily placed
176 * *s and ?s, the implementation should modify the string so that it
177 * will return a conservative superset of the request, and then use
178 * the string_match procedure to select the desired subset. E.g., if the
179 * OS doesn't implement ? (single-character wild card), any consecutive
180 * string of ?s should be interpreted as *. Note that \ can appear in
181 * the pattern also, as a quoting character.
182 */
183 file_enum *gp_enumerate_files_init(P3(const char *pat, uint patlen,
184 gs_memory_t *memory));
185
186 /*
187 * Return the next file name in the enumeration. The client passes in
188 * a scratch string and a max length. If the name of the next file fits,
189 * the procedure returns the length. If it doesn't fit, the procedure
190 * returns max length +1. If there are no more files, the procedure
191 * returns -1.
192 */
193 uint gp_enumerate_files_next(P3(file_enum *pfen, char *ptr, uint maxlen));
194
195 /*
196 * Clean up a file enumeration. This is only called to abandon
197 * an enumeration partway through: ...next should do it if there are
198 * no more files to enumerate. This should deallocate the file_enum
199 * structure and any subsidiary structures, strings, buffers, etc.
200 */
201 void gp_enumerate_files_close(P1(file_enum *pfen));