w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

sh.h
Go to the documentation of this file.
1 /*
2  * MS-DOS SHELL - Header File
3  *
4  * MS-DOS SHELL - Copyright (c) 1990,4 Data Logic Limited and Charles Forsyth
5  *
6  * This code is based on (in part) the shell program written by Charles
7  * Forsyth and the subsequence modifications made by Simon J. Gerraty (for
8  * his Public Domain Korn Shell) and is subject to the following copyright
9  * restrictions:
10  *
11  * 1. Redistribution and use in source and binary forms are permitted
12  * provided that the above copyright notice is duplicated in the
13  * source form and the copyright notice in file sh6.c is displayed
14  * on entry to the program.
15  *
16  * 2. The sources (or parts thereof) or objects generated from the sources
17  * (or parts of sources) cannot be sold under any circumstances.
18  *
19  * $Header: /usr/users/istewart/shell/sh2.3/Release/RCS/sh.h,v 2.16 1994/08/25 20:58:47 istewart Exp $
20  *
21  * $Log: sh.h,v $
22  * Revision 2.16 1994/08/25 20:58:47 istewart
23  * MS Shell 2.3 Release
24  *
25  * Revision 2.15 1994/02/23 09:23:38 istewart
26  * Beta 233 updates
27  *
28  * Revision 2.14 1994/02/01 10:25:20 istewart
29  * Release 2.3 Beta 2, including first NT port
30  *
31  * Revision 2.13 1994/01/11 17:55:25 istewart
32  * Release 2.3 Beta 0 patches
33  *
34  * Revision 2.12 1993/11/09 10:39:49 istewart
35  * Beta 226 checking
36  *
37  * Revision 2.11 1993/08/25 16:03:57 istewart
38  * Beta 225 - see Notes file
39  *
40  * Revision 2.10 1993/07/02 10:25:53 istewart
41  * 224 Beta fixes
42  *
43  * Revision 2.9 1993/06/14 11:00:54 istewart
44  * More changes for 223 beta
45  *
46  * Revision 2.8 1993/06/02 09:58:12 istewart
47  * Shell 223 Beta Release - see Notes file
48  *
49  * Revision 2.7 1993/02/16 16:04:22 istewart
50  * Beta 2.22 Release
51  *
52  * Revision 2.6 1993/01/26 18:35:09 istewart
53  * Release 2.2 beta 0
54  *
55  * Revision 2.5 1992/12/14 10:54:56 istewart
56  * BETA 215 Fixes and 2.1 Release
57  *
58  * Revision 2.4 1992/11/06 10:03:44 istewart
59  * 214 Beta test updates
60  *
61  * Revision 2.3 1992/09/03 18:54:45 istewart
62  * Beta 213 Updates
63  *
64  * Revision 2.2 1992/07/16 14:33:34 istewart
65  * Beta 212 Baseline
66  *
67  * Revision 2.1 1992/07/14 08:58:59 istewart
68  * 211 Beta updates
69  *
70  * Revision 2.0 1992/04/13 17:39:40 Ian_Stewartson
71  * MS-Shell 2.0 Baseline release
72  *
73  */
74 
75 /*
76  * Operating System Definitions
77  */
78 #if _MSC_VER > 1599
79 #pragma warning(disable : 4996)
80 #endif
81 
82 #define OS_DOS 1 /* MSDOS */
83 #define OS_OS2 2 /* OS/2 */
84 #define OS_NT 3 /* Windows NT */
85 #define OS_UNIX 4 /* A UNIX system */
86 
87 #define OS_16 1 /* 16-bit O/S */
88 #define OS_32 2 /* 32-bit O/S */
89 
90 #if defined (__OS2__)
91 # define OS_TYPE OS_OS2
92 # define OS_SIZE OS_32
93 #elif defined (__32BIT__) && defined (__EMX__)
94 # if defined (EMX_DOS)
95 # define OS_TYPE OS_DOS
96 # else
97 # define OS_TYPE OS_OS2
98 # endif
99 # define OS_SIZE OS_32
100 #elif defined (OS2)
101 # define OS_TYPE OS_OS2
102 # define OS_SIZE OS_16
103 #elif defined (WIN32)
104 # define OS_TYPE OS_NT
105 # define OS_SIZE OS_32
106 #elif defined (__386__)
107 # define OS_TYPE OS_DOS
108 # define OS_SIZE OS_32
109 #elif defined (unix)
110 # define OS_TYPE OS_UNIX
111 # define OS_SIZE OS_32
112 #else
113 # define OS_TYPE OS_DOS
114 # define OS_SIZE OS_16
115 # define OS_SWAPPING 1
116 #endif
117 
118 #if (OS_SIZE == OS_32)
119 # define F_LOCAL
120 #else
121 # define F_LOCAL near
122 #endif
123 
124 /*
125  * Get the system include files
126  */
127 
128 #if (OS_TYPE == OS_OS2)
129 
130 /*
131  * OS/2 Stuff. Define the following so we get the right defs.
132  */
133 
134 # define INCL_DOSDEVICES
135 # define INCL_DOSERRORS
136 # define INCL_DOSEXCEPTIONS
137 # define INCL_DOSFILEMGR
138 # define INCL_DOSMEMMGR
139 # define INCL_DOSMISC
140 # define INCL_DOSMODULEMGR
141 # define INCL_DOSPROCESS
142 # define INCL_DOSQUEUES
143 # define INCL_DOSSEMAPHORES
144 # define INCL_DOSSESMGR
145 # define INCL_DOSSIGNALS
146 # define INCL_KBD
147 # define INCL_VIO
148 # define INCL_WINSWITCHLIST
149 
150 # include <os2.h>
151 # include <bseerr.h>
152 
153 # if (OS_SIZE == OS_32)
154 # include <bsedev.h>
155 
156 /* Some compilers miss the 1.x to 2.x conversion macros */
157 
158 # ifndef DosCwait
159 # define DosCwait DosWaitChild
160 # endif
161 
162 # ifndef DosQCurDisk
163 # define DosQCurDisk DosQueryCurrentDisk
164 # endif
165 
166 # ifndef DosQFSAttach
167 # define DosQFSAttach DosQueryFSAttach
168 # endif
169 
170 # ifndef DosQFSInfo
171 # define DosQFSInfo DosQueryFSInfo
172 # endif
173 
174 # ifndef DosQHandType
175 # define DosQHandType DosQueryHType
176 # endif
177 
178 # ifndef DosQVerify
179 # define DosQVerify DosQueryVerify
180 # endif
181 
182 # ifndef DosSelectDisk
183 # define DosSelectDisk DosSetDefaultDisk
184 # endif
185 
186 # ifndef DosSetFHandState
187 # define DosSetFHandState DosSetFHState
188 # endif
189 
190 # ifndef DosQFileInfo
191 # define DosQFileInfo DosQueryFileInfo
192 # endif
193 
194 # endif
195 
196 #elif (OS_TYPE == OS_NT)
197 
198 /*
199  * Windows NT Stuff. Define the following so we don't get tons of extra stuff
200  * when we include windows.h
201  */
202 
203 # define NOGDICAPMASKS
204 # define NOVIRTUALKEYCODES
205 # define NOWINMESSAGES
206 # define NOWINSTYLES
207 # define NOSYSMETRICS
208 # define NOMENUS
209 # define NOICONS
210 # define NOKEYSTATES
211 # define NOSYSCOMMANDS
212 # define NORASTEROPS
213 # define NOSHOWWINDOW
214 # define OEMRESOURCE
215 # define NOATOM
216 # define NOCLIPBOARD
217 # define NOCOLOR
218 # define NOCTLMGR
219 # define NODRAWTEXT
220 # define NOGDI
221 /* # define NOKERNEL */
222 /* # define NOUSER */
223 # define NONLS
224 # define NOMB
225 # define NOMEMMGR
226 # define NOMETAFILE
227 # define NOMINMAX
228 # define NOMSG
229 # define NOOPENFILE
230 # define NOSCROLL
231 # define NOSERVICE
232 # define NOSOUND
233 # define NOTEXTMETRIC
234 # define NOWH
235 # define NOWINOFFSETS
236 # define NOCOMM
237 # define NOKANJI
238 # define NOHELP
239 # define NOPROFILER
240 # define NODEFERWINDOWPOS
241 
242 /*
243  * We're not using Microsoft's "extensions" to C for Structured Exception
244  * Handling (SEH).
245  */
246 
247 # undef try
248 # undef except
249 # undef finally
250 # undef leave
251 
252 # include <windows.h>
253 
254 #elif (OS_TYPE == OS_DOS)
255 
256 /* Finally the DOS stuff */
257 
258 # include <dos.h>
259 # if defined (__32BIT__) && defined (__EMX__)
260 
261 # else
262 # include <bios.h>
263 # endif
264 
265 /* Add bool definitions and others for UNIX */
266 
267 #elif (OS_TYPE == OS_UNIX)
268 typedef pid_t PID;
269 #endif
270 
271 #if defined (__EMX__) && (OS_TYPE == OS_OS2)
272 typedef PID pid_t;
273 #endif
274 
275 #ifndef _BOOL_T_DEFINED
276 typedef unsigned char bool;
277 # define _BOOL_T_DEFINED
278 #endif
279 
280 #ifndef TRUE
281 # define TRUE ((bool)1)
282 #endif
283 
284 #ifndef FALSE
285 # define FALSE ((bool)0)
286 #endif
287 
288 
289 /*
290  * Define number of signals
291  */
292 
293 #ifndef NSIG
294 # define NSIG 10
295 #endif
296 
297 /*
298  * Flags to DosFlagProcess are missing on IBM C Set/2
299  */
300 
301 #ifndef PFLG_A
302 # define PFLG_A 0 /* Process Flag A */
303 #endif
304 
305 #ifndef PFLG_B
306 # define PFLG_B 1 /* Process Flag B */
307 #endif
308 
309 #ifndef PFLG_C
310 # define PFLG_C 2 /* Process Flag C */
311 #endif
312 
313 /*
314  * DosFlagProcess codes
315  */
316 
317 #ifndef FLGP_SUBTREE
318 # define FLGP_SUBTREE 0 /* All sub-tree processes */
319 #endif
320 
321 #ifndef FLGP_PID
322 # define FLGP_PID 1 /* only the process */
323 #endif
324 
325 /*
326  * Spawn Types
327  */
328 
329 #ifndef P_WAIT
330 # define P_WAIT 0
331 #endif
332 
333 #ifndef P_NOWAIT
334 # define P_NOWAIT 1
335 #endif
336 
337 #ifndef P_OVERLAY
338 # define P_OVERLAY 2
339 #endif
340 
341 #ifndef OLD_P_OVERLAY
342 # define OLD_P_OVERLAY 2
343 #endif
344 
345 #ifndef P_NOWAITO
346 # define P_NOWAITO 3
347 #endif
348 
349 #ifndef P_DETACH
350 # define P_DETACH 4
351 #endif
352 
353 /* Wait values */
354 
355 #ifndef WAIT_CHILD
356 # define WAIT_CHILD 0
357 #endif
358 
359 #ifndef WAIT_GRANDCHILD
360 # define WAIT_GRANDCHILD 1
361 #endif
362 /*
363  * Missing errno values
364  */
365 
366 #ifndef EIO
367 # define EIO 105 /* I/O error */
368 #endif
369 
370 #ifndef E2BIG
371 # define E2BIG 107 /* Arg list too long */
372 #endif
373 
374 #ifndef ENOTDIR
375 # define ENOTDIR 120 /* Not a directory */
376 #endif
377 
378 /*
379  * Missing stat definitions
380  */
381 
382 
383 #ifndef S_IFMT
384 # define S_IFMT 0170000
385 #endif
386 
387 #ifndef S_IFDIR
388 # define S_IFDIR 0040000
389 #endif
390 
391 #ifndef S_IFCHR
392 # define S_IFCHR 0020000
393 #endif
394 
395 #ifndef S_IFREG
396 # define S_IFREG 0100000
397 #endif
398 
399 
400 #ifndef S_IFBLK
401 # define S_IFBLK 0x6000 /* block special */
402 #endif
403 
404 #ifndef S_ISDIR
405 # define S_ISDIR(m) ((((m) & S_IFMT) == S_IFDIR))
406 #endif
407 
408 #ifndef S_ISCHR
409 # define S_ISCHR(m) ((((m) & S_IFMT) == S_IFCHR))
410 #endif
411 
412 #ifndef S_ISREG
413 # define S_ISREG(m) ((((m) & S_IFMT) == S_IFREG))
414 #endif
415 
416 #ifndef S_ISBLK
417 # define S_ISBLK(m) ((((m) & S_IFMT) == S_IFBLK))
418 #endif
419 
420 /* GCC has these missing */
421 
422 #ifndef min
423 # define min(a,b) (((a) < (b)) ? (a) : (b))
424 #endif
425 
426 #ifndef O_TEXT
427 # define O_TEXT 0x4000
428 #endif
429 
430 #ifndef O_BINARY
431 # define O_BINARY 0x8000
432 #endif
433 
434 #ifndef O_NOINHERIT
435 # define O_NOINHERIT 0x8000
436 #endif
437 
438 #ifndef CLOCKS_PER_SEC
439 # define CLOCKS_PER_SEC 1000
440 #endif
441 
442 #ifndef max
443 # define max(a,b) (((a) > (b)) ? (a) : (b))
444 #endif
445 
446 /*
447  * File Attributes
448  */
449 
450 #if defined (__TURBOC__)
451 # define OS_FILE_DIRECTORY FA_DIREC
452 # define OS_FILE_HIDDEN FA_HIDDEN
453 # define OS_FILE_SYSTEM FA_SYSTEM
454 # define OS_FILE_NORMAL 0
455 # define OS_FILE_READONLY FA_RDONLY
456 # define OS_FILE_ARCHIVED FA_ARCH
457 
458 /* TurboC puts this in io.h, which we don't include */
459 
460 extern int _Cdecl _chmod (const char *, int, ...);
461 # define OS_GetFileAttributes(a,b) (*b = _chmod ((a), 0))
462 
463 #elif (OS_TYPE == OS_DOS)
464 
465 # define OS_FILE_DIRECTORY _A_SUBDIR
466 # define OS_FILE_HIDDEN _A_HIDDEN
467 # define OS_FILE_SYSTEM _A_SYSTEM
468 # define OS_FILE_NORMAL _A_NORMAL
469 # define OS_FILE_READONLY _A_RDONLY
470 # define OS_FILE_ARCHIVED _A_ARCH
471 
472 # ifndef _A_NORMAL
473 # define _A_NORMAL 0x00 /* No attributes */
474 # endif
475 # ifndef _A_RDONLY
476 # define _A_RDONLY 0x01 /* Read-only */
477 # endif
478 # ifndef _A_HIDDEN
479 # define _A_HIDDEN 0x02 /* Hidden */
480 # endif
481 # ifndef _A_SYSTEM
482 # define _A_SYSTEM 0x04 /* System */
483 # endif
484 # ifndef _A_VOLID
485 # define _A_VOLID 0x08 /* Volume label */
486 # endif
487 # ifndef _A_SUBDIR
488 # define _A_SUBDIR 0x10 /* Directory */
489 # endif
490 # ifndef _A_ARCH
491 # define _A_ARCH 0x20 /* Archive */
492 # endif
493 # ifndef _A_DEVICE
494 # define _A_DEVICE 0x40 /* Device */
495 # endif
496 
497 # define OS_GetFileAttributes(a,b) _dos_getfileattr ((a), (b))
498 
499 #elif (OS_TYPE == OS_OS2)
500 
501 # define OS_FILE_DIRECTORY FILE_DIRECTORY
502 # define OS_FILE_HIDDEN FILE_HIDDEN
503 # define OS_FILE_SYSTEM FILE_SYSTEM
504 # define OS_FILE_NORMAL FILE_NORMAL
505 # define OS_FILE_READONLY FILE_READONLY
506 # define OS_FILE_ARCHIVED FILE_ARCHIVED
507 
508 # if (OS_SIZE == OS_16)
509 # define OS_GetFileAttributes(a,b) DosQFileMode ((a), (b), 0L)
510 # else
511 # define OS_GetFileAttributes(a,b) DosQFileMode ((a), (b))
512 # endif
513 
514 #elif (OS_TYPE == OS_NT)
515 
516 # define OS_FILE_DIRECTORY FILE_ATTRIBUTE_DIRECTORY
517 # define OS_FILE_HIDDEN FILE_ATTRIBUTE_HIDDEN
518 # define OS_FILE_SYSTEM FILE_ATTRIBUTE_SYSTEM
519 # define OS_FILE_NORMAL 0
520 # define OS_FILE_READONLY FILE_ATTRIBUTE_READONLY
521 # define OS_FILE_ARCHIVED FILE_ATTRIBUTE_ARCHIVE
522 
523 # define OS_GetFileAttributes(a,b) DosQFileMode ((a), (b))
524 #endif
525 
526 #define OS_FILE_ATTRIBUTES (OS_FILE_DIRECTORY | OS_FILE_HIDDEN | \
527  OS_FILE_SYSTEM | OS_FILE_NORMAL | \
528  OS_FILE_READONLY | OS_FILE_ARCHIVED)
529 
530 /*
531  * Get major version number
532  */
533 
534 #if (OS_TYPE == OS_OS2)
535 # define OS_VERS_N _osmajor / 10
536 #else
537 # define OS_VERS_N _osmajor
538 #endif
539 
540 extern int BaseOS; /* Underlying OS */
541 
542 #define BASE_OS_DOS 0 /* DOS */
543 #define BASE_OS_WIN 1 /* Windows */
544 #define BASE_OS_OS2 2 /* OS2 */
545 #define BASE_OS_NT 3 /* Windows NT */
546 #define BASE_OS_UNIX 4 /* UNIX */
547 
548 /*
549  * Watcom does something funny in 386 mode with registers and int86
550  */
551 
552 #if (OS_TYPE == OS_DOS)
553 # if defined (__WATCOMC__) && defined(__386__) && !defined(__WINDOWS_386__)
554 # define REG_AX eax
555 # define REG_BX ebx
556 # define REG_CX ecx
557 # define REG_DX edx
558 # define REG_SI esi
559 # define REG_DI edi
560 # define REG_CFLAGS cflag
561 # define SystemInterrupt(a,b,c) int386 (a, b, c)
562 # define SystemExtendedInterrupt(a,b,c,d) int386x (a, b, c, d)
563 # define DosInterrupt(a,b) intdos (a, b)
564 # define DosExtendedInterrupt(a,b,c) intdosx (a, b, c)
565 # elif defined (__EMX__)
566 # define REG_AX ax
567 # define REG_BX bx
568 # define REG_CX cx
569 # define REG_DX dx
570 # define REG_SI si
571 # define REG_DI di
572 # define REG_CFLAGS flags
573 # define SystemInterrupt(a,b,c) _int86 (a, b, c)
574 # define SystemExtendedInterrupt(a,b,c,d) not available
575 # define DosInterrupt(a,b) _int86 (0x21, a, b)
576 # define DosExtendedInterrupt(a,b,c) intdosx (a, b, c)
577 # else
578 # define REG_AX ax
579 # define REG_BX bx
580 # define REG_CX cx
581 # define REG_DX dx
582 # define REG_SI si
583 # define REG_DI di
584 # define REG_CFLAGS cflag
585 # define SystemInterrupt(a,b,c) int86 (a, b, c)
586 # define SystemExtendedInterrupt(a,b,c,d) int86x (a, b, c, d)
587 # define DosInterrupt(a,b) intdos (a, b)
588 # define DosExtendedInterrupt(a,b,c) intdosx (a, b, c)
589 # endif
590 #endif
591 
592 /*
593  * Missing OS/2 1.x definitions. Map OS/2 2.x definitions as appropriate
594  */
595 
596 #if (OS_TYPE == OS_OS2) && (OS_SIZE == OS_16)
597 # define SSF_RELATED_INDEPENDENT 0 /* New session is an */
598  /* independent */
599  /* session (not related) */
600 # define SSF_RELATED_CHILD 1 /* New session is a child */
601  /* session (related) */
602 # define SSF_FGBG_FORE 0 /* Start session in foreground */
603 # define SSF_FGBG_BACK 1 /* Start session in background */
604 # define SSF_TRACEOPT_NONE 0 /* No trace */
605 # define SSF_TRACEOPT_TRACE 1 /* Trace with no notification */
606  /* of descendants */
607 # define SSF_TRACEOPT_TRACEALL 2 /* Trace all descendant sessions */
608 # define SSF_INHERTOPT_SHELL 0 /* Inherit the Shell's environment.*/
609 # define SSF_INHERTOPT_PARENT 1 /* Inherit the environment of the*/
610  /* program issuing the */
611  /* DosStartSession call. */
612 # define SSF_TYPE_DEFAULT 0 /* Use the PgmHandle data, or */
613  /* allow the Shell to establish */
614  /* the session type. */
615 # define SSF_TYPE_FULLSCREEN 1 /* Start the program in a */
616  /* full-screen session. */
617 # define SSF_TYPE_WINDOWABLEVIO 2 /* Start the program */
618  /* in a windowed session for */
619  /* programs using the Base Video*/
620  /* Subsystem */
621 # define SSF_TYPE_PM 3 /* Start the program in a */
622  /* windowed session for programs*/
623  /* using the Presentation Manager*/
624  /* services */
625 # define SSF_TYPE_VDM 4 /* Start the program in a */
626  /* full-screen DOS session. */
627 # define SSF_TYPE_WINDOWEDVDM 7 /* Start the program in a */
628  /* windowed DOS session. */
629 # define SSF_CONTROL_VISIBLE 0x0000 /* Visible */
630 # define SSF_CONTROL_INVISIBLE 0x0001 /* Invisible */
631 # define SSF_CONTROL_MAXIMIZE 0x0002 /* Maximize */
632 # define SSF_CONTROL_MINIMIZE 0x0004 /* Minimize */
633 # define SSF_CONTROL_NOAUTOCLOSE 0x0008 /* No Auto Close */
634 # define SSF_CONTROL_SETPOS 0x8000 /* Use specified size and position */
635 #endif
636 
637 /*
638  * Define common OS2 APIs declaractions
639  */
640 
641 #if (OS_TYPE == OS_OS2)
642 # if (OS_SIZE == OS_16)
643 # define OSCALL_RET USHORT
644 # define OSCALL_PARAM USHORT
645 # else
646 # define OSCALL_RET APIRET
647 # define OSCALL_PARAM ULONG
648 # endif
649 #elif (OS_TYPE == OS_DOS)
650 # define OSCALL_RET unsigned int
651 # define OSCALL_PARAM unsigned int
652 #elif (OS_TYPE == OS_NT)
653 # define OSCALL_RET DWORD
654 # define OSCALL_PARAM DWORD
655 #elif (OS_TYPE == OS_UNIX)
656 # define OSCALL_RET int
657 # define OSCALL_PARAM int
658 #endif
659 
660 /*
661  * Borland TurboC has this in a file we don't include
662  */
663 
664 #ifdef __TURBOC__
665 # define getpid() (_psp)
666 #endif
667 
668 /*
669  * UNIX doesn't have these functions
670  */
671 
672 #if (OS_TYPE == OS_UNIX)
673 extern char *strlwr (char *);
674 extern char *strupr (char *);
675 extern int stricmp (char *, char *);
676 # define fputchar(c) putchar (c)
677 #endif
678 
679 /*
680  * Ignore case compare. UNIX cares about case!
681  */
682 
683 #if (OS_TYPE == OS_UNIX)
684 # define NOCASE_COMPARE(a,b) strcmp (a,b)
685 #else
686 # define NOCASE_COMPARE(a,b) stricmp (a,b)
687 #endif
688 
689 /*
690  * Executable Head Information structures
691  *
692  * Variable signatures
693  */
694 
695 #define SIG_DOS 0x5a4d /* Dos Magic number */
696 #define SIG_OS2_16 0x454e /* OS/2 16 Magic number */
697 #define SIG_OS2_16LE 0x454c /* OS/2 16 Magic number */
698 #define SIG_OS2_32 0x584c /* OS/2 32 Magic number */
699 #define SIG_NT 0x00004550 /* NT Magic number */
700 
701 /*
702  * Standard DOS header
703  */
704 
705 #pragma pack (1)
706 
708  unsigned short e_magic; /* Magic number */
709  unsigned short e_cblp; /* Bytes on last page of file */
710  unsigned short e_cp; /* Pages in file */
711  unsigned short e_crlc; /* Relocations */
712  unsigned short e_cparhdr; /* Size of header in paragraphs */
713  unsigned short e_minalloc; /* Minimum extra paras needed */
714  unsigned short e_maxalloc; /* Maximum extra paras needed */
715  unsigned short e_ss; /* Initial (relative) SS value */
716  unsigned short e_sp; /* Initial SP value */
717  unsigned short e_csum; /* Checksum */
718  unsigned short e_ip; /* Initial IP value */
719  unsigned short e_cs; /* Initial (relative) CS value */
720  unsigned short e_lfarlc; /* File addr. of reloc. table */
721  unsigned short e_ovno; /* Overlay number */
722  unsigned short e_res[4]; /* Reserved words */
723  unsigned short e_oemid; /* OEM identifier */
724  unsigned short e_oeminfo; /* OEM information */
725  unsigned short e_res2[10]; /* Reserved words */
726  long e_lfanew; /* File addr of new exe header */
727 };
728 
729 /*
730  * OS/2 and Windows 16 Bit header
731  */
732 
734  unsigned short ne_magic; /* Magic number */
735  unsigned char ne_ver; /* Version number */
736  unsigned char ne_rev; /* Revision number */
737  unsigned short ne_enttab; /* Offset of Entry Table */
738  unsigned short ne_cbenttab; /* Size of Entry Table */
739  long ne_crc; /* Checksum of whole file */
740  unsigned short ne_flags; /* Flag word */
741  unsigned short ne_autodata; /* Automatic data segment number*/
742  unsigned short ne_heap; /* Initial heap allocation */
743  unsigned short ne_stack; /* Initial stack allocation */
744  long ne_csip; /* Initial CS:IP setting */
745  long ne_sssp; /* Initial SS:SP setting */
746  unsigned short ne_cseg; /* Count of file segments */
747  unsigned short ne_cmod; /* Entries in Module Ref. Table */
748  unsigned short ne_cbnrestab; /* Size non-resident name table */
749  unsigned short ne_segtab; /* Off. Segment Table */
750  unsigned short ne_rsrctab; /* Off. Resource Table */
751  unsigned short ne_restab; /* Off. resident name table */
752  unsigned short ne_modtab; /* Off. Module Reference Table */
753  unsigned short ne_imptab; /* Off. Imported Names Table */
754  long ne_nrestab; /* Off. Non-resident Names Table*/
755  unsigned short ne_cmovent; /* Count of movable entries */
756  unsigned short ne_align; /* Segment alignment shift count*/
757  unsigned short ne_cres; /* Count of resource segments */
758  unsigned char ne_exetyp; /* Target Operating system */
759  unsigned char ne_flagsothers; /* Other .EXE flags */
760  unsigned short ne_pretthunks; /* offset to return thunks */
761  unsigned short ne_psegrefbytes;/* offset to segment ref. bytes */
762  unsigned short ne_swaparea; /* Minimum code swap area size */
763  unsigned short ne_expver; /* Expected Windows version number */
764 };
765 
766 /*
767  * Selected ne_flags values
768  */
769 
770 #define OS2_16_NOTP 0x8000 /* Not a process */
771 #define OS2_16_IERR 0x2000 /* Errors in image */
772 #define OS2_16_BOUND 0x0800 /* Bound Family/API */
773 #define OS2_16_APPTYP 0x0700 /* Application type mask */
774 #define OS2_16_NOTWINCOMPAT 0x0100 /* Not compatible with P.M. Windowing */
775 #define OS2_16_WINCOMPAT 0x0200 /* Compatible with P.M. Windowing */
776 #define OS2_16_WINAPI 0x0300 /* Uses P.M. Windowing API */
777 
778 /*
779  * ne_exetyp values
780  */
781 
782 #define OS2_16_UNKNOWN 0 /* Unknown (any "new-format" OS) */
783 #define OS2_16_OS2 1 /* OS/2 (default) */
784 #define OS2_16_WINDOWS 2 /* Windows */
785 #define OS2_16_DOS4 3 /* DOS 4.x */
786 #define OS2_16_DEV386 4 /* Windows 386 */
787 
788 /*
789  * OS2 32bit header
790  */
791 
793  unsigned short e32_magic; /* Magic number OS2__MAGIC */
794  unsigned char e32_border; /* Byte ordering for the .EXE */
795  unsigned char e32_worder; /* Word ordering for the .EXE */
796  unsigned long e32_level; /* EXE format level for now = 0 */
797  unsigned short e32_cpu; /* CPU type */
798  unsigned short e32_os; /* OS type */
799  unsigned long e32_ver; /* Module version */
800  unsigned long e32_mflags; /* Module flags */
801  unsigned long e32_mpages; /* Module # pages */
802  unsigned long e32_startobj; /* Object # for IP */
803  unsigned long e32_eip; /* Extended IP */
804  unsigned long e32_stackobj; /* Object # for SS */
805  unsigned long e32_esp; /* Extended SS */
806  unsigned long e32_pagesize; /* .EXE page size */
807  unsigned long e32_pageshift; /* Page alignment shift in .EXE */
808  unsigned long e32_fixupsize; /* Fixup section size */
809  unsigned long e32_fixupsum; /* Fixup section checksum */
810  unsigned long e32_ldrsize; /* Loader section size */
811  unsigned long e32_ldrsum; /* Loader section checksum */
812  unsigned long e32_objtab; /* Object table off. */
813  unsigned long e32_objcnt; /* Number of objects in module */
814  unsigned long e32_objmap; /* Object page map off. */
815  unsigned long e32_itermap; /* Object iterated data map off. */
816  unsigned long e32_rsrctab; /* Off. Resource Table */
817  unsigned long e32_rsrccnt; /* Number of resource entries */
818  unsigned long e32_restab; /* Off. resident name table */
819  unsigned long e32_enttab; /* Off. Entry Table */
820  unsigned long e32_dirtab; /* Off. Module Directive Table */
821  unsigned long e32_dircnt; /* Number of module directives */
822  unsigned long e32_fpagetab; /* Off. Fixup Page Table */
823  unsigned long e32_frectab; /* Off. Fixup Record Table */
824  unsigned long e32_impmod; /* Off. Import Module Name Table */
825  unsigned long e32_impmodcnt; /* # entries in IM Name Table */
826  unsigned long e32_impproc; /* Off. IProcedure Name Table */
827  unsigned long e32_pagesum; /* Off. Per-Page Checksum Table */
828  unsigned long e32_datapage; /* Off. Enumerated Data Pages */
829  unsigned long e32_preload; /* Number of preload pages */
830  unsigned long e32_nrestab; /* Off. Non-resident Names Table */
831  unsigned long e32_cbnrestab; /* Size of Non-resident Name Table */
832  unsigned long e32_nressum; /* Non-resident Name Table Checksum */
833  unsigned long e32_autodata; /* Object # for automatic data object */
834  unsigned long e32_debuginfo; /* Off. the debugging information */
835  unsigned long e32_debuglen; /* Length of debugging info. */
836  unsigned long e32_instpreload;/* # instance pages in preload */
837  /* section of .EXE file */
838  unsigned long e32_instdemand; /* # instance pages in demand */
839  /* load section of .EXE file */
840  unsigned long e32_heapsize; /* Size of heap - for 16-bit apps */
841 /* Padding ignored */
842 };
843 
844 /*
845  * Format of e32_mflags
846  */
847 
848 #define OS2_NOTP 0x00008000L /* Library Module - used as NENOTP */
849 #define OS2_NOLOAD 0x00002000L /* Module not Loadable */
850 #define OS2_PMAPI 0x00000300L /* Uses PM Windowing API */
851 #define OS2_PMW 0x00000200L /* Compatible with PM Windowing */
852 #define OS2_NOPMW 0x00000100L /* Incompatible with PM Windowing */
853 #define OS2_APPMASK 0x00000700L /* Application Type Mask */
854 #define OS2_PROTDLL 0x00010000L /* Protected memory library module */
855 #define OS2_DEVICE 0x00020000L /* Device driver */
856 #define OS2_MODEXE 0x00000000L /* .EXE module */
857 #define OS2_MODDLL 0x00008000L /* .DLL module */
858 #define OS2_MODPROTDLL 0x00018000L /* Protected memory library module */
859 #define OS2_MODPDEV 0x00020000L /* Physical device driver */
860 #define OS2_MODVDEV 0x00028000L /* Virtual device driver */
861 #define OS2_MODMASK 0x00038000L /* Module type mask */
862 
863 /*
864  * NT Exec Header
865  */
866 
867 struct ExecNTHeader {
868  unsigned long Signature;
869 
870  struct NTFileHeader {
871  unsigned short Machine;
872  unsigned short NumberOfSections;
873  unsigned long TimeDateStamp;
874  unsigned long PointerToSymbolTable;
875  unsigned long NumberOfSymbols;
876  unsigned short SizeOfOptionalHeader;
877  unsigned short Characteristics;
879 
881  unsigned short Magic;
882  unsigned char MajorLinkerVersion;
883  unsigned char MinorLinkerVersion;
884  unsigned long SizeOfCode;
885  unsigned long SizeOfInitializedData;
886  unsigned long SizeOfUninitializedData;
887  unsigned long AddressOfEntryPoint;
888  unsigned long BaseOfCode;
889  unsigned long BaseOfData;
890  unsigned long ImageBase;
891  unsigned long SectionAlignment;
892  unsigned long FileAlignment;
895  unsigned short MajorImageVersion;
896  unsigned short MinorImageVersion;
897  unsigned short MajorSubsystemVersion;
898  unsigned short MinorSubsystemVersion;
899  unsigned long Reserved1;
900  unsigned long SizeOfImage;
901  unsigned long SizeOfHeaders;
902  unsigned long CheckSum;
903  unsigned short Subsystem;
904  unsigned short DllCharacteristics;
905  unsigned long SizeOfStackReserve;
906  unsigned long SizeOfStackCommit;
907  unsigned long SizeOfHeapReserve;
908  unsigned long SizeOfHeapCommit;
909  unsigned long LoaderFlags;
910  unsigned long NumberOfRvaAndSizes;
911 /* All entries after this left out */
913 };
914 
915 #pragma pack ()
916 
917 /*
918  * NT header definitions
919  */
920 
921 #define NT_STD_HEADER 28 /* Size of Standard header */
922 #define NT_OPTIONAL_HEADER 224 /* Size of Optional header */
923 
924 #define NT_FILE_DLL 0x2000 /* File is a DLL. */
925 #define NT_FILE_MACHINE_I386 0x14c /* Intel 386. */
926 
927 /* Subsystem Values */
928 
929 #define NT_SS_NATIVE 1 /* doesn't require a subsystem. */
930 #define NT_SS_WINDOWS_GUI 2 /* Windows GUI subsystem. */
931 #define NT_SS_WINDOWS_CUI 3 /* Windows character subsystem. */
932 #define NT_SS_OS2_CUI 5 /* OS/2 character subsystem. */
933 #define NT_SS_POSIX_CUI 7 /* Posix character subsystem. */
934 
935 /*
936  * Find the application type
937  */
938 
939 extern unsigned long QueryApplicationType (const char *);
940 
941 /* Result from above */
942 
943 #define EXETYPE_ERROR 0x00000f /* Error on program */
944 #define EXETYPE_DOS 0x0000f0 /* Dos program */
945 #define EXETYPE_OS2 0x000f00 /* OS/2 16 program */
946 #define EXETYPE_OS2_TYPE 0x000700 /* OS/2 Type program */
947 #define EXETYPE_OS2_32 0x000800 /* OS/2 32 program */
948 #define EXETYPE_NT 0x00f000 /* Win NT program */
949 #define EXETYPE_UNIX 0x0f0000 /* UNIX program */
950 
951 #define EXETYPE_UNKNOWN 0x000001 /* Not known */
952 #define EXETYPE_BAD_IMAGE 0x000002 /* Bad image */
953 #define EXETYPE_NOT_EXE 0x000003 /* Not exe - OS/2 */
954 #define EXETYPE_BAD_FILE 0x000004 /* File not found */
955 
956 #define EXETYPE_DOS_CUI 0x000010 /* Dos non windows */
957 #define EXETYPE_DOS_GUI 0x000020 /* Windows */
958 #define EXETYPE_DOS_32 0x000030 /* Watcom 32 bit */
959 #define EXETYPE_DOS_BOUND 0x000040 /* OS/2 Bound */
960 
961 #define EXETYPE_OS2_CUI 0x000100 /* Not windows compat */
962 #define EXETYPE_OS2_CGUI 0x000200 /* Windows compatible */
963 #define EXETYPE_OS2_GUI 0x000300 /* Uses PM */
964 
965 #define EXETYPE_NT_NATIVE 0x001000 /* NT native */
966 #define EXETYPE_NT_WINDOWS_GUI 0x002000 /* NT Windows GUI ss */
967 #define EXETYPE_NT_WINDOWS_CUI 0x003000 /* NT Windows CUI ss */
968 #define EXETYPE_NT_OS2 0x004000 /* NT OS2 subsystem */
969 #define EXETYPE_NT_POSIX 0x005000 /* NT POSIX subsystem */
970 
971 #define EXETYPE_UNIX_NATIVE 0x010000 /* UNIX program */
972 
973 /*
974  * Shell Definitions
975  */
976 
977 #define PATCHLEVEL 4
978 #define LINE_MAX 524288 /* Command line length */
979 #define HISTORY_MAX 100 /* History array length */
980  /* Space for full file name */
981 #define FFNAME_MAX (PATH_MAX + NAME_MAX + 4)
982 
983 #define DOS_CMD_LINE_MAX 524288 /* Max command line length */
984 #define ARRAY_SIZE(a) ((sizeof (a)) / sizeof (a[0]))
985 
986 #if (OS_TYPE == OS_DOS)
987 # define CMD_LINE_MAX DOS_CMD_LINE_MAX
988 #elif (OS_TYPE == OS_OS2)
989 # define CMD_LINE_MAX 524288 /* Max command line length */
990 #elif (OS_TYPE == OS_NT)
991 # define CMD_LINE_MAX 524288 /* Max command line length */
992 #endif
993 
994 
995 #define SSAVE_IO_SIZE 4 /* Save IO array malloc inc */
996 #define LEN_DEVICE_NAME_HEADER 5 /* /dev/ string length */
997 
998 extern int MaxNumberofFDs; /* Max no of file descriptors */
999 #define NUFILE 20 /* # of user-accessible files */
1000 #define FDBASE 20 /* First file usable by Shell */
1001 
1002 /*
1003  * Some characters
1004  */
1005 
1006 #define CHAR_UNIX_DIRECTORY '/'
1007 #define CHAR_NEW_LINE '\n'
1008 #define CHAR_SINGLE_QUOTE '\''
1009 #define CHAR_DOUBLE_QUOTE '"'
1010 #define CHAR_BACKQUOTE '`'
1011 #define CHAR_RETURN '\r'
1012 #define CHAR_SPACE ' '
1013 #define CHAR_NOT '^'
1014 #define CHAR_TAB '\t'
1015 #define CHAR_BACKSPACE '\b'
1016 #define CHAR_ESCAPE 0x1b
1017 #define CHAR_XOR '^'
1018 #define CHAR_BEGIN_LINE '^'
1019 #define CHAR_OPEN_PARATHENSIS '('
1020 #define CHAR_CLOSE_PARATHENSIS ')'
1021 #define CHAR_OPEN_BRACES '{'
1022 #define CHAR_CLOSE_BRACES '}'
1023 #define CHAR_OPEN_BRACKETS '['
1024 #define CHAR_CLOSE_BRACKETS ']'
1025 #define CHAR_TILDE '~'
1026 #define CHAR_PIPE '|'
1027 #define CHAR_HISTORY '!'
1028 #define CHAR_COMMENT '#'
1029 #define CHAR_MATCH_START '#'
1030 #define CHAR_VARIABLE '$'
1031 #define CHAR_END_LINE '$'
1032 #define CHAR_FORMAT '%'
1033 #define CHAR_JOBID '%'
1034 #define CHAR_MATCH_END '%'
1035 #define CHAR_ASYNC '&'
1036 #define CHAR_MATCH_ALL '*'
1037 #define CHAR_PLUS '+'
1038 #define CHAR_HYPHEN '-'
1039 #define CHAR_MATCH_RANGE '-'
1040 #define CHAR_CLOSE_FD '-'
1041 #define CHAR_SWITCH '-'
1042 #define CHAR_PERIOD '.'
1043 #define CHAR_COLON ':'
1044 #define CHAR_DRIVE ':'
1045 #define CHAR_SEPARATOR ';'
1046 
1047 #if (OS_TYPE == OS_UNIX)
1048 # define CHAR_PATH_SEPARATOR ':'
1049 #else
1050 # define CHAR_PATH_SEPARATOR ';'
1051 #endif
1052 
1053 #define CHAR_INPUT '<'
1054 #define CHAR_ASSIGN '='
1055 #define CHAR_OUTPUT '>'
1056 #define CHAR_MATCH_ANY '?'
1057 #define CHAR_INDIRECT '@'
1058 #define CHAR_META '\\'
1059 #define CHAR_DOS_PATH '\\'
1060 #define CHAR_MAGIC 0x80
1061 
1062 /*
1063  * fast character classes
1064  */
1065 
1066 #define C_ALPHA 0x001 /* a-z_A-Z */
1067 #define C_DIGIT 0x002 /* 0-9 */
1068 #define C_LEX1 0x004 /* \0 \t\n|&;<>() */
1069 #define C_VAR1 0x008 /* *@#!$-? */
1070 #define C_SUBOP 0x010 /* "=-+?#%" */
1071 #define C_IFS 0x020 /* $IFS */
1072 #define C_WILD 0x040 /* Wildcards */
1073 #define C_SEMICOLON 0x080 /* Semi-colon (;) */
1074 
1075 extern void InitialiseCharacterTypes (void);
1076 extern void SetCharacterTypes (char *, int);
1077 extern unsigned char CharTypes [UCHAR_MAX + 1];
1078 
1079 /*
1080  * Check for variable characters
1081  */
1082 
1083 #define IS_VariableFC(c) (CharTypes[(c)] & C_ALPHA)
1084 #define IS_VariableSC(c) (CharTypes[(c)] & (C_ALPHA | C_DIGIT))
1085 
1086 #define IS_Numeric(c) (CharTypes[(c)] & C_DIGIT)
1087 #define IS_AlphaNumeric(c) (CharTypes[(c)] & (C_ALPHA | C_DIGIT))
1088 #define IS_IFS(c) (CharTypes[(c)] & C_IFS)
1089 #define IS_Lexical(c) (CharTypes[(c)] & C_LEX1)
1090 #define IS_VarNumeric(c) (CharTypes[(c)] & (C_DIGIT | C_VAR1))
1091 #define IS_VarOp(c) (CharTypes[(c)] & C_SUBOP)
1092 #define IS_WildCard(c) (CharTypes[(c)] & C_WILD)
1093 
1094 extern char *SkipToWhiteSpace (char *);
1095 
1096 /*
1097  * File open modes
1098  */
1099  /* Open in create mode */
1100 #define O_CMASK (O_WRONLY | O_CREAT | O_TRUNC | O_BINARY)
1101  /* Open in create mode for a pipe */
1102 #define O_PMASK (O_RDWR | O_CREAT | O_TRUNC | O_TEXT)
1103  /* Open in create mode for swap file */
1104 #define O_SMASK (O_RDWR | O_CREAT | O_TRUNC | O_BINARY)
1105 #define O_SaMASK (O_RDWR | O_BINARY)
1106 #define O_RMASK (O_RDONLY | O_NOINHERIT | O_TEXT)
1107 
1108 /*
1109  * Path format conversion
1110  */
1111 
1112 #define PATH_TO_UNIX(x) ConvertPathToFormat ((x), CHAR_DOS_PATH, \
1113  CHAR_UNIX_DIRECTORY)
1114 #define PATH_TO_DOS(x) ConvertPathToFormat ((x), CHAR_UNIX_DIRECTORY, \
1115  CHAR_DOS_PATH)
1116 
1117 #if (OS_TYPE == OS_UNIX)
1118 # define PATH_TO_UPPER_CASE(a)
1119 # define PATH_TO_LOWER_CASE(a)
1120 # define IsHPFSFileSystem(a) TRUE
1121 #elif (OS_TYPE != OS_DOS)
1122 # define PATH_TO_UPPER_CASE(a) {if (!IsHPFSFileSystem (a)) strupr (a); }
1123 # define PATH_TO_LOWER_CASE(a) {if (!IsHPFSFileSystem (a)) strlwr (a); }
1124 #else
1125 # define PATH_TO_UPPER_CASE(a) { strupr (a); }
1126 # define PATH_TO_LOWER_CASE(a) { strlwr (a); }
1127 # define IsHPFSFileSystem(a) FALSE
1128 #endif
1129 
1130 /*
1131  * Drive support
1132  */
1133 
1134 #if (OS_TYPE == OS_UNIX)
1135 # define IsDriveCharacter(a) FALSE
1136 #else
1137 # define IsDriveCharacter(a) C2bool ((a) == CHAR_DRIVE)
1138 #endif
1139 
1140 #define IsPathCharacter(a) C2bool ((a) == CHAR_UNIX_DIRECTORY)
1141 #define FindLastPathCharacter(a) strrchr (a, CHAR_UNIX_DIRECTORY)
1142 #define FindPathCharacter(a) strchr (a, CHAR_UNIX_DIRECTORY)
1143 
1144 /*
1145  * shell components
1146  */
1147 
1148 #define NOBLOCK ((C_Op *)NULL)
1149 #define NOWORD ((char *)NULL)
1150 #define NOWORDS ((char **)NULL)
1151 #define NOPIPE (-1)
1152 
1153 /*
1154  * Ignore Variables flags
1155  */
1156 
1157 #define DISABLE_MAILCHECK 0x0001
1158 #define DISABLE_OPTARG 0x0002
1159 #define DISABLE_OPTIND 0x0004
1160 #define DISABLE_SECONDS 0x0008
1161 #define DISABLE_RANDOM 0x0010
1162 #define DISABLE_LASTWORD 0x0020
1163 #define DISABLE_LINECOUNT 0x0040
1164 #define DISABLE_WINTITLE 0x0080
1165 
1166 extern int DisabledVariables;
1167 
1168 /*
1169  * File Descriptor Types and Macros
1170  */
1171 
1172 #define DESCRIPTOR_UNKNOWN 0x0000 /* Error - not known */
1173 #define DESCRIPTOR_PIPE 0x0001 /* Pipe */
1174 #define DESCRIPTOR_FILE 0x0002 /* File */
1175 #define DESCRIPTOR_DEVICE 0x0004 /* Device - tty */
1176 #define DESCRIPTOR_CONSOLE 0x0008 /* Console device */
1177 
1178 #define IS_Pipe(a) (GetDescriptorType (a) & DESCRIPTOR_PIPE)
1179 #define IS_File(a) (GetDescriptorType (a) & DESCRIPTOR_FILE)
1180 #define IS_TTY(a) (GetDescriptorType (a) & \
1181  (DESCRIPTOR_DEVICE | DESCRIPTOR_CONSOLE))
1182 #define IS_Console(a) (GetDescriptorType (a) & DESCRIPTOR_CONSOLE)
1183 
1184 /*
1185  * Result from FindLocationOfExecutable
1186  */
1187 
1188 #define EXTENSION_NOT_FOUND 0 /* Cannot find file */
1189 #define EXTENSION_EXECUTABLE 1 /* OS/2 or DOS .exe or .com */
1190 #define EXTENSION_BATCH 2 /* OS/2 or DOS .cmd or .bat */
1191 #define EXTENSION_SHELL_SCRIPT 3 /* Shell script */
1192 #define EXTENSION_OTHER 4 /* Other */
1193 
1194 /*
1195  * XString - Expandable strings
1196  *
1197  * XString functions:
1198  *
1199  * XFree - Release the string
1200  * XStart - Get start of string
1201  * XClose - close a string
1202  * XCreate - Create a string
1203  * XCheck - Check for overflow
1204  */
1205 
1206 typedef struct XString {
1207  unsigned char *SStart; /* End of string */
1208  unsigned char *SEnd; /* Beginning of string */
1209  size_t SLength; /* length */
1210 } XString;
1211 
1212 #define XFree(xs) ReleaseMemoryCell ((void*)(xs).SStart)
1213 #define XStart(xs) ((xs).SStart)
1214 #define XCurrentOffset(xs, xp) (xp - (xs).SStart)
1215 #define XResetOffset(xs, n) ((xs).SStart + (n))
1216 
1217 extern void XCheck (XString *, unsigned char **);
1218 extern char *XClose (XString *, unsigned char *);
1219 extern char *XCreate (XString *, size_t);
1220 
1221 /*
1222  * Description of a command or an operation on commands.
1223  * Might eventually use a union.
1224  */
1225 
1226 typedef struct op {
1227  int type; /* operation type, see below */
1228  char **args; /* arguments to a command */
1229  char **vars; /* variable assignments */
1230  struct ioword **ioact; /* IO actions (eg, < > >>) */
1231  struct op *left;
1232  struct op *right;
1233  char *str; /* identifier for case and for */
1234 } C_Op;
1235 
1236 /*
1237  * C_Op.type values
1238  */
1239 
1240 #define TEOF 0
1241 #define TCOM 1 /* command */
1242 #define TPAREN 2 /* (c-list) */
1243 #define TPIPE 3 /* a | b */
1244 #define TLIST 4 /* a [&;] b */
1245 #define TOR 5 /* || */
1246 #define TAND 6 /* && */
1247 #define TFOR 7 /* FOR */
1248 #define TCOPROCESS 8 /* coprocess */
1249 #define TCASE 9 /* CASE */
1250 #define TIF 10 /* IF */
1251 #define TWHILE 11 /* WHILE */
1252 #define TUNTIL 12 /* UNTIL */
1253 #define TELIF 13 /* ELSE IF */
1254 #define TPAT 14 /* pattern in case */
1255 #define TBRACE 15 /* {c-list} */
1256 #define TASYNC 16 /* c & */
1257 #define TFUNC 17 /* c () {c-list} */
1258 #define TSELECT 18 /* SELECT */
1259 #define TTIME 19 /* time pipeline */
1260 
1261 /*
1262  * Prefix codes for words in command tree
1263  */
1264 
1265 #define WORD_EOS 0 /* end of string */
1266 #define WORD_CHAR 1 /* unquoted character */
1267 #define WORD_QCHAR 2 /* quoted character */
1268 #define WORD_QTCHAR 3 /* temporary quoted character */
1269 #define WORD_COMSUB 4 /* $() substitution (0 terminated) */
1270 #define WORD_OQUOTE 5 /* opening ' */
1271 #define WORD_CQUOTE 6 /* closing ' */
1272 #define WORD_ODQUOTE 7 /* opening " */
1273 #define WORD_CDQUOTE 8 /* closing " */
1274 #define WORD_OSUBST 9 /* opening ${ substitution */
1275 #define WORD_CSUBST 10 /* closing } of above */
1276 #define WORD_OMATHS 11 /* opening $(()) substitution (0 term) */
1277 #define WORD_OARRAY 12 /* opening ${name[ of array */
1278 #define WORD_CARRAY 13 /* closing ] for above */
1279 
1280 /*
1281  * Syntax and Lexical Analysis
1282  *
1283  * Lexical tokens
1284  */
1285 
1286 #define PARSE_WORD 256
1287 #define PARSE_LOGICAL_AND 257 /* && */
1288 #define PARSE_LOGICAL_OR 258 /* || */
1289 #define PARSE_BREAK 259
1290 #define PARSE_IF 260
1291 #define PARSE_THEN 261
1292 #define PARSE_ELSE 262
1293 #define PARSE_ELIF 263
1294 #define PARSE_FI 264
1295 #define PARSE_CASE 265
1296 #define PARSE_ESAC 266
1297 #define PARSE_FOR 267
1298 #define PARSE_WHILE 268
1299 #define PARSE_UNTIL 269
1300 #define PARSE_DO 270
1301 #define PARSE_DONE 271
1302 #define PARSE_IN 272
1303 #define PARSE_SELECT 273
1304 #define PARSE_FUNCTION 274
1305 #define PARSE_TIME 275
1306 #define PARSE_REDIR 276 /* >, <, etc */
1307 #define PARSE_MPAREN 277 /* () */
1308 #define PARSE_MDPAREN 278 /* (( )) */
1309 #define PARSE_TEST 279 /* [[ ]] */
1310 #define PARSE_COPROCESS 280 /* |& */
1311 #define YYERRCODE 300
1312 
1313 /*
1314  * Lexical token value
1315  */
1316 
1317 typedef union {
1318  int i; /* Integer */
1319  char *cp; /* String */
1320  char **wp; /* List */
1321  struct op *o; /* Command tree */
1322  struct ioword *iop; /* IO action */
1323 } YYSTYPE;
1324 
1325 /*
1326  * flags to ScanNextToken
1327  */
1328 
1329 #define ALLOW_CONTINUATION 0x0001 /* skip new lines to complete */
1330  /* command */
1331 #define ONEWORD 0x0002 /* single word for substitute() */
1332 #define ALLOW_ALIAS 0x0004 /* recognize alias */
1333 #define ALLOW_KEYWORD 0x0008 /* recognize keywords */
1334 #define MATHS_EXPRESSION 0x0010 /* get expression inside (( )) */
1335 #define TEST_EXPRESSION 0x0020 /* get expression inside [[ ]] */
1336 
1337 
1338 #define IDENT 64 /* Max size of an Identifier */
1339 extern char CurrentLexIdentifier [IDENT+1];
1340 
1341 /*
1342  * Input descriptor for yylex
1343  */
1344 
1345 typedef struct source {
1346  char *str; /* input pointe */
1347  int type; /* input type */
1348  union {
1349  char **strv; /* string [] */
1350  FILE *file; /* file */
1351  struct AliasList *Calias; /* alias */
1352  } u;
1353 
1354  int line; /* line number */
1355  char *file; /* input file name */
1356  bool echo; /* echo input to shlout */
1357  struct source *next; /* stacked source */
1359 
1360 /* Source.type values */
1361 
1362 #define SEOF 0 /* input EOF */
1363 #define STTY 1 /* terminal input */
1364 #define SFILE 2 /* file input */
1365 #define SWSTR 3 /* string without \n */
1366 #define SSTRING 4 /* string */
1367 #define SWORDS 5 /* string[] */
1368 #define SALIAS 6 /* alias expansion */
1369 #define SWORDSEP 8 /* string[] seperator */
1370 
1371 extern Source *pushs (int); /* push Source */
1372 extern C_Op *compile (Source *s); /* compile tree */
1373 
1374 
1375 extern Source *source; /* yyparse/yylex source */
1376 extern YYSTYPE yylval; /* result from yylex */
1377 extern int yynerrs;
1378 
1379 /* Built in Command list */
1380 
1381 struct builtin {
1382  char *command;
1383  int (*fn)(int, char **);
1384  int mode;
1385 };
1386 
1387 extern int doexec (C_Op *); /* Exec function a cheat */
1388 
1389 /*
1390  * Valid values of mode
1391  */
1392 
1393 #define BLT_ALWAYS 0x0001 /* Always use builtin version */
1394 #define BLT_CURRENT 0x0002 /* Currently use builtin version */
1395 #define BLT_NOGLOB 0x0004 /* No globbing for this internal */
1396 #define BLT_CENVIRON 0x0008 /* Don't create a new environment */
1397 #define BLT_NOWORDS 0x0010 /* Don't split words for this internal */
1398 #define BLT_SKIPGLOB (BLT_CURRENT | BLT_NOGLOB)
1399 #define BLT_SKIPENVIR (BLT_CURRENT | BLT_CENVIRON)
1400 
1401 /*
1402  * actions determining the environment of a process
1403  */
1404 
1405 #define EXEC_WITHOUT_FORK 0x0001 /* execute without forking */
1406 #define EXEC_FUNCTION 0x0002 /* execute a function */
1407 
1408 #if (OS_TYPE != OS_DOS)
1409 # define EXEC_SPAWN_NOWAIT 0x0004 /* execute a non-wait */
1410 # define EXEC_SPAWN_DETACH 0x0008 /* execute a detach */
1411 # define EXEC_SPAWN_IGNOREWAIT 0x0010 /* Pipe processing */
1412 #endif
1413 
1414 #define EXEC_PIPE_IN 0x0020 /* On pipe */
1415 #define EXEC_PIPE_SUBS 0x0040 /* Second command */
1416 #define EXEC_WINDOWS 0x0080 /* Start Windows app */
1417 
1418 /* MSDOS Memory Control Block chain structure */
1419 
1420 #ifdef OS_SWAPPING
1421 # pragma pack (1)
1422 struct MCB_list {
1423  char MCB_type; /* M or Z */
1424  unsigned int MCB_pid; /* Process ID */
1425  unsigned int MCB_len; /* MCB length */
1426 };
1427 # pragma pack ()
1428 
1429 # define MCB_CON 'M' /* More MCB's */
1430 # define MCB_END 'Z' /* Last MCB's */
1431 #endif
1432 
1433 /* Externs for Swapper assembler function */
1434 
1435 #ifdef OS_SWAPPING
1436 extern char far cmd_line[]; /* Command line */
1437 extern char far path_line[]; /* Process path */
1438 extern unsigned int far SW_intr; /* interrupt pending */
1439 #else
1440 extern unsigned int SW_intr; /* interrupt pending */
1441 extern bool IgnoreInterrupts;/* Ignore interrupts flag */
1442 #endif
1443 
1444 extern int LastNumberBase; /* Last base entered */
1445 
1446 #ifdef OS_SWAPPING
1447 extern unsigned int far SW_Blocks; /* Number of blocks to read */
1448 extern unsigned int far SW_SBlocks; /* Short Number of blocks to */
1449  /* read */
1450 extern unsigned int far SW_MinESpace; /* Minimum environment space */
1451 extern int far SW_fp; /* File or EMS Handler */
1452 extern int far SW_Pwrite; /* Partial write to disk? */
1453 extern unsigned long far SW_EMstart;/* Start addr of extend mem */
1454 extern unsigned int far SW_Mode; /* Type of swapping to do */
1455  /* 1 - disk */
1456  /* 2 - Extended memory */
1457  /* 3 - EMS Driver */
1458  /* 4 - XMS Driver */
1459 extern unsigned int far SW_EMSFrame; /* EMS Frame segment */
1460 
1461 extern unsigned int far etext; /* End of text segment */
1462 extern int Swap_Mode; /* Swapping mode */
1463 
1464 /* If you change these values, change sh7, swap_device as well */
1465 
1466 # define SWAP_OFF 0x0000 /* No swapping */
1467 # define SWAP_DISK 0x0001 /* Disk only */
1468 # define SWAP_EXTEND 0x0002 /* Extended memory */
1469 # define SWAP_EXPAND 0x0004 /* Expanded memory */
1470 #endif
1471 
1472 /*
1473  * Convert to bool
1474  */
1475 
1476 #define C2bool(c) (bool)((c) ? TRUE : FALSE)
1477 
1478 /*
1479  * flags to control evaluation of words
1480  */
1481 
1482 #define EXPAND_SPLITIFS 0x01 /* Perform blank interpretation */
1483 #define EXPAND_GLOBBING 0x02 /* Do globbing on name */
1484 #define EXPAND_PATTERN 0x04 /* quote *?[ */
1485 #define EXPAND_TILDE 0x10 /* expand ~ */
1486 #define EXPAND_CONVERT 0x20 /* Convert - and / to DOS format */
1487 #define EXPAND_NOALTS 0x40 /* No alternations */
1488 
1489 /*
1490  * Hard error handler
1491  */
1492 
1493 #if (OS_TYPE == OS_OS2)
1494 # if (OS_SIZE == OS_32)
1495 # define DISABLE_HARD_ERRORS DosError (FERR_DISABLEHARDERR)
1496 # define ENABLE_HARD_ERRORS DosError (FERR_ENABLEHARDERR)
1497 # else
1498 # define DISABLE_HARD_ERRORS DosError (HARDERROR_DISABLE)
1499 # define ENABLE_HARD_ERRORS DosError (HARDERROR_ENABLE)
1500 # endif
1501 
1502 #elif (OS_TYPE == OS_NT)
1503 # define DISABLE_HARD_ERRORS SetErrorMode (SEM_FAILCRITICALERRORS | \
1504  SEM_NOOPENFILEERRORBOX)
1505 # define ENABLE_HARD_ERRORS SetErrorMode (0)
1506 
1507 #elif (OS_TYPE == OS_DOS)
1508 # if (OS_SIZE == OS_32)
1509 extern bool IgnoreHardErrors;
1510 # define DISABLE_HARD_ERRORS IgnoreHardErrors = TRUE;
1511 # define ENABLE_HARD_ERRORS IgnoreHardErrors = FALSE;
1512 # else
1513 # define DISABLE_HARD_ERRORS
1514 # define ENABLE_HARD_ERRORS
1515 # endif
1516 
1517 #elif (OS_TYPE == OS_UNIX)
1518 # define DISABLE_HARD_ERRORS
1519 # define ENABLE_HARD_ERRORS
1520 #endif
1521 
1522 /*
1523  * General variables
1524  */
1525 
1526 extern char **ParameterArray;/* $<numeric> values */
1527 extern int ParameterCount; /* $<numeric> count */
1528 extern int ExitStatus;
1529 extern bool ExpansionErrorDetected;
1530 extern bool InteractiveFlag;/* interactive */
1531 extern bool ProcessingEXECCommand;
1532 extern int AllowMultipleLines; /* Allow continuation */
1533 extern int Current_Event; /* Current history event */
1534 extern bool ChangeInitLoad; /* Change load .ini point. */
1535 
1536 /*
1537  * Break/Continue (in for and while), Return and Exit handler
1538  */
1539 
1540 typedef struct brkcon {
1544  /* Values returned by longjmp */
1545 #define BC_LOAD 0 /* Load condition */
1546 #define BC_BREAK 1 /* Break condition */
1547 #define BC_CONTINUE 2 /* Continue condition */
1548 
1549 extern Break_C *Break_List; /* Break list for FOR/WHILE */
1550 extern Break_C *Return_List; /* Return list for RETURN */
1551 extern Break_C *SShell_List; /* SubShell list for EXIT */
1552 extern bool RestrictedShellFlag; /* Read only shell */
1553 extern bool HistoryEnabled;
1554 
1555 /*
1556  * Word List structure
1557  */
1558 
1559 typedef struct wdblock {
1560  short w_bsize;
1561  short w_nword;
1562  char *w_words[1];
1564 
1565 /*
1566  * Save Standard Input/Output/Error structure
1567  */
1568 
1569 typedef struct save_io {
1570  int depth; /* Execute recursive depth */
1571  int fp[STDERR_FILENO + 1]; /* File handlers */
1573 
1574 extern Save_IO *SSave_IO; /* Save IO array */
1575 extern int NSave_IO_E; /* Number of entries */
1576 extern int MSave_IO_E; /* Max Number of entries */
1577 
1578 /*
1579  * Function tree processing
1580  */
1581 
1582 typedef struct FunctionList {
1583  C_Op *tree; /* The tree itself */
1584  bool Traced; /* Traced flag */
1586 
1587 extern void *FunctionTree; /* Function Tree root */
1589 
1590 /*
1591  * Alias processing
1592  */
1593 
1594 typedef struct AliasList {
1595  char *name; /* The alias name */
1596  char *value; /* The alias */
1597  int AFlags; /* Alias flags */
1599 
1600 extern void *AliasTree; /* Alias Tree root */
1601 
1602 #define ALIAS_TRACKED 0x0001 /* Tracked alias */
1603 #define ALIAS_EXPANDING 0x0002 /* Alias being expanded */
1604 #define MAX_RECURSIVEALIASES 20 /* Max depth of recursive alias */
1605 
1606 /*
1607  * Job Processing
1608  */
1609 
1610 #if (OS_TYPE != OS_DOS)
1611 
1612 # if (OS_TYPE == OS_NT)
1613 typedef DWORD PID; /* Set up PID definition for NT */
1614 # endif
1615 
1616 typedef struct JobList {
1617  int Number; /* Current number */
1618  PID pid; /* Process ID */
1619  unsigned short SessionId; /* Session ID */
1620  char *Command; /* Program */
1621 } JobList;
1622 
1623 extern void *JobTree; /* Job Tree root */
1624 extern bool ExitWithJobsActive; /* Exit flag */
1625 extern int CurrentJob; /* No current */
1626 extern int PreviousJob; /* Previous Job */
1627 
1628 /*
1629  * Session Info
1630  */
1631 
1632 extern char *SessionEndQName; /* Queue name */
1633 
1634 /*
1635  * Special flag for EMX parameters
1636  */
1637 
1638 extern bool EMXStyleParameters;
1639 #endif
1640 
1641 /*
1642  * redirection
1643  */
1644 
1645 typedef struct ioword {
1646  short io_unit; /* unit affected */
1647  short io_flag; /* action (below) */
1648  char *io_name; /* file name */
1650 
1651 #define IOTYPE 0x000f /* type: bits 0:3 */
1652 #define IOREAD 0x0001 /* < */
1653 #define IOWRITE 0x0002 /* > */
1654 #define IORDWR 0x0003 /* <> */
1655 #define IOHERE 0x0004 /* << (here file) */
1656 #define IOCAT 0x0005 /* >> */
1657 #define IODUP 0x0006 /* >&digit */
1658 #define IOCLOSE 0x0007 /* >&- */
1659 #define IOEVAL 0x0010 /* Expand in << */
1660 #define IOSKIP 0x0020 /* <<- (here file */
1661 #define IOCLOBBER 0x0040 /* >| overwrite noclobber */
1662 #define IOFUNCTION 0x0080 /* The Here document name is inside a */
1663  /* function - don't delete it */
1664 
1665 /*
1666  * parsing & execution environment
1667  *
1668  * For some reason, MSC (and IBM C Set/2), don't like taking addresses
1669  * of jmp_buf's, so this macro set removes the errors
1670  */
1671 
1672 #if defined (__TURBOC__) || defined (__WATCOMC__)
1673 # define ErrorPoint jmp_buf *
1674 # define SetErrorPoint(a) setjmp (*(e.ErrorReturnPoint = &(a)))
1675 # define ExitErrorPoint(a) longjmp (*(e.ErrorReturnPoint), a)
1676 #else
1677 # define ErrorPoint int *
1678 # define SetErrorPoint(a) setjmp (e.ErrorReturnPoint = a)
1679 # define ExitErrorPoint(a) longjmp (e.ErrorReturnPoint, a)
1680 #endif
1681 
1682 #define TERMINATE_POINT_SET 0 /* Error point set */
1683 #define TERMINATE_COMMAND 1 /* Exit Error point for command */
1684 #define TERMINATE_SHELL 2 /* Exit Error point for shell */
1685 
1686 
1687 /* The environment structure itself */
1688 
1689 typedef struct env {
1691  unsigned long IOMap; /* File Descriptors open in */
1692  /* this environment */
1693  char *line; /* Current input line */
1694  /* Previous environment */
1698 
1699 extern ShellFileEnvironment e;
1700 
1701 /*
1702  * Switches/flags
1703  */
1704 
1705 #define FL_TEST(x) (flags & (1L << ((x) - 'a')))
1706 #define FL_SET(x) flags |= (1L << ((x) - 'a'))
1707 #define FL_CLEAR(x) flags &= (~(1L << ((x) - 'a')))
1708 
1709 extern long flags;
1710 
1711 /*
1712  * Switch values
1713  */
1714 
1715 #define FLAG_ALL_EXPORT 'a' /* Set all env vars to exported */
1716 #define FLAG_EXECUTE_STRING 'c' /* Command from string */
1717 #define FLAG_EXIT_ON_ERROR 'e' /* Quit on error */
1718 #define FLAG_DISABLE_GLOB 'f' /* Disable file name expansion */
1719 #define FLAG_TRACK_ALL 'h' /* Track all aliases */
1720 #define FLAG_INTERACTIVE 'i' /* Interactive shell */
1721 #define FLAG_ALL_KEYWORDS 'k' /* Look for name=value everywhere */
1722 #define FLAG_SEPARATE_GROUP 'm' /* Separate process group */
1723 #define FLAG_NO_EXECUTE 'n' /* No execution */
1724 #define FLAG_READONLY_SHELL 'r' /* Read only shell */
1725 #define FLAG_POSITION 's' /* Read from standard input */
1726 #define FLAG_ONE_COMMAND 't' /* exit after exec'ing 1 cmd */
1727 #define FLAG_UNSET_ERROR 'u' /* Abort if env var not set */
1728 #define FLAG_ECHO_INPUT 'v' /* Echo as read */
1729 #define FLAG_WARNING 'w' /* No Warning messages */
1730 #define FLAG_PRINT_EXECUTE 'x' /* Trace */
1731 
1732 /*
1733  * Global flags set by set -o which do not have single letter equivalents
1734  */
1735 
1736 extern unsigned int ShellGlobalFlags;
1737 
1738 #define FLAGS_NONE 0x0000
1739 #define FLAGS_IGNOREEOF 0x0001 /* Ignore EOF */
1740 #define FLAGS_MARKDIRECTORY 0x0002 /* Mark directories with / */
1741 #define FLAGS_NOCLOBER 0x0004 /* No delete on existing files */
1742 #define FLAGS_FUNCTION 0x0008 /* Special value used in */
1743  /* CreateGlobalVariableList. */
1744  /* Indicates a function caused */
1745  /* CGVL to be called. Not used */
1746  /* otherwise */
1747 #define FLAGS_REALPIPES 0x0010 /* Use Real pipes under OS/2 */
1748 #define FLAGS_ALTERNATION 0x0020 /* Allow alternations */
1749 
1750 #define FLAGS_EDITORS 0x01c0 /* Any of Emacs, Gmacs, or Vi */
1751 #define FLAGS_NOCASE 0x0200 /* Ignore case */
1752 #define FLAGS_MSDOS_FORMAT 0x0400 /* MSDOS format environment */
1753 #define FLAGS_VERIFY_SWITCH 0x0800 /* Change verify status */
1754 
1755 #if (OS_TYPE == OS_DOS)
1756 #define FLAGS_BREAK_SWITCH 0x1000 /* Change break status */
1757 #define FLAGS_SET_OS2 0x2000 /* Set OS to OS2 */
1758 #define FLAGS_SET_NT 0x4000 /* Set OS to NT */
1759 #endif
1760 
1761 #define FLAGS_VI 0x0040 /* Vi mode */
1762 #define FLAGS_EMACS 0x0080 /* Emacs mode */
1763 #define FLAGS_GMACS 0x0100 /* Gmacs mode */
1764 
1765 extern char null[]; /* null value for variable */
1766 extern int InterruptTrapPending; /* trap pending */
1767 extern int Execute_stack_depth; /* execute function recursion */
1768  /* depth */
1769 
1770 /*
1771  * Mode values for new GeneralPatternMatch
1772  */
1773 
1774 #define GM_ALL 0 /* Match full string */
1775 #define GM_SHORTEST 1 /* Shortest prefix/suffix */
1776 #define GM_LONGEST 2 /* Longest prefix/suffix */
1777 
1778 /*
1779  * Variable list
1780  */
1781 
1782 typedef struct var {
1783  char *name; /* Name */
1784  char *value; /* Value */
1785  int index; /* Array index */
1786  unsigned long nvalue; /* Numeric value */
1787  unsigned int base; /* Numeric base */
1788  unsigned int width; /* Field width */
1789  unsigned int status; /* Type, see below */
1791 
1792 #define STATUS_READONLY 0x0001 /* variable is read-only */
1793 #define STATUS_EXPORT 0x0002 /* variable is to be exported */
1794 #define STATUS_CANNOT_UNSET 0x0008 /* PATH Value - no unset */
1795 #define STATUS_CONVERT_MSDOS 0x0010 /* Convert to MSDOS format */
1796 #define STATUS_LEFT_JUSTIFY 0x0020 /* Left Justify */
1797 #define STATUS_RIGHT_JUSTIFY 0x0040 /* Right Justify */
1798 #define STATUS_ZERO_FILL 0x0080 /* Zero fill */
1799 #define STATUS_LOWER_CASE 0x0100 /* Convert to lower case */
1800 #define STATUS_UPPER_CASE 0x0200 /* Convert to upper case */
1801 #define STATUS_INTEGER 0x0400 /* Contains integer value */
1802 #define STATUS_TAGGED 0x0800 /* User tagged */
1803 #define STATUS_LOCAL 0x1000 /* Local variable in function */
1804 #define STATUS_GLOBAL 0x2000 /* Global variable */
1805 #define STATUS_NOEXISTANT 0x8000 /* Does not exist */
1806 
1807 extern void *VariableTree; /* Variable dictionary */
1808 extern VariableList *CurrentDirectory; /* Current directory */
1809 extern char PS1[]; /* Prompt 1 */
1810 extern char PS2[]; /* Prompt 2 */
1811 extern char PS3[]; /* Prompt 3 */
1812 extern char PS4[]; /* Prompt 4 */
1813 extern char IFS[]; /* Interfield separators */
1814 extern char *LastUserPrompt; /* Last prompt output */
1815 extern char *LastUserPrompt1; /* Alternate prompt output */
1816 extern char PathLiteral[]; /* PATH Variable */
1817 extern char CDPathLiteral[]; /* CDPATH Variable */
1818 extern char CurrentDirLiteral[]; /* Current Directory */
1819 extern char ParentDirLiteral[]; /* Parent Directory */
1820 extern char PathExtsLiteral[]; /* PATHEXTS Variable */
1821 extern char HomeVariableName[]; /* Home Variable */
1822 extern char ShellVariableName[]; /* Shell Variable */
1823 extern char *ParameterCountVariable;/* Parameter Count Variable (#) */
1824 extern char *ShellOptionsVariable; /* Shell Options Variable (-) */
1825 extern char StatusVariable[]; /* Status variable (?) */
1826 extern char *ComspecVariable; /* COMSPEC string */
1827 extern char SecondsVariable[]; /* Seconds string */
1828 extern char RandomVariable[]; /* Random string */
1829 extern char LineCountVariable[]; /* LINENO string */
1830 extern char *RootDirectory; /* Root directory */
1831 
1832 
1833 #if (OS_TYPE != OS_DOS)
1834 extern char WinTitleVariable[]; /* WINTITLE string */
1835 #endif
1836 
1837 extern char *OldPWDVariable; /* OLDPWD string */
1838 extern char *PWDVariable; /* PWD string */
1839 extern char *ENVVariable; /* ENV string */
1840 extern char BATExtension[]; /* .bat string */
1841 extern char CMDExtension[]; /* .cmd string */
1842 extern char VBSExtension[]; /* .vbs string */
1843 extern char JSExtension[]; /* .js string */
1844 extern char SHELLExtension[]; /* .sh string */
1845 extern char KSHELLExtension[]; /* .ksh string */
1846 extern char LGExtension[]; /* .lg string */
1847 #if (OS_TYPE == OS_NT)
1848 extern char SUBExtension[]; /* .sub string */
1849 #endif
1850 extern char EXEExtension[]; /* .exe string */
1851 extern char COMExtension[]; /* .com string */
1852 extern char COFFExtension[]; /* null string */
1853 extern char HistoryFileVariable[]; /* HISTFILE string */
1854 extern char HistorySizeVariable[]; /* HISTSIZE string */
1855 extern bool UseConsoleBuffer; /* Flag from dofc to */
1856  /* GetConsoleInput */
1857 extern char *NotFound; /* Not found message */
1858 extern char *BasicErrorMessage; /* Basic error message */
1859 extern char *DirectorySeparator; /* Directory separator */
1860 extern char *DeviceNameHeader; /* /dev/ */
1861 extern char LastWordVariable[]; /* Last word of command variable*/
1862 extern char OptArgVariable[]; /* OPTARG */
1863 extern char OptIndVariable[]; /* OPTIND */
1864 extern char MailCheckVariable[]; /* MAILCHECK */
1865 extern char FCEditVariable[]; /* FCEDIT */
1866 extern char EditorVariable[]; /* EDITOR */
1867 extern char VisualVariable[]; /* VISUAL */
1868 extern char Trap_DEBUG[]; /* DEBUG trap variable */
1869 extern char Trap_ERR[]; /* ERR trap variable */
1870 extern char ConsoleLineBuffer[]; /* Console line buffer */
1871 extern char LIT_dos[]; /* dos Literal */
1872 extern char *LIT_NewLine; /* NewLine Literal */
1873 extern char *LIT_BadID; /* Bad Identifier literal */
1874 extern char *LIT_OSname; /* OS name */
1875 extern char LIT_export[]; /* export literal */
1876 extern char LIT_history[]; /* history literal */
1877 extern char LIT_REPLY[]; /* Reply literal */
1878 extern char LIT_exit[]; /* Exit literal */
1879 extern char LIT_exec[]; /* Exec literal */
1880 extern char LIT_done[]; /* done literal */
1881 extern char LIT_LINES[]; /* LINES literal */
1882 extern char LIT_COLUMNS[]; /* COLUMNS literal */
1883 extern char *LIT_2Strings; /* 2 String concat */
1884 extern char *LIT_3Strings; /* 3 string concat */
1885 extern char *ListVarFormat; /* List variable format */
1886 extern char *Outofmemory1; /* Out of memory string */
1887 extern char *LIT_Emsg; /* Error message format */
1888 extern char *LIT_SyntaxError; /* Syntax error */
1889 extern char *LIT_BadArray; /* Bad Array value */
1890 extern char *LIT_ArrayRange; /* subscript out of range */
1891 extern char *LIT_BNumber; /* [%d] */
1892 extern char *LIT_Invalidfunction; /* Invalid function name */
1893 extern char *LIT_AllowTTY; /* Allow Psuedo TTYs */
1894 extern char *LIT_IsReadonly; /* is readonly */
1895 extern char LIT_Test[]; /* Test function */
1896 extern char *sOpenReadMode; /* Open file in read mode */
1897 extern char *sOpenWriteMode; /* Open file in write mode */
1898 extern char *sOpenAppendMode; /* Open file in append mode */
1899 extern char *sOpenWriteBinaryMode; /* Open file in append mode */
1900 extern int MaximumColumns; /* Max columns */
1901 extern int MaximumLines; /* Max Lines */
1902 extern int StartCursorPosition; /* Start cursor position */
1903 
1904 #if (OS_TYPE == OS_OS2) || (OS_TYPE == OS_NT)
1905 extern void SetWindowName (char *); /* Set the Window Name */
1906 #else
1907 # define SetWindowName(a)
1908 #endif
1909 
1910 /*
1911  * Note the the following global structure is used to pass session
1912  * information around. If the value of the Environment field is
1913  * (char *)NULL, then the parent environment is used. If the value is
1914  * (char *)1, then the environment is built from the current exported
1915  * environment. Otherwise the value of Environment is used as the
1916  * environment
1917  */
1918 
1919 #if (OS_TYPE == OS_OS2)
1920 extern STARTDATA *SessionControlBlock; /* Start a session info */
1921 extern STARTDATA PM_SessionControlBlock; /* PM session defaults */
1922 extern STARTDATA DOS_SessionControlBlock; /* DOS session defaults */
1923 #endif
1924 
1925 /*
1926  * SubShell Save Structure
1927  */
1928 
1929 typedef struct subshell {
1930  int depth; /* Sub_Shell Depth */
1931  unsigned int GFlags; /* Global flags */
1932  long Eflags; /* single letter flags */
1933  void *OldVariableTree; /* Header start */
1935 
1936 extern S_SubShell *SubShells; /* Save Vars array */
1937 extern int NSubShells; /* Number of entries */
1938 extern int MSubShells; /* Max Number of entries */
1939 
1940 
1941 /*
1942  * Extract field from a line
1943  */
1944 
1945 typedef struct Fields {
1946  FILE *FP; /* File handler */
1947  char *Line; /* Line buffer */
1948  int LineLength; /* Line Length */
1949  Word_B *Fields; /* ptr to the start of fields */
1951 
1952 extern int ExtractFieldsFromLine (LineFields *);
1953 extern Word_B *SplitString (char *, Word_B *);
1954 
1955 /*
1956  * Type of processing required by executable program.
1957  */
1958 
1959 typedef struct ExecutableMode {
1960  char *Name;
1961  unsigned int Flags;
1962  unsigned char FieldSep;
1964 
1965 extern void CheckProgramMode (char *, ExeMode *);
1966 extern ExeMode ExecProcessingMode; /* Current executable mode */
1967 
1968 /* Flags set a bit to indicate program mode */
1969 
1970 #define EP_NONE 0x0000 /* Use PSP command line */
1971 #define EP_DOSMODE 0x0001 /* Use DOS mode extended line */
1972 #define EP_UNIXMODE 0x0002 /* Use UNIX mode extended line */
1973 #define EP_NOEXPAND 0x0004 /* Use -f for this command */
1974 #define EP_ENVIRON 0x0008 /* Use environ for variable */
1975 #define EP_NOSWAP 0x0010 /* Do not swap for this command */
1976 #define EP_EXPORT 0x0040 /* Use -m for this command */
1977 #define EP_CONVERT 0x0080 /* Use conversion */
1978 #define EP_NOWORDS 0x0100 /* Do word expansion */
1979 #define EP_NOQUOTE 0x0200 /* No quote protection */
1980 #define EP_IGNTYPE 0x0400 /* Ignore exe type (DOS only) */
1981 #define EP_PSEUDOTTY 0x0800 /* Child shells allow psuedo tty*/
1982 #define EP_QUOTEWILD 0x1000 /* Quote wildcards */
1983 
1984 /*
1985  * storage allocation
1986  */
1987 
1988 extern int MemoryAreaLevel; /* current allocation area */
1989 
1990 /* Functions */
1991 
1992 extern void main (int, char **);
1993 
1994 extern void ShellErrorMessage (char *, ...);
1995 extern void PrintErrorMessage (char *, ...);
1996 extern int PrintWarningMessage (char *, ...);
1997 extern void CompilingError (void);
1998 
1999 extern void ExitTheShell (bool);
2000 extern void FinalExitCleanUp (int);
2001 
2002 extern void TerminateCurrentEnvironment (int);
2003 extern void CreateNewEnvironment (void);
2004 extern void QuitCurrentEnvironment (void);
2005 
2006 extern void InterruptSignalled (int);
2007 extern void TerminateSignalled (int);
2008 extern void RunTrapCommand (int);
2009 
2010 extern void SetShellSwitches (void);
2011 extern Word_B *AddWordToBlock (char *, Word_B *);
2012 extern char **GetWordList (Word_B *);
2013 extern int WordBlockSize (Word_B *);
2014 extern char *IntegerToString (int);
2015 extern char *GenerateTemporaryFileName (void);
2016 extern int (*IsCommandBuiltIn (char *, int *))(int, char **);
2017 extern char *BuildNextFullPathName (char *, char *, char *);
2018 extern int LookUpSymbol (char *);
2019 extern int GetNumericValue (char *);
2020 extern bool ConvertNumericValue (char *, long *, int);
2021 extern char *BuildFileName (char *);
2022 extern int CreateGlobalVariableList (unsigned int);
2023 extern void DeleteGlobalVariableList (void);
2024 extern Word_B *AddParameter (char *, Word_B *, char *);
2025 extern char *BuildOS2String (char **, char);
2026 extern char *GenerateFullExecutablePath (char *);
2027 
2028 #if (OS_TYPE != OS_DOS)
2029 extern char *GetOSSystemErrorMessage (OSCALL_RET);
2030 #endif
2031 
2032 extern int RestoreStandardIO (int, bool);
2033 extern void RestoreCurrentDirectory (char *);
2034 extern bool GotoDirectory (char *, unsigned int);
2035 extern void RestoreEnvironment (int, int);
2036 extern bool CheckForRestrictedShell (char *);
2037 extern void OutputUserPrompt (char *);
2038 extern void DisplayLineWithControl (char *);
2039 extern void GetCurrentDirectoryPath (void);
2040 extern int OpenForExecution (char *, char **, int *);
2041 extern int ProcessOutputMetaCharacters (char **);
2042 extern char *ConvertPathToFormat (char *, char, char);
2043 extern int CheckForScriptFile (char *, char **, int *);
2044 extern void PrintVersionNumber (FILE *);
2045 
2046 /*
2047  * Smaller version of fputs & fputc
2048  */
2049 
2050 extern int feputs (char *);
2051 extern int foputs (char *);
2052 extern int feputc (int);
2053 
2054 #if (OS_TYPE == OS_OS2) && (OS_SIZE == OS_32)
2055 extern int PrintTimes (void);
2056 #endif
2057 
2058 #if (OS_TYPE == OS_NT)
2059 extern int PrintTimes (void);
2060 extern BOOL CtrlHandler (DWORD);
2061 #endif
2062 
2063 #ifdef OS_SWAPPING
2064 extern void ClearSwapFile (void);
2065 #else
2066 # define ClearSwapFile()
2067 #endif
2068 
2069 extern void ClearExtendedLineFile (void);
2070 
2071 extern bool GeneralPatternMatch (char *, unsigned char *, bool, char **,
2072  int);
2073 extern bool SuffixPatternMatch (char *, char *, char **, int);
2074 extern int CountNumberArguments (char **);
2075 extern int SortCompare (const void *, const void *);
2076 
2077 extern long EvaluateMathsExpression (char *);
2078 extern bool ValidMathsExpression (char *, long *);
2079 
2080 /*
2081  * Compiling and executing parse tree
2082  */
2083 
2084 extern C_Op *BuildParseTree (Source *);
2085 extern int ExecuteParseTree (C_Op *, int, int, int);
2086 extern int ScanNextToken (int);
2087 
2088 #ifdef OS_SWAPPING
2089 extern int SA_spawn (char **);
2090 #endif
2091 
2092 extern int ExecuteACommand (char **, int);
2093 extern int RunACommand (Source *, char **);
2094 extern int FindLocationOfExecutable (char *, char *);
2095 
2096 extern int ReMapIOHandler (int);
2097 
2098 extern char **ExpandWordList (char **, int, ExeMode *);
2099 extern char *ExpandAString (char *, int);
2100 extern char *substitute (char *, int);
2101 extern char *ExpandOneStringFirstComponent (char *, int);
2102 extern char **BuildCompletionList (char *, size_t, int *, bool);
2103 extern size_t GetCommonPartOfFileList (char **);
2104 
2105 extern bool ChangeInitialisationValue (char *, int);
2106 extern void Configure_Keys (void);
2107 
2108 /*
2109  * Keyboard Input
2110  */
2111 
2112 extern bool RingWarningBell (void);
2113 #if (OS_TYPE == OS_DOS)
2114 extern unsigned char Poll_Keyboard (void);
2115 #else
2116 # define Poll_Keyboard()
2117 #endif
2118 
2119 extern void PositionCursorInColumnZero (void);
2120 extern int GetConsoleInput (void);
2121 extern int GetDescriptorType (int);
2122 extern bool IsDirectory (char *);
2123 extern int GetEOFKey (void);
2124 extern int LookUpKeyBoardFunction (unsigned char, unsigned char);
2125 extern int ReadCursorPosition (void);
2126 extern void SetCursorPosition (int);
2127 extern bool ClearScreen (void);
2128 extern void PrintAList (int, char **);
2129 extern void GetScreenParameters (void);
2130 extern void SetCursorShape (bool);
2131 extern void EMACS_Initialisation (void);
2132 
2133 /* read the keyboard */
2134 
2135 extern unsigned char ReadKeyBoard (unsigned char *);
2136 
2137 #define KT_FUNCTION 0 /* Functionkey */
2138 #define KT_ALTFUNCTION 0xff /* ALT key pressed */
2139 #define KT_RESIZE 0xfe /* Window re-sized */
2140 
2141 #if defined (FLAGS_EMACS) || defined (FLAGS_VI) || defined (FLAGS_GMACS)
2142 extern int EditorInput (void);
2143 #endif
2144 
2145 #if defined (FLAGS_EMACS) || defined (FLAGS_GMACS)
2146 extern int BindKeyStroke (char *, char *, bool);
2147 extern unsigned char GetFunctionKeyMap (int, unsigned char *);
2148 #endif
2149 
2150 /*
2151  * Keyboard functions
2152  */
2153 
2154 #define KF_SCANBACKWARD 0x00 /* Scan backwards in history */
2155 #define KF_SCANFOREWARD 0x01 /* Scan forewards in history */
2156 #define KF_PREVIOUS 0x02 /* Previous command */
2157 #define KF_NEXT 0x03 /* Next command */
2158 #define KF_LEFT 0x04 /* Left one character */
2159 #define KF_RIGHT 0x05 /* Right one character */
2160 #define KF_WORDRIGHT 0x06 /* Right one word */
2161 #define KF_WORDLEFT 0x07 /* Left one word */
2162 #define KF_START 0x08 /* Move to start of line */
2163 #define KF_CLEAR 0x09 /* Clear input line */
2164 #define KF_FLUSH 0x0a /* Flush to end of line */
2165 #define KF_END 0x0b /* End of line */
2166 #define KF_INSERT 0x0c /* Insert mode switch */
2167 #define KF_DELETERIGHT 0x0d /* Delete right character */
2168 #define KF_DELETELEFT 0x0e /* Delete left character */
2169 #define KF_COMPLETE 0x0f /* Complete file name */
2170 #define KF_DIRECTORY 0x10 /* Complete directory function */
2171 #define KF_CLEARSCREEN 0x11 /* Clear screen */
2172 #define KF_JOBS 0x12 /* Print Job tree */
2173 #define KF_TRANSPOSE 0x13 /* Transpose characters */
2174 #define KF_QUOTE 0x14 /* Quote character */
2175 #define KF_END_FKEYS 0x15 /* End of function keys */
2176 
2177 /*
2178  * Other init file codes
2179  */
2180 
2181 #define KF_RINGBELL 0x15 /* Ring bell */
2182 #define KF_HALFHEIGTH 0x16 /* Half height cursor */
2183 #define KF_INSERTMODE 0x17 /* Overstrike or Insert */
2184 #define KF_INSERTCURSOR 0x18 /* Enable insert cursor */
2185 #define KF_ROOTDRIVE 0x19 /* Root drive */
2186 #define KF_EOFKEY 0x1a /* EOF value */
2187 
2188 /*
2189  * Variable Name functions
2190  */
2191 
2192 extern void UnSetVariable (char *, int, bool);
2193 extern void SetVariableStatus (char *, int);
2194 extern void SetVariableArrayStatus (char *, int, int);
2195 extern void ClearVariableStatus (char *, int);
2196 extern char *GetVariableAsString (char *, bool);
2197 extern char *GetVariableArrayAsString (char *, int, bool);
2198 extern long GetVariableAsNumeric (char *);
2199 extern long GetVariableArrayAsNumeric (char *, int);
2200 extern int CountVariableArraySize (char *);
2201 extern void SetVariableFromString (char *, char *);
2202 extern void SetVariableArrayFromString (char *, int, char *);
2203 extern void SetVariableFromNumeric (char *, long);
2204 extern void SetVariableArrayFromNumeric (char *, int, long);
2205 extern void HandleSECONDandRANDOM (void);
2206 extern bool AssignVariableFromString (char *, int *);
2207 extern bool GetVariableName (char *, long *, char **, bool *);
2208 extern char IsValidVariableName (char *);
2209 extern VariableList *LookUpVariable (char *, int, bool);
2210 extern int SearchVariable (const void *, const void *);
2211 extern void BuildExtensionLists (void);
2212 
2213 /*
2214  * Some missing EMX functions
2215  */
2216 
2217 #if defined (__EMX__)
2218 extern char *ltoa (long, char *, int);
2219 extern int cwait (int *, int, int);
2220 #endif
2221 
2222 /*
2223  * Memory management
2224  */
2225 
2226 extern char *AllocateMemoryCell (size_t);
2227 extern void ReleaseMemoryCell (void *);
2228 extern void ReleaseAList (char **);
2229 extern void ReleaseMemoryArea (int);
2230 extern void SetMemoryAreaNumber (void *, int);
2231 extern int GetMemoryAreaNumber (void *);
2232 extern void *DuplicateMemoryCell (void *);
2233 extern void *GetAllocatedSpace (size_t);
2234 extern void *ReAllocateSpace (void *, size_t);
2235 extern char *StringSave (char *);
2236 extern char *StringCopy (char *);
2237 extern size_t GetMemoryCellSize (void *);
2238 
2239 #ifdef DEBUG_MEMORY
2240 extern void DumpMemoryCells (int);
2241 #define exit(x) DumpMemoryCells (x)
2242 #endif
2243 
2244 /*
2245  * UNIX File I/O function emulation
2246  */
2247 
2248 extern int S_open (bool, char *, int);
2249 extern int S_close (int, bool);
2250 extern void S_fclose (FILE *, bool);
2251 extern bool S_stat (char *, struct _stat *);
2252 extern int S_dup (int);
2253 extern int S_dup2 (int, int);
2254 extern bool S_access (char *, int);
2255 extern bool S_chdir (char *);
2256 extern bool S_getcwd (char *, int);
2257 extern int S_Remap (int, int);
2258 extern int OpenAPipe (void);
2259 extern void CloseThePipe (int);
2260 extern void CloseAllHandlers (void);
2261 
2262 #if (OS_TYPE == OS_UNIX)
2263 # define CheckDOSFileName(a) (a)
2264 # define GetCurrentDrive() 0
2265 # define SetCurrentDrive(a) -1
2266 # define GetDriveLetter(a) 0
2267 # define GetDriveNumber(a) 0
2268 # define GetRootDiskDrive() 0
2269 #else
2270 extern char *CheckDOSFileName (char *);
2271 extern unsigned int GetCurrentDrive (void);
2272 extern int SetCurrentDrive (unsigned int);
2273 extern char GetDriveLetter (unsigned int);
2274 extern unsigned int GetDriveNumber (char);
2275 extern int GetRootDiskDrive (void);
2276 #endif
2277 
2278 extern int CloseFile (FILE *);
2279 extern FILE *FOpenFile (char *, char *);
2280 extern FILE *MyReOpenFile (int, char *);
2281 extern void FlushStreams (void);
2282 extern void ChangeFileDescriptorStatus (int, bool);
2283 
2284 /*
2285  * Shell Functions
2286  */
2287 
2288 #define PF_MODE_NORMAL 0 /* Normal command */
2289 #define PF_MODE_ASYNC 1 /* Async command */
2290 #define PF_MODE_COPROC 2 /* Co-process command */
2291 #define PF_MODE_NO 3 /* No mode */
2292 
2293 extern FunctionList *LookUpFunction (char *, bool);
2294 extern bool SaveFunction (C_Op *);
2295 extern void DeleteFunction (C_Op *);
2296 extern void PrintFunction (C_Op *, int);
2297 extern C_Op *CopyFunction (C_Op *);
2298 extern int PrintAllFunctions (void);
2299 extern void DeleteAllFunctions (void);
2300 
2301 /*
2302  * Alias processing
2303  */
2304 
2305 extern AliasList *LookUpAlias (char *, bool);
2306 extern void DeleteAlias (char *);
2307 extern bool SaveAlias (char *, char *, bool);
2308 extern void PrintAlias (char *);
2309 extern bool IsValidAliasName (char *, bool);
2310 extern void UnTrackAllAliases (void);
2311 extern int PrintAllAlias (bool);
2312 
2313 /*
2314  * Here document processing
2315  */
2316 
2317 extern void ScrapHereList (void);
2318 extern void FreeAllHereDocuments (int);
2319 extern void SaveHereDocumentInfo (IO_Actions *);
2320 extern int OpenHereFile (char *, bool);
2321 
2322 /*
2323  * Job Processing
2324  */
2325 
2326 #if (OS_TYPE != OS_DOS)
2327 extern int AddNewJob (PID, unsigned short, char *);
2328 extern void DeleteJob (PID);
2329 extern void DeleteJobBySession (unsigned short);
2330 extern int PrintJobs (bool);
2331 extern int NumberOfActiveJobs (void);
2332 extern JobList *LookUpJob (int);
2333 extern JobList *SearchForJob (char *);
2334 extern int PrintProcessTree (pid_t);
2335 #endif
2336 
2337 /*
2338  * History Processing
2339  */
2340 
2341 extern void AddHistory (bool);
2342 extern void LoadHistory (void);
2343 extern void DumpHistory (void);
2344 extern void ClearHistory (void);
2345 extern void PrintHistory (bool, bool, int, int, FILE *);
2346 extern int GetLastHistoryEvent (void);
2347 extern int GetFirstHistoryEvent (void);
2348 extern char *GetHistoryRecord (int);
2349 
2350 #if (OS_TYPE != OS_DOS)
2351 extern char *GetLastHistoryString (void);
2352 #endif
2353 
2354 extern int SearchHistory (char *);
2355 extern void FlushHistoryBuffer (void);
2356 extern void DeleteLastHistory (void);
2357 extern char CleanUpBuffer (int, char *, int);
2358 
2359 /*
2360  * Interrupt handling
2361  */
2362 
2363 #if (OS_TYPE == OS_DOS)
2364 # if (OS_SIZE == OS_16)
2365 extern void interrupt far SW_Int24 (void); /* Int 24 New address */
2366 extern void interrupt far SW_Int23 (void); /* Int 23 New address */
2367 extern void interrupt far SW_Int00 (void); /* Int 00 New address */
2368 extern bool far SW_I23_InShell; /* In the shell */
2369 # elif !defined (__EMX__)
2370 extern int __far HardErrorHandler (unsigned int, unsigned int,
2371  unsigned int *);
2372 # endif
2373 #endif
2374 
2375 #if (OS_TYPE == OS_DOS)
2376 # if defined (__TURBOC__)
2377 # define GetInterruptVector(x) (void (interrupt far *)())getvect ((x))
2378 # define SetInterruptVector(x,y) setvect ((x), (y))
2379 # else
2380 # define GetInterruptVector(x) _dos_getvect ((x))
2381 # define SetInterruptVector(x,y) _dos_setvect ((x), (y))
2382 # endif
2383 #endif
2384 
2385 /*
2386  * XMS Driver functions
2387  */
2388 
2389 #ifdef OS_SWAPPING
2390 extern unsigned long far SW_XMS_Driver; /* XMS Driver Interface */
2391 extern int SW_XMS_Gversion (void);
2392 extern int SW_XMS_Allocate (unsigned int);
2393 extern int SW_XMS_Free (int);
2394 extern int SW_XMS_Available (void);
2395 #endif
2396 
2397 /*
2398  * Modified getopt for shell
2399  */
2400 
2401 extern int OptionIndex; /* optind */
2402 extern int OptionStart; /* start character */
2403 extern char *OptionArgument; /* optarg */
2404 
2405 extern int GetOptions (int, char **, char *, int);
2406 extern void ResetGetOptions (void);
2407 
2408 /*
2409  * Save structure for getopts command
2410  */
2411 
2412 typedef struct GetoptsIndex {
2413  int Index;
2416 
2417 extern void ResetGetoptsValues (bool);
2418 extern void GetGetoptsValues (GetoptsIndex *);
2419 extern void SaveGetoptsValues (int, int);
2420 
2421 /*
2422  * General Functions
2423  */
2424 
2425 
2426 /*
2427  * Flag values
2428  */
2429 
2430 #define GETOPT_PLUS 0x01 /* Allow plus sign */
2431 #define GETOPT_MESSAGE 0x02 /* Print error message */
2432 #define GETOPT_PRINT 0x04 /* doecho special */
2433 #define GETOPT_AMISSING 0x08 /* doset special */
2434 
2435 /*
2436  * TSEARCH Functions
2437  */
2438 
2439 typedef enum { preorder, postorder, endorder, leaf } VISIT;
2440 
2441 /*
2442  * Tree functions
2443  */
2444 
2445 extern void *tsearch (void *, void **, int (*)(const void *, const void *));
2446 extern void *tfind (void *, void **, int (*)(const void *, const void *));
2447 extern void *tdelete (void *, void **, int (*)(const void *, const void *));
2448 extern void twalk (const void *, void (*)(const void *, VISIT, int));
2449 
2450 /*
2451  * DEBUG
2452  */
2453 
2454 #ifdef DEBUG_ON
2455 # define DPRINT(a,b) db_printf b
2456 extern void db_printf (char *, ...);
2457 #else
2458 # define DPRINT(a,b)
2459 #endif
2460 
use _CRT_SECURE_NO_WARNINGS.See online help for details.char *__cdecl ltoa(long _Value, char *_Buffer, int _Radix)
#define strlwr
Definition: Utility.h:162
static integer interrupt
Definition: aptex.h:329
struct Command Command
#define far
Definition: dd.h:143
BOOL
Definition: dd.h:100
@ Number
Definition: psspecial.c:66
#define s
Definition: afcover.h:80
#define STARTDATA
Definition: cidparse.c:49
#define STDERR_FILENO
Definition: c-unistd.h:54
#define stricmp
Definition: win32lib.h:93
int pid_t
Definition: types.h:81
unsigned int DWORD
Definition: mktexlib.h:49
char SUBExtension[]
Definition: sh6.c:236
void RestoreCurrentDirectory(char *)
Definition: sh3.c:840
int SA_spawn(char **)
struct subshell S_SubShell
Break_C * Break_List
Definition: sh6.c:144
int _osminor
Definition: sh.h:2461
char * GetVariableAsString(char *, bool)
Definition: sh1.c:3578
void ClearSwapFile(void)
Definition: system.c:2165
char CurrentDirLiteral[]
Definition: sh6.c:201
bool S_chdir(char *)
Definition: sh8.c:1745
char ** ParameterArray
Definition: sh6.c:117
bool GetVariableName(char *, long *, char **, bool *)
Definition: sh1.c:1618
void * tdelete(void *, void **, int(*)(const void *, const void *))
int MemoryAreaLevel
Definition: sh6.c:379
#define IDENT
Definition: sh.h:1338
void CloseAllHandlers(void)
Definition: sh5.c:1161
void DeleteGlobalVariableList(void)
Definition: sh1.c:1757
char LastWordVariable[]
Definition: sh6.c:244
char VBSExtension[]
Definition: sh6.c:230
void DeleteAlias(char *)
Definition: sh10.c:1353
bool UseConsoleBuffer
Definition: sh6.c:124
int yynerrs
Definition: pl-parser.c:1372
void EMACS_Initialisation(void)
Definition: sh13.c:4649
int GetEOFKey(void)
Definition: sh9.c:2801
int far SW_fp
void SetShellSwitches(void)
Definition: sh1.c:907
char * GetVariableArrayAsString(char *, int, bool)
Definition: sh1.c:3587
unsigned int far SW_Blocks
unsigned int far etext
char RandomVariable[]
Definition: sh6.c:213
void SetVariableArrayStatus(char *, int, int)
Definition: sh1.c:3362
char ShellVariableName[]
Definition: sh6.c:205
char LIT_REPLY[]
Definition: sh6.c:261
int GetRootDiskDrive(void)
Definition: sh9.c:2788
C_Op * CopyFunction(C_Op *)
Definition: sh10.c:1251
int S_close(int, bool)
Definition: sh8.c:448
char * LastUserPrompt1
Definition: sh6.c:193
char JSExtension[]
Definition: sh6.c:231
void ClearHistory(void)
Definition: sh9.c:1593
char CMDExtension[]
Definition: sh6.c:229
char LIT_COLUMNS[]
Definition: sh6.c:263
int SW_XMS_Available(void)
char * LIT_3Strings
Definition: sh6.c:268
void * tfind(void *, void **, int(*)(const void *, const void *))
int RunACommand(Source *, char **)
Definition: sh3.c:4123
int Swap_Mode
Definition: sh6.c:141
int BindKeyStroke(char *, char *, bool)
Definition: sh13.c:4549
int OpenForExecution(char *, char **, int *)
Definition: sh8.c:778
unsigned char Poll_Keyboard(void)
char ** ExpandWordList(char **, int, ExeMode *)
Definition: sh4.c:178
void * VariableTree
Definition: sh6.c:190
char Trap_ERR[]
Definition: sh6.c:252
void SetCursorPosition(int)
Definition: sh9.c:924
char * GetHistoryRecord(int)
Definition: sh9.c:1294
char LIT_LINES[]
Definition: sh6.c:262
long GetVariableAsNumeric(char *)
Definition: sh1.c:3556
int ReadCursorPosition(void)
Definition: sh9.c:853
void FlushStreams(void)
Definition: sh8.c:1646
void BuildExtensionLists(void)
Definition: sh3.c:2527
void twalk(const void *, void(*)(const void *, VISIT, int))
char OptArgVariable[]
Definition: sh6.c:245
char * sOpenWriteMode
Definition: sh6.c:291
char far path_line[]
bool ConvertNumericValue(char *, long *, int)
Definition: system.c:1922
char LIT_Test[]
Definition: sh6.c:276
int Execute_stack_depth
Definition: sh6.c:188
char * IntegerToString(int)
Definition: sh1.c:1171
char PS3[]
Definition: sh6.c:197
int RestoreStandardIO(int, bool)
Definition: sh8.c:692
int GetFirstHistoryEvent(void)
Definition: sh9.c:2469
unsigned char ReadKeyBoard(unsigned char *)
Definition: sh9.c:2275
char * ShellOptionsVariable
Definition: sh6.c:210
int MSubShells
Definition: sh6.c:184
void ClearVariableStatus(char *, int)
Definition: sh1.c:3381
char PS1[]
Definition: sh6.c:195
struct FunctionList FunctionList
bool ChangeInitialisationValue(char *, int)
Definition: sh9.c:2357
char * ExpandAString(char *, int)
Definition: sh4.c:244
char * LIT_AllowTTY
Definition: sh6.c:274
void RunTrapCommand(int)
Definition: sh1.c:1362
int InterruptTrapPending
Definition: sh6.c:187
void * GetAllocatedSpace(size_t)
Definition: sh1.c:1241
void SetVariableFromString(char *, char *)
Definition: sh1.c:3415
char * LIT_BNumber
Definition: sh6.c:272
unsigned int GetCurrentDrive(void)
Definition: sh8.c:1060
unsigned int ShellGlobalFlags
Definition: sh6.c:130
#define SetWindowName(a)
Definition: sh.h:1907
size_t GetMemoryCellSize(void *)
Definition: sh1.c:1299
bool RestrictedShellFlag
Definition: sh6.c:147
int ExecuteParseTree(C_Op *, int, int, int)
Definition: sh3.c:265
int GetDescriptorType(int)
Definition: sh8.c:974
char PS4[]
Definition: sh6.c:198
bool S_access(char *, int)
Definition: sh8.c:1730
void * AliasTree
Definition: sh6.c:153
int ScanNextToken(int)
Definition: sh5.c:153
void QuitCurrentEnvironment(void)
Definition: sh1.c:1126
void AddHistory(bool)
Definition: sh9.c:1414
void PrintHistory(bool, bool, int, int, FILE *)
Definition: sh9.c:2489
int ParameterCount
Definition: sh6.c:118
char SecondsVariable[]
Definition: sh6.c:212
char CurrentLexIdentifier[64+1]
Definition: sh6.c:346
void SaveGetoptsValues(int, int)
Definition: sh7.c:815
int CloseFile(FILE *)
Definition: sh8.c:1626
char StatusVariable[]
Definition: sh6.c:211
char HomeVariableName[]
Definition: sh6.c:204
int CountNumberArguments(char **)
Definition: system.c:1950
int ExecuteACommand(char **, int)
Definition: sh3.c:1300
char * LIT_SyntaxError
Definition: sh6.c:269
char CleanUpBuffer(int, char *, int)
Definition: sh9.c:2844
struct ExecutableMode ExeMode
char PS2[]
Definition: sh6.c:196
YYSTYPE yylval
Definition: pl-parser.c:1370
int MaximumLines
Definition: sh6.c:278
void OutputUserPrompt(char *)
Definition: sh1.c:2325
int _osmode
Definition: sh.h:2461
void S_fclose(FILE *, bool)
Definition: sh8.c:544
void SetCursorShape(bool)
Definition: sh9.c:790
void SetVariableStatus(char *, int)
Definition: sh1.c:3349
char * ComspecVariable
Definition: sh6.c:208
void interrupt far SW_Int24(void)
bool AssignVariableFromString(char *, int *)
Definition: sh1.c:1579
bool HistoryEnabled
Definition: sh6.c:149
void ClearExtendedLineFile(void)
Definition: system.c:946
char * LIT_OSname
Definition: sh6.c:97
bool far SW_I23_InShell
int ExitStatus
Definition: sh6.c:119
Source * source
Definition: afm2tfm.c:928
FILE * FOpenFile(char *, char *)
Definition: sh8.c:1587
void DeleteAllFunctions(void)
Definition: sh10.c:1009
char LIT_exit[]
Definition: sh6.c:257
ExeMode ExecProcessingMode
Definition: sh6.c:356
void FinalExitCleanUp(int)
Definition: sh1.c:3744
void interrupt far SW_Int23(void)
bool ProcessingEXECCommand
Definition: sh6.c:123
void ResetGetoptsValues(bool)
Definition: sh7.c:802
char * LastUserPrompt
Definition: sh6.c:192
char * sOpenAppendMode
Definition: sh6.c:292
char PathExtsLiteral[]
Definition: sh6.c:203
bool SaveAlias(char *, char *, bool)
Definition: sh10.c:1298
unsigned int far SW_MinESpace
unsigned int GetDriveNumber(char)
Definition: sh8.c:3400
int SearchHistory(char *)
Definition: sh9.c:2517
C_Op * compile(Source *s)
int doexec(C_Op *)
Definition: sh7.c:2127
int BaseOS
Definition: sh6.c:116
char * CheckDOSFileName(char *)
Definition: sh8.c:1298
char * PWDVariable
Definition: sh6.c:222
char ConsoleLineBuffer[]
Definition: sh6.c:382
long flags
Definition: t4ht.c:1169
void RestoreEnvironment(int, int)
Definition: sh3.c:1120
void PrintErrorMessage(char *,...)
Definition: sh1.c:1053
FunctionList * LookUpFunction(char *, bool)
Definition: sh10.c:915
char * GenerateFullExecutablePath(char *)
Definition: system.c:1309
void * tsearch(void *, void **, int(*)(const void *, const void *))
int GetOptions(int, char **, char *, int)
Definition: sh7.c:4450
S_SubShell * SubShells
Definition: sh6.c:182
void LoadHistory(void)
Definition: sh9.c:1345
char MailCheckVariable[]
Definition: sh6.c:247
void UnTrackAllAliases(void)
Definition: sh10.c:1433
char EXEExtension[]
Definition: sh6.c:238
void ReleaseMemoryArea(int)
Definition: sh1.c:2243
char far cmd_line[]
unsigned char GetFunctionKeyMap(int, unsigned char *)
Definition: sh9.c:3001
void SetVariableArrayFromString(char *, int, char *)
Definition: sh1.c:3424
bool GotoDirectory(char *, unsigned int)
Definition: sh8.c:3521
Word_B * AddParameter(char *, Word_B *, char *)
Definition: sh8.c:1512
int NSave_IO_E
Definition: sh6.c:180
char * OptionArgument
Definition: sh6.c:370
void * FunctionTree
Definition: sh6.c:151
char * Outofmemory1
Definition: sh6.c:265
char * StringSave(char *)
Definition: sh1.c:1308
char * sOpenReadMode
Definition: sh6.c:290
int FindLocationOfExecutable(char *, char *)
Definition: system.c:716
void DeleteFunction(C_Op *)
Definition: sh10.c:1033
char * LIT_BadID
Definition: sh6.c:255
int S_Remap(int, int)
Definition: sh8.c:569
void main(int, char **)
Definition: cjpeg.c:461
int SW_XMS_Allocate(unsigned int)
void PrintVersionNumber(FILE *)
Definition: sh6.c:406
int PrintAllFunctions(void)
Definition: sh10.c:333
int(*)(int, char **) IsCommandBuiltIn(char *, int *)
Definition: sh7.c:3253
int MaximumColumns
Definition: sh6.c:277
int SortCompare(const void *, const void *)
Definition: sh4.c:1234
int far SW_Pwrite
int LookUpSymbol(char *)
Definition: sh2.c:947
C_Op * BuildParseTree(Source *)
Definition: sh2.c:886
AliasList * LookUpAlias(char *, bool)
Definition: sh10.c:1387
void PrintAList(int, char **)
Definition: sh3.c:4516
void DisplayLineWithControl(char *)
Definition: sh9.c:2755
char * ListVarFormat
Definition: sh6.c:264
char LineCountVariable[]
Definition: sh6.c:214
void SetVariableArrayFromNumeric(char *, int, long)
Definition: sh1.c:3526
long EvaluateMathsExpression(char *)
Definition: sh11.c:785
char * ExpandOneStringFirstComponent(char *, int)
Definition: sh4.c:258
void SetVariableFromNumeric(char *, long)
Definition: sh1.c:3519
char EditorVariable[]
Definition: sh6.c:249
char CDPathLiteral[]
Definition: sh6.c:200
char * LIT_IsReadonly
Definition: sh6.c:275
ShellFileEnvironment e
Definition: sh6.c:388
char LIT_done[]
Definition: sh6.c:259
struct GetoptsIndex GetoptsIndex
void SaveHereDocumentInfo(IO_Actions *)
Definition: sh5.c:1365
int OptionStart
Definition: sh6.c:369
char HistoryFileVariable[]
Definition: sh6.c:206
char ParentDirLiteral[]
Definition: sh6.c:202
struct var VariableList
void FlushHistoryBuffer(void)
Definition: sh9.c:2544
void ReleaseMemoryCell(void *)
Definition: sh1.c:2141
void ResetGetOptions(void)
Definition: sh7.c:4444
bool ValidMathsExpression(char *, long *)
Definition: sh11.c:970
char * LIT_2Strings
Definition: sh6.c:267
int WordBlockSize(Word_B *)
Definition: system.c:1779
VariableList * CurrentDirectory
Definition: sh6.c:191
Save_IO * SSave_IO
Definition: sh6.c:179
unsigned long far SW_XMS_Driver
int SearchVariable(const void *, const void *)
Definition: sh1.c:1561
void InterruptSignalled(int)
Definition: sh1.c:1195
int S_open(bool, char *, int)
Definition: sh8.c:253
unsigned char bool
Definition: sh.h:276
char KSHELLExtension[]
Definition: sh6.c:235
int SetCurrentDrive(unsigned int)
Definition: system.c:926
int AllowMultipleLines
Definition: sh6.c:126
char Trap_DEBUG[]
Definition: sh6.c:251
int SW_XMS_Free(int)
void PrintAlias(char *)
Definition: sh10.c:1272
int PrintAllAlias(bool)
Definition: sh10.c:1286
char * StringCopy(char *)
Definition: sh1.c:1325
void GetCurrentDirectoryPath(void)
Definition: sh1.c:2428
void CreateNewEnvironment(void)
Definition: sh1.c:1100
Word_B * AddWordToBlock(char *, Word_B *)
Definition: system.c:1748
void * DuplicateMemoryCell(void *)
Definition: sh1.c:1280
unsigned int far SW_Mode
void HandleSECONDandRANDOM(void)
Definition: sh1.c:3336
int GetMemoryAreaNumber(void *)
Definition: sh1.c:2314
char LIT_exec[]
Definition: sh6.c:258
char BATExtension[]
Definition: sh6.c:228
int GetConsoleInput(void)
Definition: sh9.c:302
char HistorySizeVariable[]
Definition: sh6.c:207
#define ErrorPoint
Definition: sh.h:1677
char FCEditVariable[]
Definition: sh6.c:248
void * ReAllocateSpace(void *, size_t)
Definition: sh1.c:1255
char * LIT_NewLine
Definition: sh6.c:254
int StartCursorPosition
Definition: sh6.c:134
void CheckProgramMode(char *, ExeMode *)
Definition: sh3.c:2889
void interrupt far SW_Int00(void)
char ** GetWordList(Word_B *)
Definition: sh8.c:1483
size_t GetCommonPartOfFileList(char **)
Definition: sh9.c:2974
void GetGetoptsValues(GetoptsIndex *)
Definition: sh7.c:828
FunctionList * CurrentFunction
Definition: sh6.c:152
char * substitute(char *, int)
Definition: sh4.c:158
char LIT_dos[]
Definition: sh6.c:253
char * BuildOS2String(char **, char)
Definition: system.c:1788
bool IsValidAliasName(char *, bool)
Definition: sh10.c:1418
char * LIT_Invalidfunction
Definition: sh6.c:273
int _osmajor
Definition: sh1.c:1
int LookUpKeyBoardFunction(unsigned char, unsigned char)
Definition: sh9.c:2864
char COMExtension[]
Definition: sh6.c:239
void ShellErrorMessage(char *,...)
Definition: sh1.c:1032
char * sOpenWriteBinaryMode
Definition: sh6.c:293
unsigned int far SW_intr
char * LIT_ArrayRange
Definition: sh6.c:271
int S_dup2(int, int)
Definition: sh8.c:614
char LGExtension[]
Definition: sh6.c:237
VariableList * LookUpVariable(char *, int, bool)
Definition: sh1.c:1419
void FreeAllHereDocuments(int)
Definition: sh5.c:1438
bool RingWarningBell(void)
Definition: sh9.c:2091
char * BuildNextFullPathName(char *, char *, char *)
Definition: system.c:1109
void PrintFunction(C_Op *, int)
struct AliasList AliasList
char SHELLExtension[]
Definition: sh6.c:234
int CreateGlobalVariableList(unsigned int)
Definition: sh1.c:1671
int MaxNumberofFDs
Definition: sh6.c:131
void DumpHistory(void)
Definition: sh9.c:1568
Break_C * Return_List
Definition: sh6.c:145
char * DirectorySeparator
Definition: sh6.c:243
char PathLiteral[]
Definition: sh6.c:199
int feputs(char *)
Definition: sh8.c:3385
int ReMapIOHandler(int)
Definition: sh5.c:1216
bool ChangeInitLoad
Definition: sh6.c:129
char LIT_export[]
Definition: sh6.c:256
void SetMemoryAreaNumber(void *, int)
Definition: sh1.c:2302
int CountVariableArraySize(char *)
Definition: sh1.c:1535
bool GeneralPatternMatch(char *, unsigned char *, bool, char **, int)
Definition: sh1.c:1879
void UnSetVariable(char *, int, bool)
Definition: sh7.c:1239
unsigned long far SW_EMstart
bool S_stat(char *, struct _stat *)
Definition: sh8.c:1679
int S_dup(int)
Definition: sh8.c:555
int SW_XMS_Gversion(void)
char IsValidVariableName(char *)
Definition: system.c:1935
char * BuildFileName(char *)
Definition: sh1.c:3021
void ExitTheShell(bool)
Definition: sh1.c:943
int ExtractFieldsFromLine(LineFields *)
Definition: system.c:1140
int EditorInput(void)
Definition: sh13.c:3189
void CompilingError(void)
Definition: sh5.c:1004
char VisualVariable[]
Definition: sh6.c:250
Word_B * SplitString(char *, Word_B *)
Definition: system.c:1207
char * OldPWDVariable
Definition: sh6.c:221
bool ExpansionErrorDetected
Definition: sh6.c:120
int GetLastHistoryEvent(void)
Definition: sh9.c:2460
bool InteractiveFlag
Definition: sh6.c:122
int GetNumericValue(char *)
Definition: sh8.c:3431
unsigned long QueryApplicationType(const char *)
Definition: ptype.c:49
char * RootDirectory
Definition: sh6.c:215
FILE * MyReOpenFile(int, char *)
Definition: sh8.c:1609
struct Fields LineFields
unsigned int far SW_SBlocks
Source * pushs(int)
Definition: sh5.c:1018
char OptIndVariable[]
Definition: sh6.c:246
char * AllocateMemoryCell(size_t)
Definition: sh1.c:2071
void PositionCursorInColumnZero(void)
Definition: sh9.c:1991
int feputc(int)
Definition: sh8.c:3380
char COFFExtension[]
Definition: sh6.c:240
char * NotFound
Definition: sh6.c:241
char * LIT_BadArray
Definition: sh6.c:270
int OpenAPipe(void)
Definition: sh8.c:737
int Current_Event
Definition: sh6.c:128
bool ClearScreen(void)
Definition: sh9.c:2714
int MSave_IO_E
Definition: sh6.c:181
void TerminateCurrentEnvironment(int)
Definition: sh1.c:929
VISIT
Definition: sh.h:2439
@ postorder
Definition: sh.h:2439
@ leaf
Definition: sh.h:2439
@ endorder
Definition: sh.h:2439
@ preorder
Definition: sh.h:2439
struct brkcon Break_C
void CloseThePipe(int)
Definition: sh8.c:751
int foputs(char *)
Definition: sh8.c:3390
int CheckForScriptFile(char *, char **, int *)
Definition: sh8.c:810
struct source Source
int NSubShells
Definition: sh6.c:183
struct wdblock Word_B
char * ParameterCountVariable
Definition: sh6.c:209
int OptionIndex
Definition: sh6.c:368
#define OSCALL_RET
Definition: sh.h:650
Break_C * SShell_List
Definition: sh6.c:146
char * ENVVariable
Definition: sh6.c:223
int LastNumberBase
Definition: sh6.c:185
bool SaveFunction(C_Op *)
Definition: sh10.c:956
struct ioword IO_Actions
long GetVariableArrayAsNumeric(char *, int)
Definition: sh1.c:3563
void TerminateSignalled(int)
Definition: sh1.c:1339
bool IsDirectory(char *)
Definition: sh8.c:1262
struct save_io Save_IO
char * ConvertPathToFormat(char *, char, char)
Definition: sh1.c:2931
int ProcessOutputMetaCharacters(char **)
Definition: sh8.c:3455
void ReleaseAList(char **)
Definition: sh1.c:2126
bool SuffixPatternMatch(char *, char *, char **, int)
Definition: sh1.c:2033
char LIT_history[]
Definition: sh6.c:260
char * DeviceNameHeader
Definition: sh6.c:377
void DeleteLastHistory(void)
Definition: sh9.c:2604
void ScrapHereList(void)
Definition: sh5.c:1419
struct env ShellFileEnvironment
char GetDriveLetter(unsigned int)
Definition: sh8.c:3405
char ** BuildCompletionList(char *, size_t, int *, bool)
Definition: sh9.c:2896
void GetScreenParameters(void)
Definition: sh9.c:2054
int PrintWarningMessage(char *,...)
Definition: sh1.c:1010
void Configure_Keys(void)
Definition: sh9.c:1851
char IFS[]
Definition: sh6.c:194
char * GenerateTemporaryFileName(void)
Definition: system.c:1228
unsigned int far SW_EMSFrame
void ChangeFileDescriptorStatus(int, bool)
Definition: sh8.c:3415
bool S_getcwd(char *, int)
Definition: system.c:2320
bool CheckForRestrictedShell(char *)
Definition: sh8.c:761
char * BasicErrorMessage
Definition: sh6.c:242
char * LIT_Emsg
Definition: sh6.c:266
int OpenHereFile(char *, bool)
Definition: sh5.c:1468
Definition: sh.h:1594
int AFlags
Definition: sh.h:1597
char * name
Definition: sh.h:1595
char * value
Definition: sh.h:1596
unsigned short e_res[4]
Definition: sh.h:722
long e_lfanew
Definition: sh.h:726
unsigned short e_csum
Definition: sh.h:717
unsigned short e_maxalloc
Definition: sh.h:714
unsigned short e_oeminfo
Definition: sh.h:724
unsigned short e_cs
Definition: sh.h:719
unsigned short e_ovno
Definition: sh.h:721
unsigned short e_cp
Definition: sh.h:710
unsigned short e_oemid
Definition: sh.h:723
unsigned short e_cblp
Definition: sh.h:709
unsigned short e_sp
Definition: sh.h:716
unsigned short e_cparhdr
Definition: sh.h:712
unsigned short e_res2[10]
Definition: sh.h:725
unsigned short e_minalloc
Definition: sh.h:713
unsigned short e_lfarlc
Definition: sh.h:720
unsigned short e_ip
Definition: sh.h:718
unsigned short e_ss
Definition: sh.h:715
unsigned short e_crlc
Definition: sh.h:711
unsigned short e_magic
Definition: sh.h:708
unsigned short Machine
Definition: sh.h:871
unsigned long TimeDateStamp
Definition: sh.h:873
unsigned short SizeOfOptionalHeader
Definition: sh.h:876
unsigned short Characteristics
Definition: sh.h:877
unsigned long NumberOfSymbols
Definition: sh.h:875
unsigned short NumberOfSections
Definition: sh.h:872
unsigned long PointerToSymbolTable
Definition: sh.h:874
unsigned char MajorLinkerVersion
Definition: sh.h:882
unsigned long SizeOfHeaders
Definition: sh.h:901
unsigned long SectionAlignment
Definition: sh.h:891
unsigned long FileAlignment
Definition: sh.h:892
unsigned short Subsystem
Definition: sh.h:903
unsigned long AddressOfEntryPoint
Definition: sh.h:887
unsigned short MajorOperatingSystemVersion
Definition: sh.h:893
unsigned long CheckSum
Definition: sh.h:902
unsigned short Magic
Definition: sh.h:881
unsigned long SizeOfStackCommit
Definition: sh.h:906
unsigned long Reserved1
Definition: sh.h:899
unsigned short MinorSubsystemVersion
Definition: sh.h:898
unsigned long SizeOfUninitializedData
Definition: sh.h:886
unsigned long SizeOfImage
Definition: sh.h:900
unsigned char MinorLinkerVersion
Definition: sh.h:883
unsigned long LoaderFlags
Definition: sh.h:909
unsigned long SizeOfStackReserve
Definition: sh.h:905
unsigned long ImageBase
Definition: sh.h:890
unsigned long BaseOfData
Definition: sh.h:889
unsigned short MajorImageVersion
Definition: sh.h:895
unsigned long SizeOfInitializedData
Definition: sh.h:885
unsigned short DllCharacteristics
Definition: sh.h:904
unsigned short MajorSubsystemVersion
Definition: sh.h:897
unsigned long SizeOfHeapCommit
Definition: sh.h:908
unsigned long NumberOfRvaAndSizes
Definition: sh.h:910
unsigned short MinorImageVersion
Definition: sh.h:896
unsigned long SizeOfCode
Definition: sh.h:884
unsigned long BaseOfCode
Definition: sh.h:888
unsigned short MinorOperatingSystemVersion
Definition: sh.h:894
unsigned long SizeOfHeapReserve
Definition: sh.h:907
unsigned long Signature
Definition: sh.h:868
struct ExecNTHeader::NTFileHeader FileHeader
struct ExecNTHeader::NTOptionalHeader OptionalHeader
unsigned short ne_magic
Definition: sh.h:734
long ne_crc
Definition: sh.h:739
unsigned short ne_imptab
Definition: sh.h:753
unsigned short ne_restab
Definition: sh.h:751
long ne_nrestab
Definition: sh.h:754
unsigned short ne_enttab
Definition: sh.h:737
unsigned short ne_psegrefbytes
Definition: sh.h:761
unsigned short ne_cseg
Definition: sh.h:746
long ne_csip
Definition: sh.h:744
unsigned short ne_autodata
Definition: sh.h:741
unsigned short ne_segtab
Definition: sh.h:749
unsigned short ne_cres
Definition: sh.h:757
unsigned short ne_cmod
Definition: sh.h:747
unsigned short ne_cmovent
Definition: sh.h:755
unsigned short ne_modtab
Definition: sh.h:752
unsigned short ne_heap
Definition: sh.h:742
unsigned short ne_flags
Definition: sh.h:740
unsigned short ne_cbnrestab
Definition: sh.h:748
unsigned short ne_cbenttab
Definition: sh.h:738
unsigned char ne_ver
Definition: sh.h:735
long ne_sssp
Definition: sh.h:745
unsigned short ne_swaparea
Definition: sh.h:762
unsigned short ne_pretthunks
Definition: sh.h:760
unsigned short ne_stack
Definition: sh.h:743
unsigned short ne_align
Definition: sh.h:756
unsigned char ne_rev
Definition: sh.h:736
unsigned short ne_rsrctab
Definition: sh.h:750
unsigned char ne_flagsothers
Definition: sh.h:759
unsigned short ne_expver
Definition: sh.h:763
unsigned char ne_exetyp
Definition: sh.h:758
unsigned long e32_pageshift
Definition: sh.h:807
unsigned long e32_nrestab
Definition: sh.h:830
unsigned long e32_debuginfo
Definition: sh.h:834
unsigned long e32_ldrsize
Definition: sh.h:810
unsigned long e32_rsrctab
Definition: sh.h:816
unsigned long e32_instpreload
Definition: sh.h:836
unsigned long e32_impmod
Definition: sh.h:824
unsigned long e32_fpagetab
Definition: sh.h:822
unsigned long e32_objcnt
Definition: sh.h:813
unsigned long e32_cbnrestab
Definition: sh.h:831
unsigned long e32_eip
Definition: sh.h:803
unsigned long e32_rsrccnt
Definition: sh.h:817
unsigned long e32_preload
Definition: sh.h:829
unsigned long e32_dirtab
Definition: sh.h:820
unsigned long e32_objtab
Definition: sh.h:812
unsigned long e32_frectab
Definition: sh.h:823
unsigned short e32_cpu
Definition: sh.h:797
unsigned long e32_impproc
Definition: sh.h:826
unsigned long e32_datapage
Definition: sh.h:828
unsigned short e32_magic
Definition: sh.h:793
unsigned short e32_os
Definition: sh.h:798
unsigned long e32_fixupsize
Definition: sh.h:808
unsigned char e32_border
Definition: sh.h:794
unsigned long e32_instdemand
Definition: sh.h:838
unsigned long e32_autodata
Definition: sh.h:833
unsigned long e32_startobj
Definition: sh.h:802
unsigned long e32_pagesize
Definition: sh.h:806
unsigned long e32_heapsize
Definition: sh.h:840
unsigned long e32_esp
Definition: sh.h:805
unsigned long e32_ver
Definition: sh.h:799
unsigned long e32_mpages
Definition: sh.h:801
unsigned long e32_objmap
Definition: sh.h:814
unsigned long e32_dircnt
Definition: sh.h:821
unsigned long e32_mflags
Definition: sh.h:800
unsigned long e32_enttab
Definition: sh.h:819
unsigned long e32_fixupsum
Definition: sh.h:809
unsigned long e32_ldrsum
Definition: sh.h:811
unsigned long e32_restab
Definition: sh.h:818
unsigned long e32_debuglen
Definition: sh.h:835
unsigned char e32_worder
Definition: sh.h:795
unsigned long e32_nressum
Definition: sh.h:832
unsigned long e32_stackobj
Definition: sh.h:804
unsigned long e32_level
Definition: sh.h:796
unsigned long e32_pagesum
Definition: sh.h:827
unsigned long e32_itermap
Definition: sh.h:815
unsigned long e32_impmodcnt
Definition: sh.h:825
char * Name
Definition: sh.h:1960
unsigned char FieldSep
Definition: sh.h:1962
unsigned int Flags
Definition: sh.h:1961
Definition: sh.h:1945
FILE * FP
Definition: sh.h:1946
char * Line
Definition: sh.h:1947
Word_B * Fields
Definition: sh.h:1949
int LineLength
Definition: sh.h:1948
bool Traced
Definition: sh.h:1584
C_Op * tree
Definition: sh.h:1583
int SubIndex
Definition: sh.h:2414
int Index
Definition: sh.h:2413
Definition: sh.h:1422
unsigned int MCB_len
Definition: sh.h:1425
unsigned int MCB_pid
Definition: sh.h:1424
char MCB_type
Definition: sh.h:1423
Definition: sh.h:1540
struct brkcon * NextExitLevel
Definition: sh.h:1542
jmp_buf CurrentReturnPoint
Definition: sh.h:1541
Definition: sh.h:1381
int mode
Definition: sh.h:1384
char * command
Definition: sh.h:1382
int(* fn)(int, char **)
Definition: sh.h:1383
Definition: sh.h:1689
int * ErrorReturnPoint
Definition: sh.h:1690
unsigned long IOMap
Definition: sh.h:1691
struct env * PreviousEnvironment
Definition: sh.h:1695
Word_B * OpenStreams
Definition: sh.h:1696
char * line
Definition: sh.h:1693
Definition: sh.h:1645
short io_flag
Definition: sh.h:1647
short io_unit
Definition: sh.h:1646
char * io_name
Definition: sh.h:1648
Definition: sh.h:1226
Definition: sh.h:1569
int fp[STDERR_FILENO+1]
Definition: sh.h:1571
int depth
Definition: sh.h:1570
Definition: sh.h:1345
char * file
Definition: sh.h:1355
FILE * file
Definition: sh.h:1350
struct AliasList * Calias
Definition: sh.h:1351
int type
Definition: sh.h:1347
int line
Definition: sh.h:1354
bool echo
Definition: sh.h:1356
char * str
Definition: sh.h:1346
union source::@237 u
struct source * next
Definition: sh.h:1357
char ** strv
Definition: sh.h:1349
Definition: sh.h:1929
int depth
Definition: sh.h:1930
long Eflags
Definition: sh.h:1932
void * OldVariableTree
Definition: sh.h:1933
unsigned int GFlags
Definition: sh.h:1931
Definition: sh.h:1782
char * name
Definition: sh.h:1783
char * value
Definition: sh.h:1784
unsigned int width
Definition: sh.h:1788
unsigned long nvalue
Definition: sh.h:1786
unsigned int status
Definition: sh.h:1789
int index
Definition: sh.h:1785
unsigned int base
Definition: sh.h:1787
Definition: sh.h:1559
short w_bsize
Definition: sh.h:1560
short w_nword
Definition: sh.h:1561
char * w_words[1]
Definition: sh.h:1562
#define FILE
Definition: t1stdio.h:34
return() int(((double) *(font_tbl[cur_fnt].wtbl+(int)(*(font_tbl[cur_fnt].char_wi+(int)(ch - font_tbl[cur_fnt].char_f)% 256)))/(double)(1L<< 20)) *(double) font_tbl[cur_fnt].scale)
int pid
Definition: ttf2pfb.c:129
Definition: sh.h:1317
char * cp
Definition: sh.h:1319
struct ioword * iop
Definition: sh.h:1322
char ** wp
Definition: sh.h:1320
struct op * o
Definition: sh.h:1321
int i
Definition: sh.h:1318
#define YYSTYPE
Definition: parser.h:24