Annotation of 42BSD/ingres/source/ctlmod/readinput.c, revision 1.1

1.1     ! root        1: # include      "ctlmod.h"
        !             2: # include      "pipes.h"
        !             3: # include      <resp.h>
        !             4: # include      <ingres.h>
        !             5: # include      <aux.h>
        !             6: # include      <tree.h>
        !             7: # include      <sccs.h>
        !             8: 
        !             9: SCCSID(@(#)readinput.c 7.2     2/16/81)
        !            10: 
        !            11: /*
        !            12: **  READINPUT -- read the input pipe and determine next function
        !            13: **
        !            14: **     The input pipe is read (using pb_get).  Parameters are
        !            15: **     collected and set up in the global Ctx.ctx_pv.  *ppb
        !            16: **     is set to the new function, block type, etc.
        !            17: **
        !            18: **     If an error block is read, the error routine processing
        !            19: **     is invoked.
        !            20: **
        !            21: **     Parameters:
        !            22: **             ppb -- a pointer to the pipe block to read into;
        !            23: **                     also becomes part of the return value.
        !            24: **
        !            25: **     Returns:
        !            26: **             nothing directly.
        !            27: **
        !            28: **     Side Effects:
        !            29: **             Sets Ctx.ctx_pv, Ctx.ctx_pc to the new parmv &
        !            30: **                     parmc read from the pipe.
        !            31: **             Sets the *ppb struct to indicate state, etc.
        !            32: **
        !            33: **     Trace Flags:
        !            34: **             10.0 - 10.5
        !            35: */
        !            36: 
        !            37: readinput(ppb)
        !            38: register pb_t  *ppb;
        !            39: {
        !            40:        register int    i;
        !            41: 
        !            42:        /*
        !            43:        **  Top Loop.
        !            44:        **      Executed once for each complete block read.  Normally
        !            45:        **      only executed once, but can be more if an error
        !            46:        **      block is read.
        !            47:        **
        !            48:        **      We mark Qbuf first, so we can free any parameters
        !            49:        **      when they are no longer needed (such as when they
        !            50:        **      are passed to another process).
        !            51:        */
        !            52: 
        !            53:        Ctx.ctx_pmark = markbuf(Qbuf);
        !            54: # ifdef xCTR1
        !            55:        if (tTf(10, 0))
        !            56:                lprintf("readinput: mark %d, errfn %x, ppb %x\n", Ctx.ctx_pmark, Ctx.ctx_errfn, ppb);
        !            57: # endif
        !            58: 
        !            59:        for (;;)
        !            60:        {
        !            61:                /* prime the input (reads first block) */
        !            62:                pb_prime(ppb, PB_NOTYPE);
        !            63: # ifdef xCTR2
        !            64:                if (tTf(10, 1))
        !            65:                        lprintf("readinput: type %d\n", ppb->pb_type);
        !            66: # endif
        !            67: 
        !            68:                /* if this is a response block, return immediately */
        !            69:                if (ppb->pb_type == PB_RESP)
        !            70:                {
        !            71:                        i = pb_get(ppb, (char *) &Resp, sizeof Resp);
        !            72:                        if (i != sizeof Resp)
        !            73:                                syserr("readinput: Resp sz %d", i);
        !            74: /*
        !            75:                        read_arg(ppb, &Resp.resp_rval);
        !            76: */
        !            77:                        break;
        !            78:                }
        !            79: 
        !            80:                /*
        !            81:                **  Parameter Loop.
        !            82:                **      Wander through and start reading parameters.
        !            83:                */
        !            84: 
        !            85:                for (Ctx.ctx_pc = 0; Ctx.ctx_pc < PV_MAXPC; Ctx.ctx_pc++)
        !            86:                {
        !            87:                        if (read_arg(ppb, &Ctx.ctx_pv[Ctx.ctx_pc]) == PV_EOF)
        !            88:                                break;
        !            89:                }
        !            90: 
        !            91:                /* out of loop, check for vector overflow */
        !            92:                if (Ctx.ctx_pc >= PV_MAXPC)
        !            93:                        syserr("readinput: overflow");
        !            94: 
        !            95:                /* check for error blocks */
        !            96:                if (ppb->pb_type == PB_ERR)
        !            97:                {
        !            98:                        proc_err(ppb, Ctx.ctx_pc, Ctx.ctx_pv);
        !            99:                        syserr("readinput: proc_err");
        !           100:                }
        !           101: 
        !           102: 
        !           103:                /* non-error block */
        !           104: # ifdef xCM_DEBUG
        !           105:                if (ppb->pb_type != PB_REG)
        !           106:                        syserr("readinput: pb_type %d", ppb->pb_type);
        !           107: # endif
        !           108:                Ctx.ctx_resp = ppb->pb_resp;
        !           109:                break;
        !           110:        }
        !           111: # ifdef xCTR1
        !           112:        if (tTf(10, 4))
        !           113:        {
        !           114:                lprintf("readinput: ");
        !           115:                pb_dump(ppb, FALSE);
        !           116:        }
        !           117: # endif
        !           118: }
        !           119: /*
        !           120: **  READ_ARG -- Read a single argument from pipe
        !           121: **
        !           122: **     An argument can be as simple as an integer, or as complex
        !           123: **     as a query tree.
        !           124: **
        !           125: **     Parameters:
        !           126: **             ppb -- the pipe block to read from.
        !           127: **             pparm -- the parameter descripter to put the
        !           128: **                     argument in.
        !           129: **
        !           130: **     Returns:
        !           131: **             none.
        !           132: **
        !           133: **     Side Effects:
        !           134: **             May allocate space from Qbuf for trees, etc.
        !           135: **
        !           136: **     Called By:
        !           137: **             readinput
        !           138: **
        !           139: **     Trace Flags:
        !           140: **             10.6 - 10.7
        !           141: */
        !           142: 
        !           143: read_arg(ppb, pparm)
        !           144: register pb_t  *ppb;
        !           145: register PARM  *pparm;
        !           146: {
        !           147:        auto char       ptype;
        !           148:        auto short      plen;
        !           149:        register int    i;
        !           150:        register char   *p;
        !           151:        QTREE           *q;
        !           152:        extern char     *need();
        !           153:        extern QTREE    *readqry();
        !           154: 
        !           155:        /* get the parameter type */
        !           156:        i = pb_get(ppb, &ptype, 1);
        !           157:        if (i == 0)
        !           158:        {
        !           159:                pparm->pv_type = PV_EOF;
        !           160:                pparm->pv_val.pv_str = NULL;
        !           161:                return (PV_EOF);
        !           162:        }
        !           163:        i = pb_get(ppb, (char *) &plen, 2);
        !           164:        if (i < 2)
        !           165:                syserr("readarg: pb_get %d", i);
        !           166: 
        !           167:        /* figure out the type */
        !           168:        switch (ptype)
        !           169:        {
        !           170:          case PV_INT:
        !           171: # ifdef xCM_DEBUG
        !           172:                if (plen != sizeof pparm->pv_val.pv_int)
        !           173:                        syserr("readinput: PV_INT %d", plen);
        !           174: # endif
        !           175:                pb_get(ppb, (char *) &pparm->pv_val.pv_int, plen);
        !           176:                break;
        !           177: 
        !           178:          case PV_STR:
        !           179:          case PV_TUPLE:
        !           180:                p = need(Qbuf, plen);
        !           181:                pb_get(ppb, p, plen);
        !           182:                pparm->pv_val.pv_str = p;
        !           183:                break;
        !           184: 
        !           185:          case PV_QTREE:
        !           186:                q = readqry(pb_get, (int) ppb, TRUE);
        !           187:                pparm->pv_val.pv_qtree = q;
        !           188:                break;
        !           189: 
        !           190:          case PV_EOF:
        !           191:                /* this case is allowed for the mon-par interface */
        !           192:                break;
        !           193: 
        !           194:          default:
        !           195:                syserr("readinput: type %d len %d", ptype, plen);
        !           196:        }
        !           197: 
        !           198:        /* save the type & length */
        !           199:        pparm->pv_type = ptype;
        !           200:        pparm->pv_len = plen;
        !           201: 
        !           202:        return (ptype);
        !           203: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.