1: #include "hd.h"
   2: #include "mydir.h"
   3: #include <signal.h>
   4: 
   5: /* Extract data about environment */
   6: #define ENV_COUNT   3
   7: 
   8: char *env_defalt [ENV_COUNT] =          /* Defaults */
   9:     {"/bin/csh", "/", "unknown"};
  10: char *env_name   [ENV_COUNT] =          /* Names */
  11:     {"SHELL", "HOME", "TERM"};
  12: 
  13: char *envshell, *envhome, *envterm;
  14: 
  15: char **env_dest [ENV_COUNT] =           /* Place stored */
  16:     {&envshell, &envhome, &envterm};
  17: 
  18: main () {
  19: 
  20: /*  Initialize everything, then run.  */
  21: 
  22: int i;
  23: extern char * mygetenv ();
  24: 
  25: extern leave ();
  26: 
  27: comein ();
  28: 
  29: for (i = 0; i < ENV_COUNT; i++)
  30:     *env_dest [i] = mygetenv (env_name [i], env_default [i]);
  31: 
  32: signal (SIGINT, leave);
  33: tty_init (); curs_init ();
  34: erase (); printf ("Vsh %0.1f\n", VERSION);
  35: cmdldrc ();
  36: wdfile = -1;
  37: if (curdir () || enterdir (DOT) == FAILURE) leave ();
  38: tty_push (RAWMODE);
  39: 
  40: process ();
  41: }
  42: 
  43: /* Return environment value of pstr.  If none found, or the string
  44:    length is too long, the default returned */
  45: 
  46: char *mygetenv
  47: (pstr, def)
  48: char *pstr, *def; {
  49: 
  50: char *rstr; /* return value */
  51: char *getenv ();
  52: 
  53: rstr = getenv (pstr);
  54: if ((rstr == NULL) || (strlen (rstr) >= STRMAX)) return def;
  55: else return rstr;
  56: }

Defined functions

main defined in line 18; never used
mygetenv defined in line 46; used 2 times

Defined variables

env_defalt defined in line 8; never used
env_dest defined in line 15; used 1 times
  • in line 30
env_name defined in line 10; used 1 times
  • in line 30
envhome defined in line 13; used 4 times
envshell defined in line 13; used 5 times
envterm defined in line 13; used 2 times

Defined macros

ENV_COUNT defined in line 6; used 4 times
Last modified: 1980-08-11
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 786
Valid CSS Valid XHTML 1.0 Strict