xref: /plan9/sys/src/cmd/gs/src/sstring.h (revision 593dc095aefb2a85c828727bbfa9da139a49bdf4)
1 /* Copyright (C) 1996, 1998 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: sstring.h,v 1.7 2005/04/25 12:28:49 igor Exp $ */
18 /* String and hexstring streams (filters) */
19 
20 #ifndef sstring_INCLUDED
21 #  define sstring_INCLUDED
22 
23 /* ASCIIHexEncode */
24 typedef struct stream_AXE_state_s {
25     stream_state_common;
26     /* The following are set by the client. */
27     bool EndOfData;		/* if true, write > at EOD (default) */
28     /* The following change dynamically. */
29     int count;			/* # of digits since last EOL */
30 } stream_AXE_state;
31 
32 #define private_st_AXE_state()	/* in sstring.c */\
33   gs_private_st_simple(st_AXE_state, stream_AXE_state,\
34     "ASCIIHexEncode state")
35 #define s_AXE_init_inline(ss)\
36   ((ss)->EndOfData = true, (ss)->count = 0)
37 extern const stream_template s_AXE_template;
38 
39 /* ASCIIHexDecode */
40 typedef struct stream_AXD_state_s {
41     stream_state_common;
42     int odd;			/* odd digit */
43 } stream_AXD_state;
44 
45 #define private_st_AXD_state()	/* in sstring.c */\
46   gs_private_st_simple(st_AXD_state, stream_AXD_state,\
47     "ASCIIHexDecode state")
48 #define s_AXD_init_inline(ss)\
49   ((ss)->min_left = 1, (ss)->odd = -1, 0)
50 extern const stream_template s_AXD_template;
51 
52 /* PSStringDecode */
53 typedef struct stream_PSSD_state_s {
54     stream_state_common;
55     /* The following are set by the client. */
56     bool from_string;		/* true if using Level 1 \ convention */
57     /* The following change dynamically. */
58     int depth;
59 } stream_PSSD_state;
60 
61 #define private_st_PSSD_state()	/* in sstring.c */\
62   gs_private_st_simple(st_PSSD_state, stream_PSSD_state,\
63     "PSStringDecode state")
64 
65 /* Initialize the state */
66 int s_PSSD_init(stream_state * st);
67 
68 /* A special initialization procedure for the scanner */
69 /* can avoid a procedure call. */
70 /* Note : it doesn't initialize ss->from_string. */
71 #define s_PSSD_partially_init_inline(ss)\
72   ((ss)->depth = 0)
73 extern const stream_template s_PSSD_template;
74 
75 /* PSStringEncode */
76 /* (no state) */
77 extern const stream_template s_PSSE_template;
78 
79 #endif /* sstring_INCLUDED */
80