Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtksh / ksh93 / src / cmd / ksh93 / include / argnod.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: argnod.h /main/3 1995/11/01 16:38:43 rswiston $ */
24 /***************************************************************
25 *                                                              *
26 *                      AT&T - PROPRIETARY                      *
27 *                                                              *
28 *        THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF        *
29 *                    AT&T BELL LABORATORIES                    *
30 *         AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN         *
31 *            ACCORDANCE WITH APPLICABLE AGREEMENTS             *
32 *                                                              *
33 *                Copyright (c) 1995 AT&T Corp.                 *
34 *              Unpublished & Not for Publication               *
35 *                     All Rights Reserved                      *
36 *                                                              *
37 *       The copyright notice above does not evidence any       *
38 *      actual or intended publication of such source code      *
39 *                                                              *
40 *               This software was created by the               *
41 *           Advanced Software Technology Department            *
42 *                    AT&T Bell Laboratories                    *
43 *                                                              *
44 *               For further information contact                *
45 *                    {research,attmail}!dgk                    *
46 *                                                              *
47 ***************************************************************/
48
49 /* : : generated by proto : : */
50                   
51 #ifndef ARG_RAW
52 #if !defined(__PROTO__)
53 #if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
54 #if defined(__cplusplus)
55 #define __MANGLE__      "C"
56 #else
57 #define __MANGLE__
58 #endif
59 #define __STDARG__
60 #define __PROTO__(x)    x
61 #define __OTORP__(x)
62 #define __PARAM__(n,o)  n
63 #if !defined(__STDC__) && !defined(__cplusplus)
64 #if !defined(c_plusplus)
65 #define const
66 #endif
67 #define signed
68 #define void            int
69 #define volatile
70 #define __V_            char
71 #else
72 #define __V_            void
73 #endif
74 #else
75 #define __PROTO__(x)    ()
76 #define __OTORP__(x)    x
77 #define __PARAM__(n,o)  o
78 #define __MANGLE__
79 #define __V_            char
80 #define const
81 #define signed
82 #define void            int
83 #define volatile
84 #endif
85 #if defined(__cplusplus) || defined(c_plusplus)
86 #define __VARARG__      ...
87 #else
88 #define __VARARG__
89 #endif
90 #if defined(__STDARG__)
91 #define __VA_START__(p,a)       va_start(p,a)
92 #else
93 #define __VA_START__(p,a)       va_start(p)
94 #endif
95 #endif
96
97 /*
98  *      struct to hold a word argument
99  *      Written by David Korn
100  *
101  */
102
103 #include        <stak.h>
104
105 struct ionod
106 {
107         unsigned        iofile;
108         char            *ioname;
109         struct ionod    *ionxt;
110         struct ionod    *iolst;
111         char            *iodelim;
112         off_t           iooffset;
113         long            iosize;
114 };
115
116 struct comnod
117 {
118         int             comtyp;
119         struct ionod    *comio;
120         struct argnod   *comarg;
121         struct argnod   *comset;
122         __V_            *comnamp;
123         int             comline;
124 };
125
126 #define COMBITS         4
127 #define COMMSK          ((1<<COMBITS)-1)
128 #define COMSCAN         (01<<COMBITS)
129
130 struct slnod    /* struct for link list of stacks */
131 {
132         struct slnod    *slnext;
133         struct slnod    *slchild;
134         Stak_t          *slptr;
135 };
136
137 /*
138  * This struct is use to hold $* lists and arrays
139  */
140
141 struct dolnod
142 {
143         short           dolrefcnt;      /* reference count */
144         short           dolmax;         /* size of dolval array */
145         short           dolnum;         /* number of elements */
146         short           dolbot;         /* current first element */
147         struct dolnod   *dolnxt;        /* used when list are chained */
148         char            *dolval[1];     /* array of value pointers */
149 };
150
151 /*
152  * This struct is used to hold word arguments of variable size during
153  * parsing and during expansion.  The flags indicate what processing
154  * is required on the argument.
155  */
156
157 struct argnod
158 {
159         union
160         {
161                 struct argnod   *ap;
162                 char            *cp;
163         }               argnxt;
164         union
165         {
166                 struct argnod   *ap;
167                 int             len;
168         }               argchn;
169         unsigned char   argflag;
170         char            argval[4];
171 };
172
173
174
175 /* The following should evaluate to the offset of argval in argnod */
176 extern __MANGLE__ int errno;    /* could be any l-value */
177 #define ARGVAL  ((unsigned)(((struct argnod*)(&errno))->argval-(char*)(&errno)))
178 #define sh_argstr(ap)   ((ap)->argflag&ARG_RAW?sh_fmtq((ap)->argval):(ap)->argval)
179 #ifdef SHOPT_VPIX
180 #   define ARG_SPARE 2
181 #else
182 #   define ARG_SPARE 1
183 #endif /* SHOPT_VPIX */
184
185
186 /* legal argument flags */
187 #define ARG_RAW         0x1     /* string needs no processing */
188 #define ARG_MAKE        0x2     /* bit set during argument expansion */
189 #define ARG_MAC         0x4     /* string needs macro expansion */
190 #define ARG_EXP         0x8     /* string needs file expansion */
191 #define ARG_ASSIGN      0x10    /* argument is an assignment */
192 #define ARG_QUOTED      0x20    /* word contained quote characters */
193 #define ARG_MESSAGE     0x40    /* contains international string */
194 #define ARG_APPEND      0x80    /* for += assignment */
195
196 extern __MANGLE__ char          **sh_argbuild __PROTO__((int*,const struct comnod*));
197 extern __MANGLE__ struct dolnod *sh_argcreate __PROTO__((char*[]));
198 extern __MANGLE__ char          *sh_argdolminus __PROTO__((void));
199 extern __MANGLE__ struct dolnod *sh_argfree __PROTO__((struct dolnod*,int));
200 extern __MANGLE__ struct dolnod *sh_argnew __PROTO__((char*[],struct dolnod**));
201 extern __MANGLE__ int           sh_argopts __PROTO__((int,char*[]));
202 extern __MANGLE__ void          sh_argreset __PROTO__((struct dolnod*,struct dolnod*));
203 extern __MANGLE__ void          sh_argset __PROTO__((char*[]));
204 extern __MANGLE__ struct dolnod *sh_arguse __PROTO__((void));
205
206 extern __MANGLE__ const char    e_heading[];
207 extern __MANGLE__ const char    e_off[];
208 extern __MANGLE__ const char    e_on[];
209 extern __MANGLE__ const char    e_sptbnl[];
210 extern __MANGLE__ const char    e_subst[];
211 extern __MANGLE__ const char    e_option[];
212 extern __MANGLE__ const char    e_argexp[];
213 extern __MANGLE__ const char    e_exec[];
214 extern __MANGLE__ const char    e_devfdNN[];
215
216 #endif /* ARG_RAW */