Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtksh / ksh93 / src / cmd / ksh93 / include / defs.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: defs.h /main/3 1995/11/01 16:39:16 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 #if !defined(__PROTO__)
52 #if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
53 #if defined(__cplusplus)
54 #define __MANGLE__      "C"
55 #else
56 #define __MANGLE__
57 #endif
58 #define __STDARG__
59 #define __PROTO__(x)    x
60 #define __OTORP__(x)
61 #define __PARAM__(n,o)  n
62 #if !defined(__STDC__) && !defined(__cplusplus)
63 #if !defined(c_plusplus)
64 #define const
65 #endif
66 #define signed
67 #define void            int
68 #define volatile
69 #define __V_            char
70 #else
71 #define __V_            void
72 #endif
73 #else
74 #define __PROTO__(x)    ()
75 #define __OTORP__(x)    x
76 #define __PARAM__(n,o)  o
77 #define __MANGLE__
78 #define __V_            char
79 #define const
80 #define signed
81 #define void            int
82 #define volatile
83 #endif
84 #if defined(__cplusplus) || defined(c_plusplus)
85 #define __VARARG__      ...
86 #else
87 #define __VARARG__
88 #endif
89 #if defined(__STDARG__)
90 #define __VA_START__(p,a)       va_start(p,a)
91 #else
92 #define __VA_START__(p,a)       va_start(p)
93 #endif
94 #endif
95 #define mount   _AST__mount
96
97 #include        <ast.h>
98 #include        <sfio.h>
99 #include        <error.h>
100 #include        "FEATURE/options"
101 #include        <history.h>
102 #include        "fault.h"
103 #include        "argnod.h"
104
105 struct sh_scoped
106 {
107         struct slnod    *staklist;      /* link list of function stacks */
108         int             states;
109         int             breakcnt;
110         int             execbrk;
111         int             loopcnt;
112         int             firstline;
113         int             dolc;
114         char            **dolv;
115         long            optindex;
116         long            optnum;
117         short           optchar;
118         short           opterror;
119         char            *cmdname;
120         int             ioset;
121         short           trapmax;
122         char            *trap[SH_DEBUGTRAP+1];
123         char            **trapcom;
124         char            **otrapcom;
125         __V_            *timetrap;
126         __V_            *par_tree;      /* for calling function */
127         struct sh_scoped *prevst;       /* pointer to previous state */
128 };
129
130 struct limits
131 {
132         int             open_max;       /* maximum number of file descriptors */
133         int             clk_tck;        /* number of ticks per second */
134         int             child_max;      /* maxumum number of children */
135         int             ngroups_max;    /* maximum number of process groups */
136         unsigned char   posix_version;  /* posix version number */
137         unsigned char   posix_jobcontrol;/* non-zero for job control systems */
138         unsigned char   fs3d;           /* non-zero for 3-d file system */
139 };
140
141 #define _SH_PRIVATE \
142         struct sh_scoped st;            /* scoped information */ \
143         struct limits   lim;            /* run time limits */ \
144         Hashtab_t       *track_tree;    /* for tracked aliases*/ \
145         Hashtab_t       *bltin_tree;    /* for builtin commands */ \
146         Hashtab_t       *var_base;      /* global level variables */ \
147         History_t       *hist_ptr;      /* history file pointer */ \
148         Sfio_t          *outpool;       /* ouput stream pool */ \
149         long            timeout;        /* read timeout */ \
150         long            tmout;          /* value for TMOUT */ \
151         int             curenv;         /* current subshell number */ \
152         int             jobenv;         /* subshell number for jobs */ \
153         int             nextprompt;     /* next prompt is PS<nextprompt> */ \
154         Namval_t        *bltin_cmds;    /* pointer to built-in commands */ \
155         Namval_t        *posix_fun;     /* points to last name() function */ \
156         int             infd;           /* input file descriptor */ \
157         char            *outbuff;       /* pointer to output buffer */ \
158         char            *errbuff;       /* pointer to stderr buffer */ \
159         char            *prompt;        /* pointer to prompt string */ \
160         char            *shname;        /* shell name */ \
161         char            *comdiv;        /* points to sh -c argument */ \
162         char            *prefix;        /* prefix for compound assignment */ \
163         sigjmp_buf      *jmplist;       /* longjmp return stack */ \
164         char            **sigmsg;       /* points to signal messages */ \
165         int             oldexit; \
166         uid_t           userid,euserid; /* real and effective user id */ \
167         gid_t           groupid,egroupid;/* real and effective group id */ \
168         pid_t           pid;            /* process id of shell */ \
169         pid_t           bckpid;         /* background process id */ \
170         pid_t           cpid; \
171         long            ppid;           /* parent process id of shell */ \
172         int             topfd; \
173         int             sigmax;         /* maximum number of signals */ \
174         unsigned char   *sigflag;       /* pointer to signal states */ \
175         char            intrap; \
176         char            login_sh; \
177         char            lastbase; \
178         char            universe; \
179         char            forked; \
180         char            binscript;      \
181         char            used_pos;       /* used postional parameter */\
182         unsigned char   lastsig;        /* last signal received */ \
183         char            *readscript;    /* set before reading a script */ \
184         int             *inpipe;        /* input pipe pointer */ \
185         int             *outpipe;       /* output pipe pointer */ \
186         int             cpipe[2]; \
187         int             coutpipe; \
188         struct argnod   *envlist; \
189         struct dolnod   *arglist; \
190         int             fn_depth; \
191         int             dot_depth; \
192         long            nforks; \
193         char            ifstable[256];
194
195 #include        <shell.h>
196
197
198 /* error exits from various parts of shell */
199 #define NIL(type)       ((type)0)
200
201 #define new_of(type,x)  ((type*)malloc((unsigned)sizeof(type)+(x)))
202
203 #define exitset()       (sh.savexit=sh.exitval)
204
205
206 /* states */
207 /* low numbered states are same as options */
208 #define SH_NOFORK       0x1     /* set when fork not necessary, not a state */
209 #define SH_COMPLETE     0x1     /* set for command completion */
210 #define SH_TTYWAIT      0x40    /* waiting for keyboard input */ 
211 #define SH_FORKED       0x80    /* set when process has been forked */
212 #define SH_PROFILE      0x100   /* set when processing profiles */
213 #define SH_NOALIAS      0x200   /* do not expand non-exported aliases */
214 #define SH_NOTRACK      0x400   /* set to disable sftrack() function */
215 #define SH_STOPOK       0x800   /* set for stopable builtins */
216 #define SH_GRACE        0x1000  /* set for timeout grace period */
217 #define SH_TIMING       0x2000  /* set while timing pipelines */
218 #define SH_DEFPATH      0x4000  /* set when using default path */
219 #define SH_INIT         0x8000  /* set when initializing the shell */
220
221 extern __MANGLE__ Namval_t              *sh_assignok __PROTO__((Namval_t*,int));
222 extern __MANGLE__ int           sh_echolist __PROTO__((Sfio_t*, int, char**));
223 extern __MANGLE__ struct argnod *sh_endword __PROTO__((int));
224 extern __MANGLE__ char          **sh_envgen __PROTO__((void));
225 extern __MANGLE__ void          sh_envnolocal __PROTO__((Namval_t*));
226 extern __MANGLE__ char          *sh_etos __PROTO__((double,int));
227 extern __MANGLE__ char          *sh_ftos __PROTO__((double,int));
228 extern __MANGLE__ double                sh_arith __PROTO__((const char*));
229 extern __MANGLE__ pid_t                 sh_fork __PROTO__((int,int*));
230 extern __MANGLE__ char          *sh_mactrim __PROTO__((char*,int));
231 extern __MANGLE__ int           sh_macexpand __PROTO__((struct argnod*,struct argnod**));
232 extern __MANGLE__ void          sh_machere __PROTO__((Sfio_t*, Sfio_t*, char*));
233 extern __MANGLE__ char          *sh_mactry __PROTO__((char*));
234 extern __MANGLE__ int           sh_readline __PROTO__((char**,int,int,long));
235 extern __MANGLE__ void          sh_reinit __PROTO__((char*[]));
236 extern __MANGLE__ Sfio_t                *sh_sfeval __PROTO__((char*[]));
237 extern __MANGLE__ void          sh_subtmpfile __PROTO__((void));
238 extern __MANGLE__ Sfio_t                *sh_subshell __PROTO__((union anynode*, int, int));
239 extern __MANGLE__ char          *sh_substitute __PROTO__((const char*,const char*,char*));
240 extern __MANGLE__ int           sh_tdump __PROTO__((Sfio_t*, const union anynode*));
241 extern __MANGLE__ int           sh_trace __PROTO__((char*[],int));
242 extern __MANGLE__ union anynode *sh_trestore __PROTO__((Sfio_t*));
243 extern __MANGLE__ void          sh_trim __PROTO__((char*));
244 extern __MANGLE__ void          sh_userinit __PROTO__((void));
245 extern __MANGLE__ int           sh_whence __PROTO__((char**,int));
246
247
248 #define sh_isstate(x)   (sh.st.states&((int)(x)))
249 #define sh_onstate(x)   (sh.st.states |= ((int)(x)))
250 #define sh_setstate(x)  (sh.st.states = ((int)(x)))
251 #define sh_offstate(x)  (sh.st.states &= ~((int)(x)))
252
253 extern __MANGLE__ time_t                sh_mailchk;