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