Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / lib / DtTerm / TermPrim / TermPrimParserP.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* 
24 ** $XConsortium: TermPrimParserP.h /main/1 1996/04/21 19:18:27 drk $
25 */
26 /*                                                                      *
27  * (c) Copyright 1993, 1994 Hewlett-Packard Company                     *
28  * (c) Copyright 1993, 1994 International Business Machines Corp.       *
29  * (c) Copyright 1993, 1994 Sun Microsystems, Inc.                      *
30  * (c) Copyright 1993, 1994 Novell, Inc.                                *
31  */
32 #ifndef   _Dt_TermPrimParserP_h
33 #define   _Dt_TermPrimParserP_h
34
35 #include  "TermPrimParser.h"
36 #include  <limits.h>
37
38 #ifdef     __cplusplus
39 extern "C" {
40 #endif  /* __cplusplus */
41
42
43 typedef enum _TermParserSign
44 {
45     TermPARSER_SIGNnone = 0,
46     TermPARSER_SIGNnegative,
47     TermPARSER_SIGNpositive
48 } TermParserSign;
49
50 #define GetInputChar(context)           ((context)->inputChar)
51 #define GetWorkingNum(context)          ((context)->workingNum)
52 #define GetWorkingNumIsDefault(context) ((context)->workingNumIsDefault)
53 #define GetSign(context)                ((context)->sign)
54 #define GetParm(context, i)             ((context)->parms[i])
55
56 #define SetWorkingNum(context, value)   (context)->workingNum = (value)
57 #define SetWorkingNumIsDefault(context, value) \
58                                         (context)->workingNumIsDefault = (value)
59 #define SetSign(context, value)         (context)->sign = (value)
60 #define SetParm(context, i, value)      ((context)->parms[i]) = (value)
61
62 /*
63 **  seq - parser state machine transition table
64 */
65
66 typedef struct _StateEntryRec
67 {
68     unsigned char   lower;          /* lower end of character range      */
69     unsigned char   upper;          /* upper end of character range      */
70     StateTable      nextState;      /* next state to enter               */
71     void            (*action)();    /* index to next runtime routine     */
72 } StateEntryRec, *StateEntry;
73
74 typedef struct _StateTableRec
75 {
76     Boolean         startState;     /* is this a start state?            */
77     StateEntry      stateEntry;     /* state entry table for state       */
78     StateEntry      statePreParseEntry;
79                                     /* pre-parse state entry table       */
80 } StateTableRec;
81
82 /* 
83 ** Maximum length of a softkey definition.
84 */
85 #define STR_SIZE 256
86
87 typedef struct _stringParameter
88 {
89     unsigned char   str[STR_SIZE + 1];   /* buffer for string */
90     unsigned char   length;              /* length of str     */
91 } stringParameter;
92
93 /*
94 ** states in escape sequence parsing
95 */
96 typedef enum _parseState
97 {
98     START,          /* initial state                */
99     ESCAPE,         /* saw an escape                */
100     AMP,            /* saw an escape &              */
101     AMP_A,          /* saw an escape & a            */
102     AMP_A_SIGN,     /* saw an ^[&a- or ^[&a+        */
103     AMP_A_NUM,      /* saw an escape & a num        */
104     AMP_D,          /* saw an escape & d            */
105     AMP_F,          /* saw an escape & f            */
106     AMP_F_NUM,      /* saw an escape & f num        */
107     AMP_F_MIN,      /* saw an escape & f -          */
108     AMP_F_MIN_NUM,  /* saw an escape & f - num      */
109     AMP_F_STR,      /* saw an escape & f string     */
110     AMP_J,          /* saw an escape & j            */
111     AMP_J_NUM,      /* saw an escape & j num        */
112     AMP_J_NUM_L,    /* saw an escape & j num L      */
113     AMP_J_NUM_D,        
114     AMP_K,          /* saw an escape & k            */
115     AMP_K_NUM,      /* saw an escape & k [0-9]*     */
116     AMP_R,          /* saw an escape & r            */
117     AMP_R_NUM,      /* saw an escape & r num        */
118     AMP_S,          /* saw an escape & s            */
119     AMP_S_0,        /* saw an escape & s 0          */
120     AMP_S_1,        /* saw an escape & s 1          */
121     LPAREN,         /* saw an escape (              */
122     RPAREN,         /* saw an escape )              */
123     ASTERISK,       /* saw an escape *              */
124     ASTERISK_D,     /* saw an escape * d            */
125     ASTERISK_S,     /* saw an escape * s            */
126     AMP_P,
127     AMP_P_NUM,
128     AMP_P_NUM_W,
129     AMP_P_W,
130     ERROR,          /* error in escape sequence     */
131     ASTERISK_X,     /* saw an escape * x            */
132     ASTERISK_Y,     /* saw an escape * y            */
133     ASTERISK_Y_EXC, /* saw an escape * y !          */
134     AMP_V,          /* saw an escape & v            */
135     AMP_V_ZERO,     /* saw an escape & v 0          */
136     AMP_V_ONE,      /* saw an escape & v 1          */
137     AMP_V_2_7,      /* saw an escape & v [2-7]      */
138     AMP_V_DEC,      /* saw an escape & v .          */
139     AMP_X,          /* saw an escape & x            */
140     AMP_X_0,        /* saw an escape & x 0          */
141     AMP_X_1,        /* saw an escape & x 1          */
142     KJCODE          /* Kanji State  1/17/86 NY      */
143 } parseState;
144
145 #define NUM_PARMS  20
146
147 typedef struct _ParserContextRec
148 {
149     /*
150     ** escape sequence parsing variables
151     */
152     StateTable       stateTable;    /* state table of the current state  */
153     unsigned char    inputChar[MB_LEN_MAX];
154                                     /* character being parsed            */
155     short            inputCharLen;  /* length of the above               */
156     parseState       stateName;     /* enum type with current state      */
157     int              workingNum;    /* working number for entering parm  */
158     Boolean          workingNumIsDefault;
159                                     /* true if working num not touched   */
160     TermParserSign   sign;          /* for numeric sign                  */
161     int              parms[NUM_PARMS];   /* parameters                   */
162     stringParameter  stringParms[2];
163 } ParserContextRec;
164
165 /* 
166 ** Parser support routines.
167 */
168 extern void _DtTermPrimParserSaveSign ( Widget w);
169 extern void _DtTermPrimParserNextState(Widget w);
170 extern void _DtTermPrimParserClearParm(Widget w);
171 extern void _DtTermPrimParserClrStrParm(Widget w);
172 extern void _DtTermPrimParserEnterNum(Widget w);
173 extern void _enterMinNum(Widget w);
174 extern void _DtTermPrimParserParm1(Widget w);
175 extern void _DtTermPrimParserParm2(Widget w);
176 extern void _DtTermPrimParserParm3(Widget w);
177 extern void _DtTermPrimParserParm4(Widget w);
178
179 #ifdef  __cplusplus
180 } /* close scope of 'extern "C"'... */
181 #endif  /* __cplusplus */
182
183 #endif /* _Dt_TermPrimParserP_h */
184 /* DON'T ADD ANYTHING AFTER THIS #endif... */