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

1.1     ! root        1: /* ode2oid.c - object descriptor to object identifier */
        !             2: 
        !             3: #ifndef        lint
        !             4: static char *rcsid = "$Header: /f/osi/psap/RCS/ode2oid.c,v 7.2 90/07/09 14:43:45 mrose Exp $";
        !             5: #endif
        !             6: 
        !             7: /* 
        !             8:  * $Header: /f/osi/psap/RCS/ode2oid.c,v 7.2 90/07/09 14:43:45 mrose Exp $
        !             9:  *
        !            10:  *
        !            11:  * $Log:       ode2oid.c,v $
        !            12:  * Revision 7.2  90/07/09  14:43:45  mrose
        !            13:  * sync
        !            14:  * 
        !            15:  * Revision 1.1.1.2  90/06/07  08:03:26  isode
        !            16:  * ISODE 6.1 beta
        !            17:  * 
        !            18:  * Revision 7.0  89/11/23  22:12:48  mrose
        !            19:  * Release 6.0
        !            20:  * 
        !            21:  */
        !            22: 
        !            23: /*
        !            24:  *                               NOTICE
        !            25:  *
        !            26:  *    Acquisition, use, and distribution of this module and related
        !            27:  *    materials are subject to the restrictions of a license agreement.
        !            28:  *    Consult the Preface in the User's Manual for the full terms of
        !            29:  *    this agreement.
        !            30:  *
        !            31:  */
        !            32: 
        !            33: 
        !            34: /* LINTLIBRARY */
        !            35: 
        !            36: #include <stdio.h>
        !            37: #include "psap.h"
        !            38: #include "ppkt.h"
        !            39: 
        !            40: /* work around define collisions */
        !            41: #undef missingP
        !            42: #undef pylose
        !            43: #include "rtpkt.h"
        !            44: 
        !            45: /* work around type clashes */
        !            46: #undef missingP
        !            47: #undef pylose
        !            48: #undef toomuchP
        !            49: #define ACSE
        !            50: #define assocblk assocblkxxx
        !            51: #define newacblk newacblkxxx
        !            52: #define findacblk findacblkxxx
        !            53: #include "acpkt.h"
        !            54: 
        !            55: /*  */
        !            56: #define ODECACHESIZE 10
        !            57: static struct la_cache {
        !            58:        char    *descriptor;    
        !            59:        int     ref;
        !            60:        OID     oid;
        !            61: } Cache[ODECACHESIZE];
        !            62: 
        !            63: static void preloadcache (str)
        !            64: char   *str;
        !            65: {
        !            66:     struct la_cache *cp = &Cache[0];
        !            67:     register struct isobject *io;
        !            68: 
        !            69:     (void) setisobject (0);
        !            70:     while (io = getisobject ()) {
        !            71:        if (strcmp (str, io -> io_descriptor) == 0 ||
        !            72:            strcmp (DFLT_ASN, io -> io_descriptor) == 0 ||
        !            73:            strcmp (AC_ASN, io -> io_descriptor) == 0 ||
        !            74:            strcmp (BER, io -> io_descriptor) == 0 ||
        !            75:            strcmp (RT_ASN, io -> io_descriptor) == 0) {
        !            76:            if ((cp -> oid = oid_cpy (&io -> io_identity)) == NULLOID ||
        !            77:                (cp -> descriptor = malloc ((unsigned) (strlen (io -> io_descriptor) + 1)))
        !            78:                == NULLCP) {
        !            79:                if (cp -> oid) {
        !            80:                    oid_free (cp -> oid);
        !            81:                    cp -> oid = NULLOID;
        !            82:                }
        !            83:            }
        !            84:            else {
        !            85:                (void) strcpy (cp -> descriptor, io -> io_descriptor);
        !            86:                cp -> ref = 1;
        !            87:                cp ++;
        !            88:            }
        !            89:        }
        !            90:     }
        !            91:     (void) endisobject ();
        !            92: }
        !            93: 
        !            94: OID    ode2oid (descriptor)
        !            95: char   *descriptor;
        !            96: {
        !            97:     register struct isobject *io;
        !            98:     int i, least;
        !            99:     struct la_cache *cp, *cpn;
        !           100:     static char firsttime = 0;
        !           101: 
        !           102:     if (firsttime == 0) {
        !           103:        preloadcache (descriptor);
        !           104:        firsttime = 1;
        !           105:     }
        !           106: 
        !           107:     least = Cache[0].ref;
        !           108:     for (cpn = cp = &Cache[0], i = 0; i < ODECACHESIZE; i++, cp++) {
        !           109:        if (cp -> ref < least) {
        !           110:            least = cp -> ref;
        !           111:            cpn = cp;
        !           112:        }
        !           113:        if (cp -> ref <= 0)
        !           114:                continue;
        !           115:        if (strcmp (descriptor, cp -> descriptor) == 0) {
        !           116:            cp -> ref ++;
        !           117:            return cp -> oid;
        !           118:        }
        !           119:     }
        !           120: 
        !           121:     if ((io = getisobjectbyname (descriptor)) == NULL)
        !           122:        return NULLOID;
        !           123: 
        !           124:     if (cpn -> oid)
        !           125:            oid_free (cpn -> oid);
        !           126:     if (cpn -> descriptor)
        !           127:            free (cpn -> descriptor);
        !           128: 
        !           129:     cpn -> ref = 1;
        !           130:     if ((cpn -> oid = oid_cpy (&io -> io_identity)) == NULLOID ||
        !           131:        (cpn -> descriptor = malloc ((unsigned) (strlen (descriptor) + 1))) == NULLCP) {
        !           132:        if (cpn -> oid) {
        !           133:            oid_free (cpn -> oid);
        !           134:            cpn -> oid = NULLOID;
        !           135:        }
        !           136:         cpn -> ref = 0;
        !           137:     }
        !           138:     else
        !           139:        (void) strcpy (cpn -> descriptor, descriptor);
        !           140: 
        !           141:     return (&io -> io_identity);
        !           142: }

unix.superglobalmegacorp.com

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