Annotation of 43BSDReno/contrib/isode-beta/dsap/common/oidseq.c, revision 1.1

1.1     ! root        1: /* oidseq.c - OID Sequence utility routines */
        !             2: 
        !             3: #ifndef lint
        !             4: static char *rcsid = "$Header: /f/osi/dsap/common/RCS/oidseq.c,v 7.1 89/12/19 16:19:27 mrose Exp $";
        !             5: #endif
        !             6: 
        !             7: /*
        !             8:  * $Header: /f/osi/dsap/common/RCS/oidseq.c,v 7.1 89/12/19 16:19:27 mrose Exp $
        !             9:  *
        !            10:  *
        !            11:  * $Log:       oidseq.c,v $
        !            12:  * Revision 7.1  89/12/19  16:19:27  mrose
        !            13:  * sync
        !            14:  * 
        !            15:  * Revision 7.0  89/11/23  21:42:36  mrose
        !            16:  * Release 6.0
        !            17:  * 
        !            18:  */
        !            19: 
        !            20: /*
        !            21:  *                                NOTICE
        !            22:  *
        !            23:  *    Acquisition, use, and distribution of this module and related
        !            24:  *    materials are subject to the restrictions of a license agreement.
        !            25:  *    Consult the Preface in the User's Manual for the full terms of
        !            26:  *    this agreement.
        !            27:  *
        !            28:  */
        !            29: 
        !            30: 
        !            31: /* LINTLIBRARY */
        !            32: 
        !            33: #include "quipu/util.h"
        !            34: #include "quipu/entry.h"
        !            35: 
        !            36: extern int oidformat;
        !            37: 
        !            38: oid_seq_free (ptr)
        !            39: struct oid_seq * ptr;
        !            40: {
        !            41: register struct oid_seq * loop;
        !            42: register struct oid_seq * next;
        !            43: 
        !            44:        for (loop=ptr; loop!=NULLOIDSEQ; loop=next) {
        !            45:                next = loop->oid_next;
        !            46:                oid_free (loop->oid_oid);
        !            47:                free ((char *) loop);
        !            48:        }
        !            49: }
        !            50: 
        !            51: struct oid_seq *oid_seq_merge (a,b)
        !            52: struct oid_seq *a;
        !            53: struct oid_seq *b;
        !            54: {
        !            55: register struct oid_seq  *aptr, *bptr, *result, *trail;
        !            56: 
        !            57:        if ( a == NULLOIDSEQ )
        !            58:                return (b);
        !            59:        if ( b == NULLOIDSEQ )
        !            60:                return (a);
        !            61: 
        !            62:        /* start sequence off, make sure 'a' is the first */
        !            63:        switch (oid_cmp (a->oid_oid,b->oid_oid)) {
        !            64:                case 0: /* equal */
        !            65:                        result = a;
        !            66:                        oid_free (b->oid_oid);
        !            67:                        free ((char *) b);
        !            68:                        aptr = a->oid_next;
        !            69:                        bptr = b->oid_next;
        !            70:                        break;
        !            71:                case -1:
        !            72:                        result = b;
        !            73:                        aptr = a;
        !            74:                        bptr = b->oid_next;
        !            75:                        break;
        !            76:                case 1:
        !            77:                        result = a;
        !            78:                        aptr = a->oid_next;
        !            79:                        bptr = b;
        !            80:                        break;
        !            81:                }
        !            82: 
        !            83:        trail = result;
        !            84:        while (  (aptr != NULLOIDSEQ) && (bptr != NULLOIDSEQ) ) {
        !            85: 
        !            86:           switch (oid_cmp (aptr->oid_oid,bptr->oid_oid)) {
        !            87:                case 0: /* equal */
        !            88:                        trail->oid_next = aptr;
        !            89:                        trail = aptr;
        !            90:                        oid_free (bptr->oid_oid);
        !            91:                        free ((char *) bptr);
        !            92:                        aptr = aptr->oid_next;
        !            93:                        bptr = bptr->oid_next;
        !            94:                        break;
        !            95:                case -1:
        !            96:                        trail->oid_next = bptr;
        !            97:                        trail = bptr;
        !            98:                        bptr = bptr->oid_next;
        !            99:                        break;
        !           100:                case 1:
        !           101:                        trail->oid_next = aptr;
        !           102:                        trail = aptr;
        !           103:                        aptr = aptr->oid_next;
        !           104:                        break;
        !           105:            }
        !           106:        }
        !           107:        if (aptr == NULLOIDSEQ)
        !           108:                trail->oid_next = bptr;
        !           109:        else
        !           110:                trail->oid_next = aptr;
        !           111: 
        !           112:        return (result);
        !           113: }
        !           114: 
        !           115: oid_seq_cmp (a,b)
        !           116: struct oid_seq  *a, *b;
        !           117: {
        !           118:     struct oid_seq     * aa1;
        !           119:     struct oid_seq     * aa2;
        !           120: 
        !           121:     if((a == NULLOIDSEQ) && (b == NULLOIDSEQ))
        !           122:        return(0);
        !           123: 
        !           124:     if(a == NULLOIDSEQ)
        !           125:        return(-1);
        !           126: 
        !           127:     if(b == NULLOIDSEQ)
        !           128:        return(1);
        !           129: 
        !           130:     for(aa1=a; aa1 != NULLOIDSEQ; aa1=aa1->oid_next)
        !           131:     {
        !           132:        for(aa2=b; aa2 != NULLOIDSEQ; aa2=aa2->oid_next)
        !           133:        {
        !           134:            if(oid_cmp(aa1->oid_oid, aa2->oid_oid) == 0)
        !           135:                break;
        !           136:        }
        !           137:        if(aa2 == NULLOIDSEQ)
        !           138:            return(1);
        !           139:     }
        !           140: 
        !           141:     for(aa2=b; aa2 != NULLOIDSEQ; aa2=aa2->oid_next)
        !           142:     {
        !           143:        for(aa1=a; aa1 != NULLOIDSEQ; aa1=aa1->oid_next)
        !           144:        {
        !           145:            if(oid_cmp(aa1->oid_oid, aa2->oid_oid) == 0)
        !           146:                break;
        !           147:        }
        !           148:        if(aa1 == NULLOIDSEQ)
        !           149:            return(-1);
        !           150:     }
        !           151: 
        !           152:     return(0);
        !           153: }
        !           154: 
        !           155: struct oid_seq * oid_seq_cpy (a)
        !           156: struct oid_seq * a;
        !           157: {
        !           158: register struct oid_seq * b;
        !           159: register struct oid_seq * c;
        !           160: register struct oid_seq * d;
        !           161: struct oid_seq * result;
        !           162: 
        !           163:        result = oid_seq_alloc ();
        !           164:        result -> oid_oid = oid_cpy (a->oid_oid);
        !           165:        result -> oid_next = NULLOIDSEQ;
        !           166:        b = result;
        !           167: 
        !           168:        for (c=a->oid_next; c!=NULLOIDSEQ; c=c->oid_next) {
        !           169:                d = oid_seq_alloc ();
        !           170:                d-> oid_oid = oid_cpy (c->oid_oid);
        !           171:                d-> oid_next = NULLOIDSEQ;
        !           172:                b-> oid_next = d;
        !           173:                b = d;
        !           174:        }
        !           175:        return (result);
        !           176: }
        !           177: 
        !           178: oid_seq_print (ps,ptr,format)
        !           179: PS ps;
        !           180: register struct oid_seq * ptr;
        !           181: int format;
        !           182: {
        !           183:        ps_printf (ps,"%s",oid2name (ptr->oid_oid,oidformat));
        !           184:        for ( ptr=ptr->oid_next; ptr!= NULLOIDSEQ; ptr=ptr->oid_next)
        !           185:                if ( format == READOUT )
        !           186:                        ps_printf (ps," AND %s",oid2name (ptr->oid_oid,oidformat));
        !           187:                else
        !           188:                        ps_printf (ps,"$%s",oid2name (ptr->oid_oid,oidformat));
        !           189: }
        !           190: 
        !           191: struct oid_seq * str2oidseq (str)
        !           192: char * str;
        !           193: {
        !           194: register char *ptr;
        !           195: register char *save,val;
        !           196: struct oid_seq * ois = NULLOIDSEQ;
        !           197: struct oid_seq * newois;
        !           198: OID oid;
        !           199: char * SkipSpace();
        !           200: 
        !           201:        while ( (ptr = index (str,'$')) != 0) {
        !           202:                save = ptr++;
        !           203:                save--;
        !           204:                if (! isspace (*save))
        !           205:                        save++;
        !           206:                val = *save;
        !           207:                *save = 0;
        !           208:                newois = oid_seq_alloc();
        !           209:                if ((oid = name2oid (SkipSpace(str))) == NULLOID) {
        !           210:                        parse_error ("invaild name in sequence %s",str);
        !           211:                        oid_seq_free (ois);
        !           212:                        free ((char *) newois);
        !           213:                        return (NULLOIDSEQ);
        !           214:                }
        !           215:                newois->oid_oid = oid_cpy(oid);
        !           216:                newois->oid_next = ois;
        !           217:                ois = newois;
        !           218:                *save = val;
        !           219:                str = ptr;
        !           220:        }
        !           221: 
        !           222:        newois = oid_seq_alloc();
        !           223:        if ((oid = name2oid (SkipSpace(str))) == NULLOID) {
        !           224:                parse_error ("invaild name in sequence %s",str);
        !           225:                oid_seq_free (ois);
        !           226:                free ((char *) newois);
        !           227:                return (NULLOIDSEQ);
        !           228:        }
        !           229:        newois->oid_oid = oid_cpy(oid);
        !           230:        newois->oid_next = ois;
        !           231:        ois = newois;
        !           232: 
        !           233:        return (ois);
        !           234: }

unix.superglobalmegacorp.com

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