1
/* Copyright (C) 2001-2006 Artifex Software, Inc.
4
This software is provided AS-IS with no warranty, either express or
7
This software is distributed under license and may not be copied, modified
8
or distributed except as expressly authorized under the terms of that
9
license. Refer to licensing information at http://www.artifex.com/
10
or contact Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134,
11
San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information.
14
/* $Id: gsargs.h 8051 2007-06-14 22:06:25Z alexcher $ */
15
/* Command line argument list management */
17
#ifndef gsargs_INCLUDED
18
# define gsargs_INCLUDED
21
* We need to handle recursion into @-files.
22
* The following structures keep track of the state.
23
* Defining a maximum argument length and a maximum nesting depth
24
* decreases generality, but eliminates the need for dynamic allocation.
26
#define arg_str_max 2048
27
#define arg_depth_max 10
28
typedef struct arg_source_s {
32
bool parsed; /* true for "pushed-back" argument, not to be parsed again */
33
char *chars; /* original string */
34
gs_memory_t *memory; /* if non-0, free chars when done with it */
35
const char *str; /* string being read */
40
typedef struct arg_list_s {
41
bool expand_ats; /* if true, expand @-files */
42
FILE *(*arg_fopen) (const char *fname, void *fopen_data);
46
int depth; /* depth of @-files */
47
char cstr[arg_str_max + 1];
48
arg_source sources[arg_depth_max];
51
/* Initialize an arg list. */
52
void arg_init(arg_list * pal, const char **argv, int argc,
53
FILE * (*arg_fopen) (const char *fname, void *fopen_data),
57
* Push a string onto an arg list.
58
* This may also be used (once) to "unread" the last argument.
59
* If mem != 0, it is used to free the string when we are done with it.
60
* Return 0 on success, non-zero on failure
62
int arg_push_memory_string(arg_list * pal, char *str, bool parsed, gs_memory_t * mem);
64
#define arg_push_string(pal, str, parsed)\
65
arg_push_memory_string(pal, str, parsed, (gs_memory_t *)0);
67
/* Clean up an arg list before exiting. */
68
void arg_finit(arg_list * pal);
71
* Get the next arg from a list.
72
* Note that these are not copied to the heap.
74
const char *arg_next(arg_list * pal, int *code);
76
/* Copy an argument string to the heap. */
77
char *arg_copy(const char *str, gs_memory_t * mem);
79
#endif /* gsargs_INCLUDED */