1 /* Copyright (C) 2001-2019 Artifex Software, Inc.
2    All Rights Reserved.
3 
4    This software is provided AS-IS with no warranty, either express or
5    implied.
6 
7    This software is distributed under license and may not be copied,
8    modified or distributed except as expressly authorized under the terms
9    of the license contained in the file LICENSE in this distribution.
10 
11    Refer to licensing information at http://www.artifex.com or contact
12    Artifex Software, Inc.,  1305 Grant Avenue - Suite 200, Novato,
13    CA 94945, U.S.A., +1(415)492-9861, for further information.
14 */
15 
16 
17 /* String and hexstring streams (filters) */
18 
19 #ifndef sstring_INCLUDED
20 #  define sstring_INCLUDED
21 
22 #include "scommon.h"
23 
24 /* ASCIIHexEncode */
25 typedef struct stream_AXE_state_s {
26     stream_state_common;
27     /* The following are set by the client. */
28     bool EndOfData;		/* if true, write > at EOD (default) */
29     /* The following change dynamically. */
30     int count;			/* # of digits since last EOL */
31 } stream_AXE_state;
32 
33 #define private_st_AXE_state()	/* in sstring.c */\
34   gs_private_st_simple(st_AXE_state, stream_AXE_state,\
35     "ASCIIHexEncode state")
36 #define s_AXE_init_inline(ss)\
37   ((ss)->EndOfData = true, (ss)->count = 0)
38 extern const stream_template s_AXE_template;
39 
40 /* ASCIIHexDecode */
41 typedef struct stream_AXD_state_s {
42     stream_state_common;
43     int odd;			/* odd digit */
44 } stream_AXD_state;
45 
46 #define private_st_AXD_state()	/* in sstring.c */\
47   gs_private_st_simple(st_AXD_state, stream_AXD_state,\
48     "ASCIIHexDecode state")
49 #define s_AXD_init_inline(ss)\
50   ((ss)->min_left = 1, (ss)->odd = -1, 0)
51 extern const stream_template s_AXD_template;
52 
53 /* PSStringDecode */
54 typedef struct stream_PSSD_state_s {
55     stream_state_common;
56     /* The following are set by the client. */
57     bool from_string;		/* true if using Level 1 \ convention */
58     /* The following change dynamically. */
59     int depth;
60 } stream_PSSD_state;
61 
62 #define private_st_PSSD_state()	/* in sstring.c */\
63   gs_private_st_simple(st_PSSD_state, stream_PSSD_state,\
64     "PSStringDecode state")
65 
66 /* Initialize the state */
67 int s_PSSD_init(stream_state * st);
68 
69 /* A special initialization procedure for the scanner */
70 /* can avoid a procedure call. */
71 /* Note : it doesn't initialize ss->from_string. */
72 #define s_PSSD_partially_init_inline(ss)\
73   ((ss)->depth = 0)
74 extern const stream_template s_PSSD_template;
75 
76 /* PSStringEncode */
77 /* (no state) */
78 extern const stream_template s_PSSE_template;
79 
80 #endif /* sstring_INCLUDED */
81