home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / MISC / GNU / SH164AS.ZIP / SHELL / SH6.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-02-28  |  5.5 KB  |  176 lines

  1. /* MS-DOS SHELL - Data Declarations
  2.  *
  3.  * MS-DOS SHELL - Copyright (c) 1990 Data Logic Limited and Charles Forsyth
  4.  *
  5.  * This code is based on (in part) the shell program written by Charles
  6.  * Forsyth and is subject to the following copyright restrictions:
  7.  *
  8.  * 1.  Redistribution and use in source and binary forms are permitted
  9.  *     provided that the above copyright notice is duplicated in the
  10.  *     source form and the copyright notice in file sh6.c is displayed
  11.  *     on entry to the program.
  12.  *
  13.  * 2.  The sources (or parts thereof) or objects generated from the sources
  14.  *     (or parts of sources) cannot be sold under any circumstances.
  15.  *
  16.  *    $Header: D:/SRC/SHELL/RCS/sh6.c 1.15 90/09/11 19:42:15 Ian_Stewartson Exp $
  17.  *
  18.  *    $Log:    sh6.c $
  19.  * Revision 1.15  90/09/11  19:42:15  Ian_Stewartson
  20.  * Version 1.6.4
  21.  * 
  22.  * Revision 1.14  90/08/14  23:34:49  MS_user
  23.  * Changed for release 1.6.3
  24.  * 
  25.  * Revision 1.13  90/05/15  21:10:19  MS_user
  26.  * Release 1.6.2
  27.  * 
  28.  * Revision 1.12  90/05/09  20:35:41  MS_user
  29.  * Change to release 1.6.1
  30.  * 
  31.  * Revision 1.11  90/04/25  22:38:47  MS_user
  32.  * Add initialisation for new field in IO_Args
  33.  * 
  34.  * Revision 1.10  90/04/25  09:20:39  MS_user
  35.  * Change version message processing
  36.  * 
  37.  * Revision 1.9  90/04/11  12:57:12  MS_user
  38.  * Update release date
  39.  * 
  40.  * Revision 1.8  90/04/06  17:17:46  MS_user
  41.  * RELEASE 1.6!
  42.  * 
  43.  * Revision 1.7  90/03/26  20:55:36  MS_user
  44.  * Move to beta test version
  45.  * 
  46.  * Revision 1.6  90/03/12  20:34:07  MS_user
  47.  * Add save program name variable for initialisation file
  48.  * 
  49.  * Revision 1.5  90/03/06  15:13:48  MS_user
  50.  * Set up for alpha release
  51.  * 
  52.  * Revision 1.4  90/03/05  13:52:31  MS_user
  53.  * Change in environment structure
  54.  * 
  55.  * Revision 1.3  90/02/22  16:38:56  MS_user
  56.  * Add XMS support
  57.  * 
  58.  * Revision 1.2  90/02/16  16:58:22  MS_user
  59.  * Set up 1.5 release
  60.  * 
  61.  * Revision 1.1  90/01/25  13:42:04  MS_user
  62.  * Initial revision
  63.  * 
  64.  */
  65.  
  66. #include <sys/types.h>
  67. #include <stddef.h>
  68. #include <stdio.h>
  69. #include <signal.h>
  70. #include <errno.h>
  71. #include <setjmp.h>
  72. #include <stdlib.h>
  73. #include <limits.h>
  74. #include <dirent.h>
  75. #include <unistd.h>
  76. #include <string.h>
  77. #include "sh.h"
  78.  
  79. static char    *Copy_Right1 = "MS-DOS SH Version 1.6.4 - %s (DOS %d.%d)\n";
  80. static char    *Copy_Right2 = "Copyright (c) Data Logic Ltd and Charles Forsyth 1990\n";
  81. char        **dolv;        /* Parameter array            */
  82. int        dolc;        /* Number of entries in parameter array    */
  83. int        exstat;        /* Exit status                */
  84. char        gflg;
  85. int        fn_area_number = -1;    /* Next function area number    */
  86. bool        talking = FALSE;/* interactive (talking-type wireless)    */
  87. int        execflg;    /* Exec mode                */
  88. int        multiline;    /* \n changed to ;            */
  89. int        Current_Event = 0;    /* Current history event    */
  90. int        *failpt;    /* Current fail point jump address    */
  91. int        *errpt;        /* Current error point jump address    */
  92.                 /* Swap mode                */
  93. int        Swap_Mode = SWAP_EXPAND | SWAP_DISK;
  94. Break_C        *Break_List;    /* Break list for FOR/WHILE        */
  95. Break_C        *Return_List;    /* Return list for RETURN        */
  96. Break_C        *SShell_List;    /* SubShell list for EXIT        */
  97. bool        level0 = FALSE;    /* Level Zero flag            */
  98. bool        r_flag = FALSE;    /* Restricted shell            */
  99.                 /* History processing enabled flag    */
  100. bool        History_Enabled = FALSE;
  101. Fun_Ops        *fun_list = (Fun_Ops *)NULL;    /* Function list    */
  102. Save_IO        *SSave_IO;    /* Save IO array            */
  103. int        NSave_IO_E = 0;    /* Number of entries in Save IO array    */
  104. int        MSave_IO_E = 0;    /* Max Number of entries in SSave_IO    */
  105. S_SubShell    *SubShells;    /* Save Vars array            */
  106. int        NSubShells = 0;    /* Number of entries in SubShells    */
  107. int        MSubShells = 0;    /* Max Number of entries in SubShells    */
  108.  
  109. Word_B        *wdlist;    /* Current Word List            */
  110. Word_B        *iolist;    /* Current IO List            */
  111. long        ourtrap = 0L;    /* Signal detected            */
  112. int        trapset;    /* Trap pending                */
  113. int        yynerrs;    /* yacc errors detected            */
  114. int        Execute_stack_depth;    /* execute function recursion    */
  115.                     /* depth            */
  116. Var_List    *vlist = (Var_List *)NULL;    /* dictionary        */
  117. Var_List    *path;        /* search path for commands        */
  118. Var_List    *ps1;        /* Prompt 1                */
  119. Var_List    *ps2;        /* Prompt 2                */
  120. Var_List    *C_dir;        /* Current directory            */
  121. char        *last_prompt;    /* Last prompt output            */
  122. Var_List    *ifs;        /* Inter-field separator        */
  123. char        *Program_Name;    /* Program name                */
  124. char        *home = "HOME";
  125. char        *shell = "SHELL";
  126. char        *history_file = "HISTFILE";
  127. char        *hsymbol = "#";
  128. char        *msymbol = "-";
  129. char        *spcl2 = "$`'\"";
  130.  
  131.                 /* I/O stacks                */
  132. IO_Args        ioargstack[NPUSH];
  133. IO_State    iostack[NPUSH];
  134.  
  135.                 /* Temporary I/O argument        */
  136. IO_Args        temparg = {
  137.     (char *)NULL,        /* Word                    */
  138.     (char **)NULL,        /* Word list                */
  139.     0,                /* File descriptor            */
  140.     AFID_NOBUF,            /* Buffer id                */
  141.     0L,                /* File position            */
  142.     0,                /* Offset in buffer            */
  143.     (IO_Buf *)NULL        /* Buffer                */
  144. };
  145.  
  146. int        areanum;    /* Current allocation area        */
  147. int        inparse;    /* In parser flag            */
  148. long        flags = 0L;    /* Command line flags            */
  149. char        *null = "";
  150.  
  151.                 /* Current environment            */
  152. Environ    e = {
  153.     (char *)NULL,        /* Current line buffer            */
  154.     (char *)NULL,        /* Current pointer in line        */
  155.     (char *)NULL,        /* End of line pointer            */
  156.     iostack,            /* I/O Stack pointers            */
  157.     iostack - 1,
  158.     (int *)NULL,
  159.     FALSE,            /* End of file processing        */
  160.     FDBASE,            /* Base file handler            */
  161.     (DIR *)NULL,        /* Currently open directory        */
  162.     (Environ *)NULL        /* Previous Env pointer            */
  163. };
  164.  
  165. /* The only bit of code in this module prints the version number */
  166.  
  167. void    Print_Version (fp)
  168. int    fp;
  169. {
  170.     char    buf[100];
  171.  
  172.     sprintf (buf, Copy_Right1, __DATE__, _osmajor, _osminor);
  173.     write (fp, buf, strlen (buf));
  174.     write (fp, Copy_Right2, strlen (Copy_Right2));
  175. }
  176.