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