Annotation of 42BSD/ingres/source/iutil/put_tuple.c, revision 1.1.1.1

1.1       root        1: # include      <ingres.h>
                      2: # include      <symbol.h>
                      3: # include      <access.h>
                      4: # include      <sccs.h>
                      5: 
                      6: SCCSID(@(#)put_tuple.c 7.1     2/5/81)
                      7: 
                      8: 
                      9: 
                     10: char   *Acctuple;
                     11: char   Accanon[MAXTUP];
                     12: 
                     13: 
                     14: /*
                     15: **  PUT_TUPLE
                     16: **
                     17: **     Put the canonical tuple in the position
                     18: **     on the current page specified by tid
                     19: **
                     20: **     Trace Flags:
                     21: **             27.3-5
                     22: */
                     23: 
                     24: put_tuple(tid, tuple, length)
                     25: TID    *tid;
                     26: char   *tuple;
                     27: int    length;
                     28: {
                     29:        register char   *tp;
                     30:        char            *get_addr();
                     31: 
                     32: #      ifdef xATR2
                     33:        if (tTf(27, 3))
                     34:        {
                     35:                printf("put_tuple:len=%d,", length);
                     36:                dumptid(tid);
                     37:        }
                     38: #      endif
                     39: 
                     40:        /* get address in buffer */
                     41:        tp = get_addr(tid);
                     42: 
                     43:        /* move the tuple */
                     44:        bmove(tuple, tp, length);
                     45: 
                     46:        /* mark page as dirty */
                     47:        Acc_head->bufstatus |= BUF_DIRTY;
                     48: }
                     49: /*
                     50: **  CANONICAL
                     51: **
                     52: **     Make the tuple canonical and return the length
                     53: **     of the tuple.
                     54: **
                     55: **     If the relation is compressed then the tuple in
                     56: **     compressed into the global area Accanon.
                     57: **
                     58: **     As a side effect, the address of the tuple to be
                     59: **     inserted is placed in Acctuple.
                     60: **
                     61: **     returns: length of canonical tuple
                     62: **
                     63: **     Trace Flags:
                     64: **             27.6, 7
                     65: */
                     66: 
                     67: canonical(d, tuple)
                     68: register DESC  *d;
                     69: register char  *tuple;
                     70: {
                     71:        register int    i;
                     72: 
                     73:        if (d->reldum.relspec < 0)
                     74:        {
                     75:                /* compress tuple */
                     76:                i = comp_tup(d, tuple);
                     77:                Acctuple = Accanon;
                     78:        }
                     79:        else
                     80:        {
                     81:                Acctuple = tuple;
                     82:                i = d->reldum.relwid;
                     83:        }
                     84: #      ifdef xATR3
                     85:        if (tTf(27, 6))
                     86:                printf("canonical: %d\n", i);
                     87: #      endif
                     88:        return (i);
                     89: }
                     90: /*
                     91: **  COMP_TUP
                     92: **
                     93: **     Compress the tuple into Accanon. Compression is
                     94: **     done by copying INT and FLOAT as is.
                     95: **     For CHAR fields, the tuple is copied until a null
                     96: **     byte or until the end of the field. Then trailing
                     97: **     blanks are removed and a null byte is inserted at
                     98: **     the end if any trailing blanks were present.
                     99: */
                    100: 
                    101: comp_tup(d, src)
                    102: register DESC  *d;
                    103: register char  *src;
                    104: {
                    105:        register char   *dst;
                    106:        char            *save;
                    107:        char            *domlen, *domtype;
                    108:        int             i, j, len;
                    109: 
                    110:        dst = Accanon;
                    111: 
                    112:        domlen = &d->relfrml[1];
                    113:        domtype = &d->relfrmt[1];
                    114: 
                    115:        for (i = 1; i <= d->reldum.relatts; i++)
                    116:        {
                    117:                len = *domlen++ & I1MASK;
                    118:                if (*domtype++ == CHAR)
                    119:                {
                    120:                        save = src;
                    121:                        for (j = 1; j <= len; j++)
                    122:                        {
                    123:                                if ((*dst++ = *src++) == NULL)
                    124:                                {
                    125:                                        dst--;
                    126:                                        break;
                    127:                                }
                    128:                        }
                    129: 
                    130:                        while (j--)
                    131:                                if (*--dst != ' ')
                    132:                                        break;
                    133: 
                    134:                        if (j != len)
                    135:                                *++dst = NULL;
                    136: 
                    137:                        dst++;
                    138:                        src = save + len;
                    139:                }
                    140:                else
                    141:                {
                    142:                        while (len--)
                    143:                                *dst++ = *src++;
                    144: 
                    145:                }
                    146:        }
                    147:        return (dst - Accanon);
                    148: }
                    149: /*
                    150: **  SPACE_LEFT
                    151: **
                    152: **     Determine how much space remains on the page in
                    153: **     the current buffer. Included in computation
                    154: **     is the room for an additional line number
                    155: */
                    156: 
                    157: space_left(bp)
                    158: register struct accbuf *bp;
                    159: {
                    160:        register int    nextoff;
                    161:        register int    i;
                    162:        register short  *pp;
                    163: 
                    164:        nextoff = bp->nxtlino;
                    165: #      ifdef xATR3
                    166:        if (nextoff < 0 || nextoff > PGSIZE)
                    167:                syserr("space_left: nextoff=%d", nextoff);
                    168: #      endif
                    169: 
                    170:        /* compute space left on page */
                    171:        pp = &bp->linetab[-nextoff];
                    172:        i = PGSIZE - *pp - (nextoff + 2) * 2;
                    173: 
                    174:        /* see if there is also a free line number */
                    175:        if (nextoff < MAXLINENO)
                    176:                return (i);
                    177:        while (++pp <= &bp->linetab[0])
                    178:                if (*pp == 0)
                    179:                        return (i);
                    180:        return (0);
                    181: }

unix.superglobalmegacorp.com

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