Annotation of 43BSDReno/contrib/isode-beta/dsap/common/oid2.c, revision 1.1.1.1

1.1       root        1: #include "quipu/util.h"
                      2: #include "quipu/entry.h"
                      3: #include "cmd_srch.h"
                      4: #include "tailor.h"
                      5: 
                      6: extern char chrcnv [];
                      7: 
                      8: extern LLog * log_dsap;
                      9: int load_obj_hier();
                     10: int add_oc_macro();
                     11: 
                     12: extern oid_table OIDTable[];
                     13: extern objectclass ocOIDTable[];
                     14: extern oid_table_attr attrOIDTable[];
                     15: extern int NumEntries;
                     16: extern int attrNumEntries;
                     17: extern int ocNumEntries;
                     18: static table_seq table_seq_new ();
                     19: 
                     20: struct mac_buf {                        /* for handling macros */
                     21:        char name [BUFSIZE];
                     22:        char value [LINESIZE];
                     23: } macro [BUFSIZE];
                     24: 
                     25: int NumMacro            = 0;
                     26: 
                     27: want_oc_hierarchy ()
                     28: {
                     29: extern IFP oc_load;
                     30: extern IFP oc_macro_add;
                     31: 
                     32:        oc_load = load_obj_hier;
                     33:        oc_macro_add = add_oc_macro;
                     34: }
                     35: 
                     36: load_obj_hier (sep,newname)
                     37: char * sep;
                     38: char * newname;
                     39: {
                     40:        if (sep == 0) {
                     41:                LLOG (log_dsap,LLOG_FATAL,("hierarchy missing %s",newname));
                     42:                return NOTOK;
                     43:        }
                     44:        if (get_oc_bits (sep) != OK) {
                     45:                LLOG (log_dsap,LLOG_FATAL,("(%s)",newname));
                     46:                return NOTOK;
                     47:        }
                     48: 
                     49:        return OK;
                     50: }
                     51: 
                     52: static get_oc_bits (str)
                     53: register char * str;
                     54: {
                     55: register char * ptr;
                     56: register char * ptr2;
                     57: struct oid_seq * oidseq = NULLOIDSEQ, *oidseqptr = oidseq;
                     58: objectclass * oc;
                     59: 
                     60:        if ((ptr = index (str,SEPERATOR)) == 0) {
                     61:                LLOG (log_dsap,LLOG_FATAL,("must missing"));
                     62:                return (NOTOK);
                     63:        }
                     64:        *ptr++ = 0;
                     65: 
                     66:        while (( ptr2 = index (str,COMMA)) != 0) {
                     67:                *ptr2++ = 0;
                     68:                oidseqptr = (struct oid_seq *) smalloc (sizeof (struct oid_seq));
                     69:                if ((oc = name2oc(str)) == NULLOBJECTCLASS) {
                     70:                        LLOG (log_dsap,LLOG_FATAL,("unknown objectclass in hierachy %s",str));
                     71:                        return (NOTOK);
                     72:                }
                     73:                oidseqptr->oid_oid = oc->oc_ot.ot_oid;
                     74:                oidseqptr->oid_next = NULLOIDSEQ;
                     75:                oidseq = oid_seq_merge (oidseq,oidseqptr);
                     76:                str = ptr2;
                     77:        }
                     78:        if (*str != 0) {
                     79:                oidseqptr = (struct oid_seq *) smalloc (sizeof (struct oid_seq));
                     80:                                        /* no logging -> never freed */
                     81:                if ((oc = name2oc(str)) == NULLOBJECTCLASS) {
                     82:                        LLOG (log_dsap,LLOG_FATAL,("unknown objectclass in hierachy %s",str));
                     83:                        return (NOTOK);
                     84:                }
                     85:                oidseqptr->oid_oid = oc->oc_ot.ot_oid;
                     86:                oidseqptr->oid_next = NULLOIDSEQ;
                     87:                oidseq = oid_seq_merge (oidseq,oidseqptr);
                     88:                ocOIDTable[ocNumEntries].oc_hierachy = oidseq;
                     89:        } else
                     90:                ocOIDTable[ocNumEntries].oc_hierachy = NULLOIDSEQ;
                     91: 
                     92:        str = ptr;
                     93:        if ((ptr = index (str,SEPERATOR)) == 0) {
                     94:                LLOG (log_dsap,LLOG_FATAL,("may element missing"));
                     95:                return (NOTOK);
                     96:        }
                     97:        *ptr++ = 0;
                     98: 
                     99:        ocOIDTable[ocNumEntries].oc_may  = table_seq_new (ptr);
                    100:        ocOIDTable[ocNumEntries].oc_must = table_seq_new (str);
                    101: 
                    102:        return (OK);
                    103: }
                    104: 
                    105: static table_seq undo_macro (top,ptr)
                    106: table_seq top;
                    107: register char * ptr;
                    108: {
                    109: register int i;
                    110: table_seq tab;
                    111: table_seq tab_top;
                    112: table_seq trail = NULLTABLE_SEQ;
                    113: 
                    114:        if (*ptr == 0)
                    115:                return (top);
                    116: 
                    117:        for (i=0; i<NumMacro; i++)
                    118:                if (lexequ (macro[i].name,ptr) == 0) {
                    119:                        tab_top= table_seq_new (macro[i].value);
                    120:                        for (tab=tab_top; tab!=NULLTABLE_SEQ; tab=tab->ts_next)
                    121:                                trail = tab;
                    122:                        if (trail != NULLTABLE_SEQ) {
                    123:                                trail->ts_next = top;
                    124:                                return (tab_top);
                    125:                        } else
                    126:                                return (top);
                    127:                }
                    128: 
                    129:        LLOG (log_dsap,LLOG_FATAL,("can't interpret %s in must/may field",ptr));
                    130:        return (top);
                    131: }
                    132: 
                    133: static table_seq table_seq_new (str)
                    134: register char * str;
                    135: {
                    136: register char * ptr;
                    137: table_seq tptr;
                    138: table_seq top = NULLTABLE_SEQ;
                    139: oid_table_attr * at;
                    140: 
                    141:        if (*str == 0)
                    142:                return (NULLTABLE_SEQ);
                    143: 
                    144:        while ((ptr = index (str,COMMA)) != 0) {
                    145:                *ptr = 0;
                    146:                if ((at = name2attr (str)) == NULLTABLE_ATTR)
                    147:                        top = undo_macro (top,str);
                    148:                else {
                    149:                        tptr = (table_seq) smalloc (sizeof (*tptr));
                    150:                                        /* no logging -> never freed */
                    151:                        tptr->ts_oa = at;
                    152:                        tptr->ts_next = top;
                    153:                        top = tptr;
                    154:                }
                    155:                *ptr = COMMA;
                    156:                str = ptr + 1;
                    157:        }
                    158: 
                    159:        if (str != 0) {
                    160:                if ((at = name2attr (str)) == NULLTABLE_ATTR)
                    161:                        return (undo_macro (top,str));
                    162:                else {
                    163:                        tptr = (table_seq) smalloc (sizeof (*tptr));
                    164:                                        /* no logging -> never freed */
                    165:                        tptr->ts_oa = at;
                    166:                        tptr->ts_next = top;
                    167:                        return (tptr);
                    168:                }
                    169:        } else
                    170:                return (NULLTABLE_SEQ);
                    171: 
                    172: }
                    173: 
                    174: 
                    175: 
                    176: void   dumpalloid ()
                    177: {
                    178: register int i;
                    179: register objectclass      * oc = &ocOIDTable[0];
                    180: register oid_table_attr   * at = &attrOIDTable[0];
                    181: register oid_table        * oi = &OIDTable[0];
                    182:  
                    183:        for (i=0;i<ocNumEntries;i++,oc++)
                    184:                (void) printf("\"%s\"\t\t%s\n", oc->oc_ot.ot_name, oc->oc_ot.ot_stroid);
                    185:  
                    186:        for (i=0;i<attrNumEntries;i++,at++)
                    187:                (void) printf("\"%s\"\t\t%s\n", at->oa_ot.ot_name, at->oa_ot.ot_stroid);
                    188:  
                    189:        for (i=0;i<NumEntries;i++,oi++)
                    190:                (void) printf("\"%s\"\t\t%s\n", oi->ot_name, oi->ot_stroid);
                    191:   
                    192:   }
                    193: 
                    194: 
                    195: add_oc_macro (buf,ptr)
                    196: char * buf, *ptr;
                    197: {
                    198:        (void) strcpy(macro[NumMacro].name,buf);
                    199:        (void) strcpy(macro[NumMacro++].value,ptr);
                    200: }

unix.superglobalmegacorp.com

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