1: # include   "../ingres.h"
   2: # include   "../aux.h"
   3: # include   "../unix.h"
   4: 
   5: # define    CLOSED      077
   6: 
   7: /*
   8: **  Initialize INGRES Process
   9: **
  10: **	All initialization for a process is performed, including
  11: **	initialization of trace info and global variables.  Typical
  12: **	call is
  13: **		initproc(procname, argv);
  14: **	with procname being a string (e.g., "PARSER"),
  15: **	argv is the parameter of main().
  16: **
  17: **	Calling this routine should be one of the first things done
  18: **	in  main().
  19: **
  20: **	Information passed in argv is as follows:
  21: **	argv[0] - line from process table
  22: **	argv[1] - pipe vector
  23: **		argv[1][0] - R_up
  24: **		argv[1][1] - W_up
  25: **		argv[1][2] - R_down
  26: **		argv[1][3] - W_down
  27: **		argv[1][4] - R_front
  28: **		argv[1][5] - W_front
  29: **	argv[2] - Fileset - unique character string for temp file names.
  30: **	argv[3] - Usercode - two character user identifier
  31: **	argv[4] - Database - database name
  32: **	argv[5->n] - Xparams - additional parameters,
  33: **		different for each process.  See .../files/proctab
  34: **		for what each process actually gets.
  35: **
  36: **	The pipe descriptors are passed with the 0100 bit set, so that
  37: **	they will show up in a readable fashion on a "ps".
  38: **
  39: **	A flag "Equel" is set if running an EQUEL program.  The flag
  40: **	is set to 1 if the EQUEL program is a 6.0 or 6.0 EQUEL program,
  41: **	and to 2 if it is a 6.2 EQUEL program.
  42: **
  43: **	User flags "[+-]x" are processed.  Note that the syntax of some of
  44: **	these are assumed to be correct.  They should be checked in
  45: **	ingres.c.
  46: **
  47: **	Signal 2 is caught and processed by 'rubcatch', which will
  48: **	eventually call 'rubproc', a user supplied routine which cleans
  49: **	up the relevant process.
  50: **
  51: **	History:
  52: **		6/29/79 (eric) (mod 6) -- Standalone variable added.
  53: */
  54: 
  55: char        *Fileset;   /* unique string to append to temp file names */
  56: char        *Usercode;  /* code to append to relation names */
  57: char        *Database;  /* database name */
  58: char        **Xparams;  /* other parameters */
  59: char        *Pathname;  /* pathname of INGRES subtree */
  60: int     R_up;       /* pipe descriptor: read from above */
  61: int     W_up;       /* pipe descriptor: write to above */
  62: int     R_down;     /* pipe descriptor: read from below */
  63: int     W_down;     /* pipe descriptor: write to below */
  64: int     R_front;    /* pipe descriptor: read from front end */
  65: int     W_front;    /* pipe descriptor: write to front end */
  66: int     W_err;      /* pipe descriptor: write error message (usually W_up */
  67: int     Equel;      /* flag set if running an EQUEL program */
  68: int     Rublevel;   /* rubout level, set to -1 if turned off */
  69: struct out_arg  Out_arg;    /* output arguments */
  70: int     Standalone; /* not standalone */
  71: 
  72: initproc(procname, argv)
  73: char    *procname;
  74: char    **argv;
  75: {
  76:     extern char *Proc_name; /* defined in syserr.c */
  77:     register char   *p;
  78:     register char   **q;
  79:     register int    fd;
  80:     extern      rubcatch(); /* defined in rub.c */
  81:     static int  reenter;
  82: 
  83:     Standalone = FALSE;
  84:     Proc_name = procname;
  85:     reenter = 0;
  86:     setexit();
  87:     if (reenter++)
  88:         exit(-1);
  89:     if (signal(2, 1) == 0)
  90:         signal(2, &rubcatch);
  91:     else
  92:         Rublevel = -1;
  93:     p = argv[1];
  94:     R_up = fd = *p++ & 077;
  95:     if (fd == CLOSED)
  96:         R_up = -1;
  97:     W_up = fd = *p++ & 077;
  98:     if (fd == CLOSED)
  99:         W_up = -1;
 100:     W_err = W_up;
 101:     R_down = fd = *p++ & 077;
 102:     if (fd == CLOSED)
 103:         R_down = -1;
 104:     W_down = fd = *p++ & 077;
 105:     if (fd == CLOSED)
 106:         W_down = -1;
 107:     R_front = fd = *p++ & 077;
 108:     if (fd == CLOSED)
 109:         R_front = -1;
 110:     W_front = fd = *p++ & 077;
 111:     if (fd == CLOSED)
 112:         W_front = -1;
 113: 
 114:     q = &argv[2];
 115:     Fileset = *q++;
 116:     Usercode = *q++;
 117:     Database = *q++;
 118:     Pathname = *q++;
 119:     Xparams = q;
 120: 
 121:     /* process flags */
 122:     for (; (p = *q) != -1 && p != NULL; q++)
 123:     {
 124:         if (p[0] != '-')
 125:             continue;
 126:         switch (p[1])
 127:         {
 128:           case '&': /* equel program */
 129:             Equel = 1;
 130:             if (p[6] != '\0')
 131:                 Equel = 2;
 132:             break;
 133: 
 134:           case 'c': /* c0 sizes */
 135:             atoi(&p[2], &Out_arg.c0width);
 136:             break;
 137: 
 138:           case 'i': /* iNsizes */
 139:             switch (p[2])
 140:             {
 141: 
 142:               case '1':
 143:                 atoi(&p[3], &Out_arg.i1width);
 144:                 break;
 145: 
 146:               case '2':
 147:                 atoi(&p[3], &Out_arg.i2width);
 148:                 break;
 149: 
 150:               case '4':
 151:                 atoi(&p[3], &Out_arg.i4width);
 152:                 break;
 153: 
 154:             }
 155:             break;
 156: 
 157:           case 'f': /* fN sizes */
 158:             p = &p[3];
 159:             fd = *p++;
 160:             while (*p != '.')
 161:                 p++;
 162:             *p++ = 0;
 163:             if ((*q)[2] == '4')
 164:             {
 165:                 atoi(&(*q)[4], &Out_arg.f4width);
 166:                 atoi(p, &Out_arg.f4prec);
 167:                 Out_arg.f4style = fd;
 168:             }
 169:             else
 170:             {
 171:                 atoi(&(*q)[4], &Out_arg.f8width);
 172:                 atoi(p, &Out_arg.f8prec);
 173:                 Out_arg.f8style = fd;
 174:             }
 175:             *--p = '.'; /* restore parm for dbu's */
 176:             break;
 177: 
 178:           case 'v': /* vertical seperator */
 179:             Out_arg.coldelim = p[2];
 180:             break;
 181: 
 182:         }
 183:     }
 184: }

Defined functions

Defined variables

Database defined in line 57; used 2 times
Fileset defined in line 55; used 1 times
Out_arg defined in line 69; used 11 times
R_down defined in line 62; used 4 times
R_front defined in line 64; used 2 times
Rublevel defined in line 68; used 1 times
  • in line 92
Standalone defined in line 70; used 1 times
  • in line 83
Usercode defined in line 56; used 1 times
W_down defined in line 63; used 5 times
W_err defined in line 66; used 1 times
W_front defined in line 65; used 2 times
W_up defined in line 61; used 7 times
Xparams defined in line 58; used 1 times

Defined macros

CLOSED defined in line 5; used 6 times
Last modified: 1980-12-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 3249
Valid CSS Valid XHTML 1.0 Strict