Annotation of 43BSDReno/contrib/isode-beta/acsap/isoentity.c, revision 1.1.1.1

1.1       root        1: /* isoentity.c - application entity titles -- sequential lookup utilities  */
                      2: 
                      3: #ifndef        lint
                      4: static char *rcsid = "$Header: /f/osi/acsap/RCS/isoentity.c,v 7.0 89/11/23 21:22:13 mrose Rel $";
                      5: #endif
                      6: 
                      7: /* 
                      8:  * $Header: /f/osi/acsap/RCS/isoentity.c,v 7.0 89/11/23 21:22:13 mrose Rel $
                      9:  *
                     10:  *
                     11:  * $Log:       isoentity.c,v $
                     12:  * Revision 7.0  89/11/23  21:22:13  mrose
                     13:  * Release 6.0
                     14:  * 
                     15:  */
                     16: 
                     17: /*
                     18:  *                               NOTICE
                     19:  *
                     20:  *    Acquisition, use, and distribution of this module and related
                     21:  *    materials are subject to the restrictions of a license agreement.
                     22:  *    Consult the Preface in the User's Manual for the full terms of
                     23:  *    this agreement.
                     24:  *
                     25:  */
                     26: 
                     27: 
                     28: /* LINTLIBRARY */
                     29: 
                     30: #include <ctype.h>
                     31: #include <stdio.h>
                     32: #include "psap.h"
                     33: #include "isoaddrs.h"
                     34: #include "tailor.h"
                     35: 
                     36: /*    DATA */
                     37: 
                     38: static char *isoentities = "isoentities";
                     39: 
                     40: static FILE *servf = NULL;
                     41: static int   stayopen = 0;
                     42: 
                     43: static int   mask;
                     44: static int   vecp;
                     45: static char  buffer[BUFSIZ + 1];
                     46: static char *vec[NVEC + NSLACK + 1];
                     47: 
                     48: static struct isoentity ies;
                     49: 
                     50: /*  */
                     51: 
                     52: int    setisoentity (f)
                     53: int    f;
                     54: {
                     55:     if (servf == NULL)
                     56:        servf = fopen (isodefile (isoentities, 0), "r");
                     57:     else
                     58:        rewind (servf);
                     59:     stayopen |= f;
                     60: 
                     61:     return (servf != NULL);
                     62: }
                     63: 
                     64: 
                     65: int    endisoentity () {
                     66:     if (servf && !stayopen) {
                     67:        (void) fclose (servf);
                     68:        servf = NULL;
                     69:     }
                     70: 
                     71:     return 1;
                     72: }
                     73: 
                     74: /*  */
                     75: 
                     76: struct isoentity   *getisoentity () {
                     77:     static char  descriptor[BUFSIZ];
                     78: 
                     79:     if (servf == NULL
                     80:            && (servf = fopen (isodefile (isoentities, 0), "r")) == NULL)
                     81:        return NULL;
                     82: 
                     83:     while (_startisoentity (descriptor) == OK)
                     84:        if (_stopisoentity (descriptor, (struct isoentity *) NULL) == OK)
                     85:            return (&ies);
                     86: 
                     87:     return NULL;
                     88: }
                     89: 
                     90: /*  */
                     91: 
                     92: int    _startisoentity (descriptor)
                     93: char   *descriptor;
                     94: {
                     95:     register char  *cp,
                     96:                   *dp;
                     97:     char   *ep;
                     98:     register struct isoentity  *ie = &ies;
                     99: 
                    100:     bzero ((char *) ie, sizeof *ie);
                    101: 
                    102:     ep = (dp = buffer) + sizeof buffer;
                    103:     while (fgets (dp, ep - dp, servf) != NULL) {
                    104:        if (*buffer == '#')
                    105:            continue;
                    106:        if (cp = index (buffer, '\n')) {
                    107:            *cp-- = NULL;
                    108:            if (*cp == '\\') {
                    109:                if ((dp = cp) + 1 >= ep)
                    110:                    dp = buffer;
                    111:                continue;
                    112:            }
                    113:        }
                    114: 
                    115:        switch (vecp = str2vecX (buffer, vec, 5 + 1, &mask, NULL)) {
                    116:            case 3:                     /* no address */
                    117:            case 4:                     /* new-style */
                    118:                break;
                    119: 
                    120:            default:
                    121:                continue;
                    122:        }
                    123: 
                    124:        (void) sprintf (descriptor, "%s-%s", vec[0], vec[1]);
                    125: 
                    126:        return OK;
                    127:     }
                    128: 
                    129:     return DONE;
                    130: }
                    131: 
                    132: /*  */
                    133: 
                    134: int    _stopisoentity (descriptor, iep)
                    135: char   *descriptor;
                    136: struct isoentity *iep;
                    137: {
                    138:     register int    i;
                    139:     register struct isoentity  *ie = &ies;
                    140:     OID                oid = &ie -> ie_identifier;
                    141:     struct PSAPaddr *pa = &ie -> ie_addr;
                    142:     struct PSAPaddr *pz;
                    143:     static unsigned int elements[NELEM + 1];
                    144: 
                    145:     if (strcmp (vec[2], "NULL") == 0)
                    146:        elements[i = 0] = 0;
                    147:     else
                    148:        if ((i = str2elem (vec[2], elements)) <= 1)
                    149:            return NOTOK;
                    150:     oid -> oid_elements = elements;
                    151:     oid -> oid_nelem = i;
                    152:     ie -> ie_descriptor = descriptor;
                    153: 
                    154:     switch (vecp) {
                    155:        case 3:         /* no address */
                    156:            break;
                    157: 
                    158:        case 4:         /* new-style */
                    159:            if (pz = str2paddr (vec[3]))
                    160:                *pa = *pz;              /* struct copy */
                    161:            break;
                    162:     }
                    163: 
                    164:     if (iep)
                    165:        *iep = *ie;     /* struct copy */
                    166: 
                    167:     return OK;
                    168: }
                    169: 
                    170: /*  */
                    171: 
                    172: _printent (ie)
                    173: register struct isoentity  *ie;
                    174: {
                    175:     LLOG (addr_log, LLOG_DEBUG,
                    176:          ("Entity:  %s (%s)", ie -> ie_descriptor,
                    177:           oid2ode (&ie -> ie_identifier)));
                    178: 
                    179:     (void) ll_printf (addr_log, "Address: %s\n",
                    180:                      paddr2str (&ie -> ie_addr, NULLNA));
                    181: 
                    182:     (void) ll_printf (addr_log, "///////\n");
                    183: 
                    184:     (void) ll_sync (addr_log);
                    185: }

unix.superglobalmegacorp.com

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