]> git.ipfire.org Git - thirdparty/cups.git/blob - pstoraster/gsargs.h
Import cups.org releases
[thirdparty/cups.git] / pstoraster / gsargs.h
1 /* Copyright (C) 1997, 1998 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
7 to 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
9 to 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
14 to 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 supports the work of the GNU Project, but is not
20 affiliated with the Free Software Foundation or the GNU Project. GNU
21 Ghostscript, as distributed by Aladdin Enterprises, does not require any
22 GNU software to build or run it.
23 */
24
25 /*$Id$ */
26 /* Command line argument list management */
27
28 #ifndef gsargs_INCLUDED
29 # define gsargs_INCLUDED
30
31 /*
32 * We need to handle recursion into @-files.
33 * The following structures keep track of the state.
34 * Defining a maximum argument length and a maximum nesting depth
35 * decreases generality, but eliminates the need for dynamic allocation.
36 */
37 #define arg_str_max 512
38 #define arg_depth_max 10
39 typedef struct arg_source_s {
40 bool is_file;
41 union _u {
42 struct _su {
43 const char *chars; /* original string */
44 gs_memory_t *memory; /* if non-0, free chars when done with it */
45 const char *str; /* string being read */
46 } s;
47 FILE *file;
48 } u;
49 } arg_source;
50 typedef struct arg_list_s {
51 bool expand_ats; /* if true, expand @-files */
52 FILE *(*arg_fopen) (P2(const char *fname, void *fopen_data));
53 void *fopen_data;
54 const char **argp;
55 int argn;
56 int depth; /* depth of @-files */
57 char cstr[arg_str_max + 1];
58 arg_source sources[arg_depth_max];
59 } arg_list;
60
61 /* Initialize an arg list. */
62 void arg_init(P5(arg_list * pal, const char **argv, int argc,
63 FILE * (*arg_fopen) (P2(const char *fname, void *fopen_data)),
64 void *fopen_data));
65
66 /*
67 * Push a string onto an arg list.
68 * This may also be used (once) to "unread" the last argument.
69 * If mem != 0, it is used to free the string when we are done with it.
70 */
71 void arg_push_memory_string(P3(arg_list * pal, const char *str,
72 gs_memory_t * mem));
73
74 #define arg_push_string(pal, str)\
75 arg_push_memory_string(pal, str, (gs_memory_t *)0);
76
77 /* Clean up an arg list before exiting. */
78 void arg_finit(P1(arg_list * pal));
79
80 /*
81 * Get the next arg from a list.
82 * Note that these are not copied to the heap.
83 */
84 const char *arg_next(P1(arg_list * pal));
85
86 /* Copy an argument string to the heap. */
87 char *arg_copy(P2(const char *str, gs_memory_t * mem));
88
89 #endif /* gsargs_INCLUDED */