Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtksh / exksh.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 /* $XConsortium: exksh.h /main/3 1995/11/01 15:54:01 rswiston $ */
24 /* "%W%" */
25
26 /*      Copyright (c) 1991, 1992 UNIX System Laboratories, Inc. */
27 /*      All Rights Reserved     */
28
29 /*      THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF    */
30 /*      UNIX System Laboratories, Inc.                  */
31 /*      The copyright notice above does not evidence any       */
32 /*      actual or intended publication of such source code.    */
33
34 #ifndef _Dtksh_exksh_h
35 #define _Dtksh_exksh_h
36
37 #include <sys/types.h>
38
39 #ifndef SYMS_ONLY
40
41 #define SH_FAIL 1
42 #define SH_SUCC 0
43
44 #define PRSYMBOLIC                      1
45 #define PRMIXED                         2
46 #define PRDECIMAL                       4
47 #define PRHEX                           8
48 #define PRMIXED_SYMBOLIC        16
49 #define PRNAMES                         32
50
51 #define UPP(CH) (islower(CH) ? toupper(CH) : (CH))
52 #define C_PAIR(STR, CH1, CH2) (((STR)[0] == (CH1)) && ((STR)[1] == (CH2)))
53 #define XK_USAGE(X) return(xk_usage(X), SH_FAIL);
54
55 /* In the future, this will require following pointers, unless we
56 ** can always trace back types to typedefs.  For example, unsigned long is
57 ** a typedef, but it is simple because it is really just a long.
58 */
59 #define IS_SIMPLE(TBL) ((TBL)->flags & F_SIMPLE)
60
61 #ifndef N_DEFAULT /* From name.h */
62 /* Stolen out of include/name.h, the problems of including things
63 ** out of the ksh code is major.  Hence, the copy rather than the
64 ** include.
65 */
66
67 struct Bfunction {
68         long    (*f_vp)();              /* value function */
69         long    (*f_ap)();              /* assignment function */
70 };
71
72 #endif /* N_DEFAULT: From name.h */
73
74 #define ALLDATA         INT_MAX
75
76 #define BIGBUFSIZ (10 * BUFSIZ)
77
78 #define IN_BAND         1
79 #define OUT_BAND        2
80 #define NEW_PRIM        4
81
82 struct fd {
83         int vfd;
84         int flags;
85         char mode;
86         struct strbuf *lastrcv;
87         int rcvcount;
88         int sndcount;
89         int uflags;
90 };
91
92 struct vfd {
93         int fd;
94 };
95
96 extern struct fd *Fds;
97 extern struct vfd *Vfds;
98
99 struct libdesc {
100         char *name;
101         void *handle;
102 };
103 struct libstruct {
104         char *prefix;
105         int nlibs;
106         struct libdesc *libs;
107 };
108
109
110 #ifndef OSI_LIB_CODE
111 #define PARPEEK(b, s) (((b)[0][0] == s[0]) ? 1 :  0 )
112 #define PAREXPECT(b, s) (((b)[0][0] == s[0]) ? 0 : -1 )
113 #define OFFSET(T, M) ((int)(&((T)NULL)->M))
114
115 typedef char *string_t;
116
117 /*
118  * Structures for driving generic print/parse/copy/free routines
119  */
120
121 typedef struct memtbl {
122         char *name;     /* name of the member */
123         char *tname;    /* name of the typedef */
124         char  kind;     /* kind of member, see #defines below */
125         char  flags;    /* flags for member, see #defines below */
126         short  tbl;     /* -1 or index into ASL_allmems[] array */
127         short  ptr;     /* number of "*" in front of member */
128         short  subscr;  /* 0 if no subscript, else max number of elems */
129         short  delim;   /* 0 if no length delim, +1 if next field, -1 if prev */
130         short  id;      /* Id of the ASL in which this def is made */
131         short  offset;  /* offset into the C structure */
132         short  size;    /* size of this member, for easy malloc'ing */
133         long  choice;   /* def of tag indicating field chosen for unions */
134 } memtbl_t;
135
136 struct envsymbols {
137         char *name;
138         int  id;
139         int  (*parsefunc)();
140         int  (*printfunc)();
141         char *tname;
142         int  intlike;
143         int  string;
144         int  topptr;
145         int  valbits;
146         struct {
147                 char *name;
148                 unsigned long val;
149                 int  cover;
150         } vals[64];
151 }; 
152
153
154 /*
155  * Definitions for the kind field of the above structure 
156  */
157
158 #define K_CHAR          (0)     /* char or unchar */
159 #define K_SHORT         (1)     /* short or ushort */
160 #define K_INT           (2)     /* int or uint */
161 #define K_LONG          (3)     /* long, unsigned long, PRIM, etc. */
162 #define K_STRING        (4)     /* char * or char [] */
163 #define K_OBJID         (5)     /* objid_t *, note the star is included */
164 #define K_ANY           (6)     /* any_t */
165 #define K_STRUCT        (7)     /* struct { } */
166 #define K_UNION         (8)     /* union { } */
167 #define K_TYPEDEF       (9)     /* typedef */
168 #define K_DSHORT        (10)    /* short delimiter */
169 #define K_DINT  (11)    /* int delimiter */
170 #define K_DLONG (12)    /* long delimiter */
171
172 /*
173  * Definitions for the flags field of the above structure, bitmask
174  */
175
176 #define F_SIMPLE                (1)     /* simple, flat type */
177 #define F_FIELD                 (2) /* memtbl is a field of a structure, not the
178                                                                 name of a type */
179 #define F_TBL_IS_PTR    (4) /* tbl field is pointer, not number; */
180 #define F_TYPE_IS_PTR   (8) /* type is built-in, but is already a pointer, like K_STRING */
181
182 #define SUCCESS 0
183 #define FAIL    (-1)
184
185 #define TRUE    1
186 #define FALSE   0
187
188 /* The following macro, RIF, stands for Return If Fail.  Practically
189  * every line of encode/decode functions need to do this, so it aids
190  * in readability.
191  */
192 #define RIF(X) do { if ((X) == FAIL) return(FAIL); } while(0)
193
194 #endif /* not OSI_LIB_CODE */
195
196 #if !defined(OSI_LIB_CODE) || defined(NEED_SYMLIST)
197 struct symlist {
198         struct memtbl tbl;
199         int isflag;
200         int nsyms;
201         struct symarray *syms;
202 };
203 #endif
204
205 #define DYNMEM_ID               (1)
206 #define BASE_ID                 (2)
207
208 #define ALTPUTS(STR) puts(STR)
209
210 #ifndef NULL
211 #define NULL    (0)
212 #endif
213
214 #ifdef SPRINTF_RET_LEN
215 #define lsprintf sprintf
216 #endif
217
218 #define MAX_CALL_ARGS 15
219
220 #define TREAT_SIMPLE(TBL) ((TBL)->ptr || IS_SIMPLE(TBL))
221
222 #ifdef EXKSH_INCLUDED
223 #define XK_PRINT(ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7) (_Delim = 0, xk_print(ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7))
224 #define XK_PARSE(ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7) (_Delim = 0, xk_parse(ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7))
225 #define XK_FREE(ARG1, ARG2, ARG3, ARG4, ARG5) (_Delim = 0, xk_free(ARG1, ARG2, ARG3, ARG4, ARG5))
226 #endif
227
228 #define NOHASH          1
229 #define TYPEONLY        2
230 #define STRUCTONLY      4
231
232 #endif /* not SYMS_ONLY */
233
234 struct symarray {
235         const char *str;
236         unsigned long addr;
237 };
238
239 #endif /* _Dtksh_exksh_h */
240 /* DON'T ADD ANYTHING AFTER THIS #endif */