Annotation of 42BSD/ingres/source/iutil/get_tuple.c, revision 1.1

1.1     ! root        1: # include      <ingres.h>
        !             2: # include      <access.h>
        !             3: # include      <symbol.h>
        !             4: # include      <sccs.h>
        !             5: 
        !             6: SCCSID(@(#)get_tuple.c 7.1     2/5/81)
        !             7: 
        !             8: /*
        !             9: **     Routine associated with getting a tuple out of
        !            10: **     the current buffer.
        !            11: */
        !            12: 
        !            13: 
        !            14: /*
        !            15: **     Get_tuple - take the tuple specified
        !            16: **     by tid and move it to "tuple"
        !            17: */
        !            18: 
        !            19: get_tuple(d, tid, tuple)
        !            20: register DESC  *d;
        !            21: TID            *tid;
        !            22: char           *tuple;
        !            23: {
        !            24:        register char   *cp;
        !            25:        char            *get_addr();
        !            26: 
        !            27:        cp = get_addr(tid);
        !            28: 
        !            29:        if (d->reldum.relspec < 0)
        !            30:                uncomp_tup(d, cp, tuple);       /* compressed tuple */
        !            31:        else
        !            32:                bmove(cp, tuple, d->reldum.relwid);     /* uncompressed tuple */
        !            33: }
        !            34: /*
        !            35: **     Getint_tuple - get the tuple specified by
        !            36: **     tid. If possible avoid moving the tuple.
        !            37: **     Return value is address of tuple.
        !            38: */
        !            39: 
        !            40: char *
        !            41: getint_tuple(d, tid, tuple)
        !            42: register DESC  *d;
        !            43: TID            *tid;
        !            44: char           *tuple;
        !            45: {
        !            46:        register char   *cp, *ret;
        !            47:        extern char     *get_addr();
        !            48: 
        !            49:        cp = get_addr(tid);
        !            50: 
        !            51:        if (d->reldum.relspec < 0)
        !            52:        {
        !            53:                ret = tuple;
        !            54:                uncomp_tup(d, cp, ret); /* compressed tuple */
        !            55:        }
        !            56:        else
        !            57:                ret = cp;                       /* uncompressed tuple */
        !            58:        return (ret);
        !            59: }
        !            60: /*
        !            61: **     Routine to compute the address of a tuple
        !            62: **     within the current buffer.
        !            63: **     Syserr if specified tuple deleted.
        !            64: */
        !            65: 
        !            66: char *
        !            67: get_addr(tid)
        !            68: register TID   *tid;
        !            69: {
        !            70:        register int    offset;
        !            71: 
        !            72:        offset = Acc_head->linetab[-(tid->line_id & I1MASK)];
        !            73:        if (offset == 0)
        !            74:        {
        !            75:                syserr("get_addr rel=%ld tid=%ld", Acc_head->rel_tupid, *(long *)tid);
        !            76:        }
        !            77: #      ifdef xATR3
        !            78:        if (offset < 0 || offset > PGSIZE)
        !            79:                syserr("get_addr: offset=%d\n");
        !            80: #      endif
        !            81:        return (((char *) Acc_head) + offset);
        !            82: }
        !            83: /*
        !            84: **     Uncompress - decompress the tuple at address cp
        !            85: **     according to descriptor.
        !            86: */
        !            87: 
        !            88: uncomp_tup(d, cp, tuple)
        !            89: register DESC  *d;
        !            90: char           *cp;
        !            91: char           *tuple;
        !            92: {
        !            93:        register char   *src, *dst;
        !            94:        int             i, j;
        !            95: 
        !            96:        dst = tuple;
        !            97:        src = cp;
        !            98: 
        !            99:        /* for each domain, copy and blank pad if char */
        !           100:        for (i = 1; i <= d->reldum.relatts; i++)
        !           101:        {
        !           102:                j = d->relfrml[i] & I1MASK;
        !           103:                if (d->relfrmt[i] == CHAR)
        !           104:                {
        !           105:                        while (j--)
        !           106:                        {
        !           107:                                if ((*dst++ = *src++) == NULL)
        !           108:                                {
        !           109:                                        /* back up one */
        !           110:                                        dst--;
        !           111:                                        j++;
        !           112:                                        break;
        !           113:                                }
        !           114:                        }
        !           115: 
        !           116:                        /* blank pad if necessary */
        !           117:                        while (j-- > 0)
        !           118:                                *dst++ = ' ';
        !           119:                }
        !           120:                else
        !           121:                {
        !           122:                        while (j--)
        !           123:                                *dst++ = *src++;
        !           124:                }
        !           125:        }
        !           126: }
        !           127: /*
        !           128: **     Check if a line number is valid.
        !           129: **     If linenumber is illegal return AMINVL_ERR
        !           130: **     if Line has been deleted return 2
        !           131: **     else return 0
        !           132: */
        !           133: 
        !           134: invalid(tid)
        !           135: register TID   *tid;
        !           136: {
        !           137:        register int    i;
        !           138: 
        !           139:        i = tid->line_id & I1MASK;
        !           140: 
        !           141:        if (i >= Acc_head->nxtlino)
        !           142:                return (acc_err(AMINVL_ERR));
        !           143: 
        !           144:        if (Acc_head->linetab[-i] == 0)
        !           145:                return (2);
        !           146: 
        !           147:        return (0);
        !           148: }

unix.superglobalmegacorp.com

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