xref: /plan9/sys/src/cmd/gs/src/gsfname.h (revision 593dc095aefb2a85c828727bbfa9da139a49bdf4)
1 /* Copyright (C) 1993, 1998, 1999 Aladdin Enterprises.  All rights reserved.
2 
3   This software is provided AS-IS with no warranty, either express or
4   implied.
5 
6   This software is distributed under license and may not be copied,
7   modified or distributed except as expressly authorized under the terms
8   of the license contained in the file LICENSE in this distribution.
9 
10   For more information about licensing, please refer to
11   http://www.ghostscript.com/licensing/. For information on
12   commercial licensing, go to http://www.artifex.com/licensing/ or
13   contact Artifex Software, Inc., 101 Lucas Valley Road #110,
14   San Rafael, CA  94903, U.S.A., +1(415)492-9861.
15 */
16 
17 /* $Id: gsfname.h,v 1.5 2002/06/16 08:45:42 lpd Exp $ */
18 
19 #ifndef gsfname_INCLUDED
20 #  define gsfname_INCLUDED
21 
22 /*
23  * Structure and procedures for parsing file names.
24  *
25  * Define a structure for representing a parsed file name, consisting of
26  * an IODevice name in %'s, a file name, or both.  Note that the file name
27  * may be either a gs_string (no terminator) or a C string (null terminator).
28  *
29  * NOTE: You must use parse_[real_]file_name to construct parsed_file_names.
30  * Do not simply allocate the structure and fill it in.
31  */
32 #ifndef gx_io_device_DEFINED
33 #  define gx_io_device_DEFINED
34 typedef struct gx_io_device_s gx_io_device;
35 #endif
36 
37 typedef struct gs_parsed_file_name_s {
38     gs_memory_t *memory;	/* allocator for terminated name string */
39     gx_io_device *iodev;
40     const char *fname;
41     uint len;
42 } gs_parsed_file_name_t;
43 
44 /* Parse a file name into device and individual name. */
45 int gs_parse_file_name(gs_parsed_file_name_t *, const char *, uint);
46 
47 /* Parse a real (non-device) file name and convert to a C string. */
48 int gs_parse_real_file_name(gs_parsed_file_name_t *, const char *, uint,
49 			    gs_memory_t *, client_name_t);
50 
51 /* Convert a file name to a C string by adding a null terminator. */
52 int gs_terminate_file_name(gs_parsed_file_name_t *, gs_memory_t *,
53 			   client_name_t);
54 
55 /* Free a file name that was copied to a C string. */
56 void gs_free_file_name(gs_parsed_file_name_t *, client_name_t);
57 
58 #endif /* gsfname_INCLUDED */
59