Annotation of 43BSDReno/contrib/isode-beta/psap/prim2oid.c, revision 1.1

1.1     ! root        1: /* prim2oid.c - presentation element to object identifier */
        !             2: 
        !             3: #ifndef        lint
        !             4: static char *rcsid = "$Header: /f/osi/psap/RCS/prim2oid.c,v 7.1 90/05/22 20:30:03 mrose Exp $";
        !             5: #endif
        !             6: 
        !             7: /* 
        !             8:  * $Header: /f/osi/psap/RCS/prim2oid.c,v 7.1 90/05/22 20:30:03 mrose Exp $
        !             9:  *
        !            10:  *
        !            11:  * $Log:       prim2oid.c,v $
        !            12:  * Revision 7.1  90/05/22  20:30:03  mrose
        !            13:  * bug-fix
        !            14:  * 
        !            15:  * Revision 7.0  89/11/23  22:13:12  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 <stdio.h>
        !            34: #include "psap.h"
        !            35: 
        !            36: /*  */
        !            37: 
        !            38: OID    prim2oid (pe)
        !            39: register PE    pe;
        !            40: {
        !            41:     register unsigned int i,
        !            42:                         *ip;
        !            43:     register PElementData dp,
        !            44:                          ep;
        !            45:     static OIDentifier oid;
        !            46:     register OID       o = &oid;
        !            47: 
        !            48:     if (pe -> pe_form != PE_FORM_PRIM
        !            49:            || (dp = pe -> pe_prim) == NULLPED
        !            50:            || pe -> pe_len == 0)
        !            51:        return pe_seterr (pe, PE_ERR_PRIM, NULLOID);
        !            52:     ep = dp + pe -> pe_len;
        !            53: 
        !            54:     if (o -> oid_elements)
        !            55:        free ((char *) o -> oid_elements);
        !            56: 
        !            57:     for (i = 1; dp < ep; i++) {        /* another whacko OSI encoding... */
        !            58:        if (*dp == 0x80)
        !            59:            return pe_seterr (pe, PE_ERR_OID, NULLOID);
        !            60: 
        !            61:        while (*dp++ & 0x80)
        !            62:            if (dp > ep)
        !            63:                return pe_seterr (pe, PE_ERR_OID, NULLOID);
        !            64:     }
        !            65: 
        !            66:     if ((ip = (unsigned int *) malloc ((i + 1) * sizeof *ip)) == NULL)
        !            67:        return pe_seterr (pe, PE_ERR_NMEM, NULLOID);
        !            68:     o -> oid_elements = ip, o -> oid_nelem = i;
        !            69:     
        !            70:     for (dp = pe -> pe_prim; dp < ep; ) {
        !            71:        i = 0;
        !            72:        do {
        !            73:            i <<= 7; 
        !            74:            i |= *dp & 0x7f;
        !            75:        } while (*dp++ & 0x80);
        !            76: 
        !            77:        if (ip != o -> oid_elements)
        !            78:            *ip++ = i;
        !            79:        else
        !            80:            if (i < 40)
        !            81:                *ip++ = 0, *ip++ = i;
        !            82:            else
        !            83:                if (i < 80)
        !            84:                    *ip++ = 1, *ip++ = i - 40;
        !            85:                else
        !            86:                    *ip++ = 2, *ip++ = i - 80;
        !            87:     }
        !            88: 
        !            89:     return o;
        !            90: }

unix.superglobalmegacorp.com

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