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

1.1     ! root        1: /* oc.c - Object Class routines */
        !             2: 
        !             3: #ifndef lint
        !             4: static char *rcsid = "$Header: /f/osi/dsap/common/RCS/oc.c,v 7.3 90/07/09 14:34:47 mrose Exp $";
        !             5: #endif
        !             6: 
        !             7: /*
        !             8:  * $Header: /f/osi/dsap/common/RCS/oc.c,v 7.3 90/07/09 14:34:47 mrose Exp $
        !             9:  *
        !            10:  *
        !            11:  * $Log:       oc.c,v $
        !            12:  * Revision 7.3  90/07/09  14:34:47  mrose
        !            13:  * sync
        !            14:  * 
        !            15:  * Revision 7.2  90/03/15  11:17:41  mrose
        !            16:  * quipu-sync
        !            17:  * 
        !            18:  * Revision 7.1  90/01/11  23:49:43  mrose
        !            19:  * lint
        !            20:  * 
        !            21:  * Revision 7.0  89/11/23  21:42:31  mrose
        !            22:  * Release 6.0
        !            23:  * 
        !            24:  */
        !            25: 
        !            26: /*
        !            27:  *                                NOTICE
        !            28:  *
        !            29:  *    Acquisition, use, and distribution of this module and related
        !            30:  *    materials are subject to the restrictions of a license agreement.
        !            31:  *    Consult the Preface in the User's Manual for the full terms of
        !            32:  *    this agreement.
        !            33:  *
        !            34:  */
        !            35: 
        !            36: 
        !            37: /* LINTLIBRARY */
        !            38: 
        !            39: #include "quipu/util.h"
        !            40: #include "quipu/entry.h"
        !            41: #include "tailor.h"
        !            42: 
        !            43: extern LLog * log_dsap;
        !            44: extern short oc_sntx; 
        !            45: extern IFP oc_hier;
        !            46: 
        !            47: objectclass * oc_add (oid)
        !            48: OID oid;
        !            49: {
        !            50: oid_table * Current;
        !            51: extern objectclass ocOIDTable[];
        !            52: extern int ocNumEntries;
        !            53: 
        !            54:        Current = &ocOIDTable[ocNumEntries].oc_ot;
        !            55:        if (oid == NULLOID)
        !            56:                Current->ot_oid = NULLOID;
        !            57:        else
        !            58:                Current->ot_oid = oid_cpy (oid);
        !            59:        (void) strcpy (Current->ot_name, oid2ode_aux(oid,0));
        !            60:        (void) strcpy (Current->ot_stroid, sprintoid(oid));
        !            61:        add_entry_aux (Current->ot_name,(caddr_t)&ocOIDTable[ocNumEntries],3,NULLCP);
        !            62:        ocOIDTable[ocNumEntries].oc_hierachy = NULLOIDSEQ;
        !            63:        ocOIDTable[ocNumEntries].oc_may  = NULLTABLE_SEQ;
        !            64:        ocOIDTable[ocNumEntries].oc_must = NULLTABLE_SEQ;
        !            65:        return (&ocOIDTable[ocNumEntries++]);
        !            66: }
        !            67: 
        !            68: objectclass * str2oc (str)
        !            69: char * str;
        !            70: {
        !            71: char * ptr;
        !            72: char * get_oid ();
        !            73: objectclass *oc;
        !            74: 
        !            75:        if ((oc = name2oc (str)) != NULLOBJECTCLASS) 
        !            76:                return (oc);
        !            77: 
        !            78:        /* unknown object class -- need to add to table */
        !            79:        if ((ptr = get_oid (str)) == NULLCP) {
        !            80:                parse_error ("Object class %s unknown",str);
        !            81:                return (NULLOBJECTCLASS);
        !            82:        }
        !            83: 
        !            84:        return (oc_add (str2oid(ptr)));
        !            85: }
        !            86: 
        !            87: static AV_Sequence new_oc_avs (oc)
        !            88: objectclass * oc;
        !            89: {
        !            90: AV_Sequence avs;
        !            91: 
        !            92:        avs = avs_comp_alloc();
        !            93:        avs->avseq_next = NULLAV;
        !            94:        avs->avseq_av.av_syntax = oc_sntx;
        !            95:        avs->avseq_av.av_struct = (caddr_t) oc;
        !            96:        return (avs);
        !            97: }
        !            98: 
        !            99: static AV_Sequence str2oc_hier (str)
        !           100: char * str;
        !           101: {
        !           102: AV_Sequence avs = NULLAV;
        !           103: objectclass * oc;
        !           104: char * ptr, *save, val;
        !           105: 
        !           106:        str = SkipSpace (str);
        !           107: 
        !           108:        while ((ptr = index (str,'&')) != 0) {
        !           109:                save = ptr++;
        !           110:                save--;
        !           111:                if (! isspace (*save))
        !           112:                        save++;
        !           113:                val = *save;
        !           114:                *save = 0;
        !           115: 
        !           116:                if ((oc = str2oc (str)) == NULLOBJECTCLASS)
        !           117:                        return (NULLAV);
        !           118:                if (avs == NULLAV)
        !           119:                        avs = new_oc_avs (oc);
        !           120:                else
        !           121:                        add_oc_avs (oc,&avs);
        !           122:                add_hierarchy (oc,&avs);
        !           123: 
        !           124:                *save = val;
        !           125:                str = SkipSpace(ptr);
        !           126:        }
        !           127: 
        !           128:        if ((oc = str2oc (str)) == NULLOBJECTCLASS)
        !           129:                return (NULLAV);
        !           130:        if (avs == NULLAV)
        !           131:                avs = new_oc_avs (oc);
        !           132:        else
        !           133:                add_oc_avs (oc,&avs);
        !           134:        add_hierarchy (oc,&avs);
        !           135: 
        !           136:        return (avs);
        !           137: }
        !           138: 
        !           139: add_oc_avs (oc,avsp)
        !           140: objectclass * oc;
        !           141: AV_Sequence *avsp;
        !           142: {
        !           143: AV_Sequence loop;
        !           144: objectclass *ocp;
        !           145: 
        !           146:        /* see if we already have oc in heirarchy ... */
        !           147: 
        !           148:        for (loop = *avsp; loop != NULLAV; loop = loop->avseq_next) {
        !           149:                ocp = (objectclass *)loop->avseq_av.av_struct;
        !           150:                if (oc == ocp)
        !           151:                        return;
        !           152:        }
        !           153:        *avsp = avs_merge (*avsp,new_oc_avs(oc));
        !           154: }
        !           155: 
        !           156: static add_hierarchy (oc,avsp)
        !           157: objectclass * oc;
        !           158: AV_Sequence *avsp;
        !           159: {
        !           160: struct oid_seq * oidseq;
        !           161: objectclass *ocp;
        !           162: 
        !           163:        for (oidseq = oc->oc_hierachy; 
        !           164:                        oidseq != NULLOIDSEQ; oidseq = oidseq->oid_next) {
        !           165:                ocp = oid2oc(oidseq->oid_oid);
        !           166:                add_oc_avs (ocp,avsp);
        !           167:                add_hierarchy (ocp,avsp);
        !           168:        }
        !           169: }
        !           170: 
        !           171: 
        !           172: #ifdef notyet
        !           173: static in_hierarchy (a,b)
        !           174: AV_Sequence a, b;
        !           175: {
        !           176: struct oid_seq * oidseq;
        !           177: objectclass *oca, *ocb;
        !           178: 
        !           179:        if ((a == NULLAV) || (a->avseq_av.av_syntax != oc_sntx) || (a->avseq_av.av_struct == NULL))
        !           180:                return (FALSE);
        !           181: 
        !           182:        if ((b == NULLAV) || (b->avseq_av.av_syntax != oc_sntx) || (b->avseq_av.av_struct == NULL))
        !           183:                return (FALSE);
        !           184: 
        !           185:        oca = (objectclass *) a->avseq_av.av_struct;
        !           186:        ocb = (objectclass *) b->avseq_av.av_struct;
        !           187: 
        !           188:        for (oidseq = ocb->oc_hierachy; 
        !           189:                        oidseq != NULLOIDSEQ; oidseq = oidseq->oid_next) 
        !           190:                if (oid_cmp(oca->oc_ot.ot_oid,oidseq->oid_oid) == 0)
        !           191:                        return (TRUE);
        !           192: 
        !           193:        return (FALSE);
        !           194: }
        !           195: 
        !           196: static oc_print_avs (ps,avs,format)  /* need to use this somehow !!! */
        !           197: PS ps;
        !           198: AV_Sequence avs;
        !           199: int format;
        !           200: {
        !           201: AV_Sequence newavs;
        !           202: char found;
        !           203: char printed = FALSE;
        !           204: 
        !           205:        if (avs == NULLAV)
        !           206:                return;
        !           207: 
        !           208:        if (format != READOUT)
        !           209:                DLOG (log_dsap,LLOG_EXCEPTIONS,("invalid call to oc_print"));
        !           210: 
        !           211:        for ( ; avs->avseq_next != NULLAV ; avs=avs->avseq_next) {
        !           212:                found = FALSE;
        !           213:                for (newavs = avs->avseq_next; newavs != NULLAV; newavs=newavs->avseq_next)
        !           214:                        if (in_hierarchy(avs,newavs) == TRUE) {
        !           215:                                found = TRUE;
        !           216:                                break;
        !           217:                        }
        !           218: 
        !           219:                if (found == FALSE) {
        !           220:                        if (printed == TRUE)
        !           221:                                ps_print (ps," & ");
        !           222:                        AttrV_print (ps,&avs->avseq_av,format);
        !           223:                        printed = TRUE;
        !           224:                }
        !           225:        }
        !           226: 
        !           227:        if (printed == TRUE)
        !           228:                ps_print (ps," & ");
        !           229:        AttrV_print (ps,&avs->avseq_av,format);
        !           230: }
        !           231: #endif
        !           232: 
        !           233: objclass_cmp (a,b)
        !           234: objectclass *a, *b;
        !           235: {
        !           236:        if (a == NULLOBJECTCLASS)
        !           237:                return ( b ? -1 : 0 );
        !           238: 
        !           239:        if (b == NULLOBJECTCLASS)
        !           240:                return (1);
        !           241: 
        !           242:        return (oid_cmp(a->oc_ot.ot_oid,b->oc_ot.ot_oid));
        !           243: }
        !           244: 
        !           245: static objectclass * oc_cpy (oc)
        !           246: objectclass * oc;
        !           247: {
        !           248:        return (oc);    /* static table !!! */
        !           249: }
        !           250: 
        !           251: check_in_oc (oid,avs)
        !           252: OID oid;
        !           253: AV_Sequence avs;
        !           254: {
        !           255: objectclass * oc;
        !           256: 
        !           257:        for (; avs != NULLAV; avs = avs->avseq_next) {
        !           258:                oc = (objectclass *) avs->avseq_av.av_struct;
        !           259:                if (oc == NULLOBJECTCLASS)
        !           260:                        continue;
        !           261:                if (oid_cmp(oid,oc->oc_ot.ot_oid) == 0)
        !           262:                        return (TRUE);
        !           263:        }
        !           264: 
        !           265:        return (FALSE);
        !           266: }
        !           267: 
        !           268: /* ARGSUSED */
        !           269: static oc_free (oc)
        !           270: objectclass * oc;
        !           271: {
        !           272:        ;       /* static table !!! */
        !           273: }
        !           274: 
        !           275: static PE oc_enc (oc)
        !           276: objectclass *oc;
        !           277: {
        !           278:        return (oid2prim(oc->oc_ot.ot_oid));
        !           279: }
        !           280: 
        !           281: 
        !           282: static objectclass * oc_dec (pe)
        !           283: PE pe;
        !           284: {
        !           285: OID oid;
        !           286: objectclass *oc;
        !           287: 
        !           288:         if (! test_prim_pe (pe,PE_CLASS_UNIV,PE_PRIM_OID))
        !           289:                return NULLOBJECTCLASS;
        !           290: 
        !           291:        if ((oid = prim2oid (pe)) == NULLOID)
        !           292:                return NULLOBJECTCLASS;
        !           293: 
        !           294:        if ((oc = oid2oc (oid)) != NULLOBJECTCLASS)
        !           295:                return (oc);
        !           296: 
        !           297:        return (oc_add(oid));
        !           298: }
        !           299: 
        !           300: 
        !           301: 
        !           302: oc_print (ps,oc,format)
        !           303: PS ps;
        !           304: objectclass * oc;
        !           305: int format;
        !           306: {
        !           307: extern int oidformat;
        !           308: 
        !           309:        if ( format != READOUT)
        !           310:                ps_printf (ps,"%s",oc2name (oc,OIDPART));
        !           311:        else
        !           312:                ps_printf (ps,"%s",oc2name (oc,oidformat));
        !           313: }
        !           314: 
        !           315: objectclass_syntax ()
        !           316: {
        !           317: 
        !           318:        oc_sntx = add_attribute_syntax ("objectclass",
        !           319:                (IFP) oc_enc,   (IFP) oc_dec,
        !           320:                (IFP) str2oc,   oc_print,
        !           321:                (IFP) oc_cpy,   objclass_cmp,
        !           322:                oc_free,        NULLCP,
        !           323:                NULLIFP,        FALSE );
        !           324: 
        !           325:        oc_hier = (IFP) str2oc_hier;
        !           326:        want_oc_hierarchy ();
        !           327: 
        !           328: }

unix.superglobalmegacorp.com

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