1: # include   <useful.h>
   2: # include   <ingres.h>
   3: # include   <aux.h>
   4: # include   "IIglobals.h"
   5: # include   <sccs.h>
   6: # include   <errors.h>
   7: 
   8: SCCSID(@(#)IIreadinp.c	8.2	2/8/85)
   9: 
  10: 
  11: static char IInbuf[70];
  12: static char *IInb_free;
  13: 
  14: char    *
  15: IIneed(i)
  16: register    i;
  17: {
  18:     register char   *p;
  19: 
  20:     p = IInb_free;
  21:     if (IInb_free + i - IInbuf >= sizeof IInbuf)
  22:         IIsyserr("Error param overflow");
  23:     IInb_free += i;
  24:     return (p);
  25: }
  26: 
  27: IInd_init()
  28: {
  29:     IInb_free = IInbuf;
  30: }
  31: 
  32: /*
  33: **  IIREADINPUT -- read the input pipe
  34: **
  35: **	The input pipe is read (using pb_get).  Parameters are
  36: **	collected and set up in the global IIerr_pv.
  37: **
  38: **	If an error block is read, the error routine processing
  39: **	is invoked.
  40: **
  41: **	Parameters:
  42: **		ppb -- a pointer to the pipe block to read into;
  43: **			also becomes part of the return value.
  44: **
  45: **	Returns:
  46: **
  47: **	Requires:
  48: **		pb_prime, pb_get -- to read from the pipe.
  49: **		IIneed -- to get space to store things
  50: **			from the pipe.
  51: **
  52: **	History:
  53: **		8/21/79 (eric) -- written.
  54: */
  55: 
  56: IIreadinput(ppb)
  57: register pb_t   *ppb;
  58: {
  59:     register int    i;
  60:     int     pc;
  61:     char        *pv[20];
  62:     auto int    eno;
  63: 
  64:     /* if this is a response block, return immediately */
  65:     if (ppb->pb_type == PB_RESP)
  66:     {
  67:         i = IIpb_get(ppb, &IIresp, sizeof IIresp);
  68:         if (i != sizeof IIresp)
  69:             IIsyserr("readinput: IIresp sz %d", i);
  70:         IItupcnt = IIresp.resp_tups;
  71:     }
  72: 
  73:     /*
  74: 	**  Parameter Loop.
  75: 	**	Wander through and start reading parameters.
  76: 	*/
  77: 
  78:     IInd_init();
  79:     for (pc = 0 ; pc < PV_MAXPC; pc++)
  80:     {
  81:         if (IIread_arg(ppb, &pv[pc]) == PV_EOF)
  82:             break;
  83:     }
  84: 
  85:     /* out of loop, check for vector overflow */
  86:     if (pc >= sizeof pv / sizeof pv[0])
  87:         IIsyserr("readinput: overflow");
  88: 
  89:     /* check for error blocks */
  90:     if (ppb->pb_type == PB_ERR)
  91:     {
  92:         IIatoi(pv[0], &eno);
  93:         IIerror(eno, pc - 1, &pv[1]);
  94:     }
  95: }
  96: /*
  97: **  IIREAD_ARG -- Read a single argument from pipe
  98: **
  99: **	An argument can be as simple as an integer, or as complex
 100: **	as a query tree.
 101: **
 102: **	Parameters:
 103: **		ppb -- the pipe block to read from.
 104: **		pparm -- the parameter descripter to put the
 105: **			argument in.
 106: **
 107: **	Returns:
 108: **		PV_EOF -- if last arg read
 109: **
 110: **	Side Effects:
 111: **		May allocate space from Qbuf for trees, etc.
 112: **
 113: **	Requires:
 114: **		pb_get
 115: **		syserr
 116: **		need
 117: **		readqtree
 118: **
 119: **	Called By:
 120: **		readinput
 121: **
 122: **	Trace Flags:
 123: **		10.6 - 10.7
 124: */
 125: 
 126: IIread_arg(ppb, parm)
 127: register pb_t   *ppb;
 128: char        **parm;
 129: {
 130:     char        buf[20];
 131:     auto char   ptype;
 132:     auto short  plen;
 133:     register int    i;
 134:     register char   *p;
 135:     char        *ib;
 136:     int     j;
 137:     char        *IIneed();
 138:     char        *IIitos();
 139: 
 140:     /* get the parameter type */
 141:     i = IIpb_get(ppb, &ptype, 1);
 142:     if (i == 0)
 143:     {
 144:         return (PV_EOF);
 145:     }
 146:     i = IIpb_get(ppb, &plen, 2);
 147:     if (i < 2)
 148:         IIsyserr("readarg: pb_get %d", i);
 149: 
 150:     /* figure out the type */
 151:     switch (ptype)
 152:     {
 153:       case PV_INT:
 154:         IIpb_get(ppb, &j, plen);
 155:         ib = IIitos(j);
 156:         p = IIneed(j = IIlength(ib) + 1);
 157:         IIbmove(ib, p, j);
 158:         break;
 159: 
 160:       case PV_STR:
 161:         p = IIneed(plen + 1);
 162:         IIpb_get(ppb, p, plen);
 163:         p[plen] = 0;
 164:         break;
 165: 
 166:       default:
 167:         IIsyserr("readinput: type %d len %d", ptype, plen);
 168:     }
 169:     *parm = p;
 170:     return (ptype);
 171: }

Defined functions

IInd_init defined in line 27; used 1 times
  • in line 78
IIneed defined in line 14; used 3 times
IIread_arg defined in line 126; used 1 times
  • in line 81

Defined variables

IInb_free defined in line 12; used 4 times
IInbuf defined in line 11; used 3 times
Last modified: 1986-04-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 959
Valid CSS Valid XHTML 1.0 Strict