Annotation of researchv9/jerq/sgs/compress/mid.c, revision 1.1

1.1     ! root        1: /*
        !             2: *     static char ID_mid[] = "@(#) mid.c: 1.3 6/29/82";
        !             3: */
        !             4: 
        !             5: #include <stdio.h>
        !             6: #include "sdp.h"
        !             7: #include "sdp1.h"
        !             8: #include <signal.h>
        !             9: #include "syms.h"
        !            10: #include "tagitem.h"
        !            11: 
        !            12: 
        !            13: /*     before starting pass 2 of utility, a table for index of
        !            14:        tag must be built.  The tagitem and storage area for tags 
        !            15:        saved in pass 1 are freed
        !            16:  */
        !            17: 
        !            18: #define YES    1
        !            19: #define NO     0
        !            20: struct table{
        !            21:        long    oldlcn;
        !            22:        long    newlcn;
        !            23:        long    real_loc;
        !            24: } *tbl_head;
        !            25: 
        !            26: 
        !            27: extern long    szecnt;
        !            28: extern  char   *malloc();
        !            29: extern long    tag_sum;
        !            30: extern int     vflag;
        !            31: extern char      tagname[];
        !            32: extern int      framsz;
        !            33: extern int        framect;
        !            34: 
        !            35: extern struct SPACE    *TAGSPACE;
        !            36: extern struct ENVIRON  *ENV;
        !            37: extern struct SPACE    *SYMSPACE;
        !            38: 
        !            39: 
        !            40: build()
        !            41: {
        !            42: 
        !            43: 
        !            44:        extern ITEMID           ti_head;
        !            45: 
        !            46:        TAGITEM *tag_ptr, *tag_ptr2;
        !            47:        ITEMID  tagid;
        !            48:        struct table    *tbl_ptr;
        !            49: 
        !            50:        long            i;
        !            51:        char           *p;
        !            52: 
        !            53: 
        !            54:        if (symfini()!=YES)
        !            55:                {
        !            56:                fprintf(stderr,"could not close SDP\n");
        !            57:                return (NO);
        !            58:                }
        !            59:        if (sdp_disconnect(TAGSPACE) == SDPERROR)       
        !            60:                {
        !            61:                fprintf(stderr,"Failed to close SDP for tag");
        !            62:                return(NO);
        !            63:                }
        !            64:        if (sdp_vacate(ENV) == SDPERROR)
        !            65:                {
        !            66:                return (NO);
        !            67:                }
        !            68:        tbl_head = (struct table *) calloc((unsigned)tag_sum, sizeof(struct table));
        !            69:        if ( tbl_head == NULL ) {
        !            70:                fprintf(stderr,"No space for table\n");
        !            71:            return(NO);
        !            72:            }
        !            73:        tbl_ptr = tbl_head;
        !            74: 
        !            75:        tagid = ti_head;
        !            76: /*
        !            77:        printf("framect=%d framsz=%d tagsum=%ld tab=%d\n",framect,framsz,
        !            78:        tag_sum,sizeof(struct table));
        !            79: */
        !            80:        framect=((long) framect * framsz -  tag_sum * sizeof(struct table)) / framsz;
        !            81: 
        !            82:        if (framect < 2)
        !            83:                {
        !            84:                fprintf(stderr,"nospace for secondary house\n");
        !            85:                return (NO);
        !            86:                }
        !            87:        ENV = sdp_house(framect,framsz,NULL);
        !            88:        if (ENV == NULL)
        !            89:                {
        !            90:                fprintf(stderr,"secondary house failed\n");
        !            91:                return (NO);
        !            92:                }
        !            93:        if ((int)(TAGSPACE=sdp_connect(tagname,ENV,NULL,RNLY)) == SDPERROR)
        !            94:                {
        !            95:                fprintf(stderr,"Failed to reinitialized SDP symbol space\n");
        !            96:                return (NO);
        !            97:                }
        !            98:        tag_ptr = (TAGITEM *) sdp_use(TAGSPACE,tagid,RNLY);
        !            99: 
        !           100:        /*
        !           101:         * build table
        !           102:         */
        !           103: 
        !           104:        for ( i=0L; i < tag_sum; i++) {
        !           105:                tbl_ptr->oldlcn = tag_ptr->oldloc;
        !           106:                tbl_ptr->newlcn = tag_ptr->newloc;
        !           107:                if ( tag_ptr->p_realtag == 0L)
        !           108:                        tbl_ptr->real_loc = tbl_ptr->newlcn;
        !           109:                else {
        !           110:                        tag_ptr2 = (TAGITEM *)sdp_use(TAGSPACE,tag_ptr->p_realtag,RNLY);
        !           111:                        tbl_ptr->real_loc = tag_ptr2->newloc;
        !           112:                        sdp_unuse(TAGSPACE,tag_ptr->p_realtag,RNLY);
        !           113:                        }
        !           114: 
        !           115:                ++tbl_ptr;
        !           116:                sdp_unuse(TAGSPACE,tagid,RNLY);
        !           117:                tagid = tag_ptr->next_ti;
        !           118:                if ( (i+1) < tag_sum )
        !           119:                        tag_ptr = (TAGITEM *) sdp_use(TAGSPACE,tagid,RNLY);
        !           120:        }
        !           121: 
        !           122:        return( YES );
        !           123: }

unix.superglobalmegacorp.com

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