Annotation of 43BSD/ingres/source/support/indconv.q, revision 1.1

1.1     ! root        1: # include      <sccs.h>
        !             2: 
        !             3: SCCSID(@(#)indconv.q   8.1     12/31/84)
        !             4: 
        !             5: 
        !             6: # define       MAXNAME         12
        !             7: # define       M_HEAP          5
        !             8: # define       M_ISAM          11
        !             9: # define       M_HASH          21
        !            10: 
        !            11: ##     char            *Usercode;
        !            12:        struct
        !            13:        {
        !            14:                char    relname[MAXNAME + 1], indname[MAXNAME + 1], relsp[10];
        !            15:                char    domname[7][MAXNAME + 1], modseq[7];
        !            16:        }       Indinfo[100];
        !            17: 
        !            18: struct relspec
        !            19: {
        !            20:        char    specnum, *specname;
        !            21: };
        !            22: 
        !            23: struct relspec relspecs[]
        !            24: {
        !            25:        M_ISAM,         "isam",
        !            26:        M_HASH,         "hash",
        !            27:        -M_ISAM,        "cisam",
        !            28:        -M_HASH,        "chash",
        !            29:        M_HEAP,         "heap",
        !            30:        -M_HEAP,        "cheap",
        !            31:        0
        !            32: };
        !            33: 
        !            34: main(argc, argv)
        !            35: int    argc;
        !            36: char   *argv[];
        !            37: {
        !            38:        char    *kp;
        !            39: ##     char    aname[20];
        !            40: ##     char    keystring[100];
        !            41: ##     char    pname[20], iname[20];
        !            42: ##     char    *db;
        !            43: ##     int     cnt, i, j, rspec, aid, akey;
        !            44: 
        !            45:        if (argc != 2)
        !            46:                syserr(0, "wrong number of parameters");
        !            47:        db = argv[1];
        !            48:        if (initucode(db, 0, 0, 0, 0))
        !            49:                syserr(0, "cannot access %s data base", db);
        !            50: ##     ingres db "-nheap"
        !            51:        cnt = 0;
        !            52: ##     range of r is relation
        !            53: ##     retrieve (iname = r.relid, rspec = r.relspec)
        !            54: ##             where r.relindxd < 0 and r.relindxd != -2 and r.relowner = Usercode
        !            55: ##     {
        !            56:                smove(iname, Indinfo[cnt].indname);
        !            57:                for (i = 0; relspecs[i].specnum != 0; i++)
        !            58:                {
        !            59:                        if (rspec == relspecs[i].specnum)
        !            60:                        {
        !            61:                                smove(relspecs[i].specname, Indinfo[cnt].relsp);
        !            62:                                break;
        !            63:                        }
        !            64:                }
        !            65:                for (i = 0; i < 7; i++)
        !            66:                        Indinfo[cnt].modseq[i] = -1;
        !            67:                if (++cnt >= 100)
        !            68:                {
        !            69:                        printf("There are more indices than I can convert\n");
        !            70:                        printf("\tso run me again to finish the rest\n");
        !            71:                        break;
        !            72:                }
        !            73: ##     }
        !            74: ##     range of x is indexes
        !            75: ##     retrieve (pname = x.irelidp, iname = x.irelidi)
        !            76: ##             where x.iownerp = Usercode
        !            77: ##     {
        !            78:                for (i = 0; i < cnt; i++)
        !            79:                {
        !            80:                        if (sequal(iname, Indinfo[i].indname))
        !            81:                        {
        !            82:                                smove(pname, Indinfo[i].relname);
        !            83:                                break;
        !            84:                        }
        !            85:                }
        !            86: ##     }
        !            87: ##     range of a is attribute
        !            88: ##     retrieve (iname = a.attrelid, aname = a.attname, aid = a.attid,
        !            89: ##                     akey = a.attxtra)
        !            90: ##             where a.attowner = Usercode
        !            91: ##     {
        !            92:                for (i = 0; i < cnt; i++)
        !            93:                {
        !            94:                        if (sequal(iname, Indinfo[i].indname))
        !            95:                        {
        !            96:                                if (akey > 0)
        !            97:                                        Indinfo[i].modseq[akey - 1] = aid - 1;
        !            98:                                smove(aname, Indinfo[i].domname[aid - 1]);
        !            99:                                break;
        !           100:                        }
        !           101:                }
        !           102: ##     }
        !           103: 
        !           104:        for (i = 0; i < cnt; i++)
        !           105:        {
        !           106:                smove(Indinfo[i].indname, iname);
        !           107: ##             destroy iname
        !           108:        }
        !           109:        for (i = 0; i < cnt; i++)
        !           110:        {
        !           111:                kp = &keystring[0];
        !           112:                for (j = 0; j < 7; j++)
        !           113:                {
        !           114:                        if (sequal("tidp", Indinfo[i].domname[j]))
        !           115:                                break;
        !           116:                        if (j > 0)
        !           117:                                xmove(", ", &kp);
        !           118:                        xmove(Indinfo[i].domname[j], &kp);
        !           119:                }
        !           120:                smove(Indinfo[i].relname, pname);
        !           121:                smove(Indinfo[i].indname, iname);
        !           122: ##             index on pname is iname (keystring)
        !           123:        }
        !           124:        for (i = 0; i < cnt; i++)
        !           125:        {
        !           126:                kp = &keystring[0];
        !           127:                for (j = 0; j < 7 && Indinfo[i].modseq[j] != -1; j++)
        !           128:                {
        !           129:                        if (j > 0)
        !           130:                                xmove(", ", &kp);
        !           131:                        xmove(Indinfo[i].domname[Indinfo[i].modseq[j]], &kp);
        !           132:                }
        !           133:                smove(Indinfo[i].indname, iname);
        !           134:                smove(Indinfo[i].relsp, pname);
        !           135:                if (j == 0)
        !           136:                {
        !           137: ##                     modify iname to pname
        !           138:                        printf("write to Bob Epstein for a free INGRES T-shirt\n");
        !           139:                }
        !           140:                else
        !           141:                {
        !           142: ##                     modify iname to pname on keystring
        !           143:                }
        !           144:                printf("index %s converted.\n", iname);
        !           145:        }
        !           146:        printf("done\n");
        !           147: }
        !           148: 
        !           149: sequal(ax, bx)
        !           150: char   *ax, *bx;
        !           151: {
        !           152:        register char   *a, *b;
        !           153: 
        !           154:        a = --ax;
        !           155:        b = --bx;
        !           156:        while (*++a == *++b)
        !           157:                if (*a == 0)
        !           158:                        return (1);
        !           159:        if (*a == 0)
        !           160:        {
        !           161:                while (*b == ' ')
        !           162:                        b++;
        !           163:                if (*b)
        !           164:                        return (0);
        !           165:                return (1);
        !           166:        }
        !           167:        if (*b == 0)
        !           168:        {
        !           169:                while (*a == ' ')
        !           170:                        a++;
        !           171:                if (*a)
        !           172:                        return (0);
        !           173:                return (1);
        !           174:        }
        !           175:        return (0);
        !           176: }
        !           177: 
        !           178: smove(ax, bx)
        !           179: char   *ax, *bx;
        !           180: {
        !           181:        register char   *a, *b;
        !           182: 
        !           183:        a = ax;
        !           184:        b = bx;
        !           185:        while (*b++ = *a++);
        !           186:        return (0);
        !           187: }
        !           188: 
        !           189: xmove(ax, bx)
        !           190: char   *ax, **bx;
        !           191: {
        !           192:        register char   *a, *b;
        !           193: 
        !           194:        a = ax;
        !           195:        b = *bx;
        !           196:        while (*b++ = *a++);
        !           197:        *bx = --b;
        !           198:        return (0);
        !           199: }

unix.superglobalmegacorp.com

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