]> git.sur5r.net Git - openldap/commitdiff
Preserve OID macros for display in back-config
authorHoward Chu <hyc@openldap.org>
Sat, 9 Apr 2005 16:13:04 +0000 (16:13 +0000)
committerHoward Chu <hyc@openldap.org>
Sat, 9 Apr 2005 16:13:04 +0000 (16:13 +0000)
servers/slapd/at.c
servers/slapd/cr.c
servers/slapd/oc.c
servers/slapd/oidm.c
servers/slapd/slap.h

index e4030aec05cc6a7f1e85d0b46c32ad75a570847b..f5b27f6a3908d1d97b02406e7b4ed2b254f34d6b 100644 (file)
@@ -323,6 +323,7 @@ at_add(
        int             code;
        char    *cname;
        char    *oid;
+       char    *oidm = NULL;
 
        if ( !OID_LEADCHAR( at->at_oid[0] )) {
                /* Expand OID macros */
@@ -332,7 +333,7 @@ at_add(
                        return SLAP_SCHERR_OIDM;
                }
                if ( oid != at->at_oid ) {
-                       ldap_memfree( at->at_oid );
+                       oidm = at->at_oid;
                        at->at_oid = oid;
                }
        }
@@ -394,6 +395,7 @@ at_add(
 
        sat->sat_cname.bv_val = cname;
        sat->sat_cname.bv_len = strlen( cname );
+       sat->sat_oidmacro = oidm;
        ldap_pvt_thread_mutex_init(&sat->sat_ad_mutex);
 
        if ( at->at_sup_oid ) {
@@ -650,12 +652,20 @@ at_unparse( BerVarray *res, AttributeType *start, AttributeType *end, int sys )
        }
        i = 0;
        for ( at=start; at; at=LDAP_STAILQ_NEXT(at, sat_next)) {
+               LDAPAttributeType lat, *latp;
                if ( sys && !(at->sat_flags & SLAP_AT_HARDCODE)) continue;
-               if ( ldap_attributetype2bv( &at->sat_atype, &bv ) == NULL ) {
+               if ( at->sat_oidmacro ) {
+                       lat = at->sat_atype;
+                       lat.at_oid = at->sat_oidmacro;
+                       latp = &lat;
+               } else {
+                       latp = &at->sat_atype;
+               }
+               if ( ldap_attributetype2bv( latp, &bv ) == NULL ) {
                        ber_bvarray_free( bva );
                }
                if ( !sys ) {
-                       idx.bv_len = sprintf(idx.bv_val, "{%02d}", i);
+                       idx.bv_len = sprintf(idx.bv_val, "{%d}", i);
                }
                bva[i].bv_len = idx.bv_len + bv.bv_len;
                bva[i].bv_val = ch_malloc( bva[i].bv_len + 1 );
index 948f4ec0cda34e88a00aeca5d01188cf5d725f5d..a1c6005e93f2fef14d25a0f4b24d5e411f2d9302 100644 (file)
@@ -340,6 +340,7 @@ cr_add(
        ContentRule     *scr;
        int             code;
        int             op = 0;
+       char    *oidm = NULL;
 
        if ( cr->cr_names != NULL ) {
                int i;
@@ -359,7 +360,7 @@ cr_add(
                        return SLAP_SCHERR_OIDM;
                }
                if ( oid != cr->cr_oid ) {
-                       ldap_memfree( cr->cr_oid );
+                       oidm = cr->cr_oid;
                        cr->cr_oid = oid;
                }
        }
@@ -367,6 +368,7 @@ cr_add(
        scr = (ContentRule *) ch_calloc( 1, sizeof(ContentRule) );
        AC_MEMCPY( &scr->scr_crule, cr, sizeof(LDAPContentRule) );
 
+       scr->scr_oidmacro = oidm;
        scr->scr_sclass = oc_find(cr->cr_oid);
        if ( !scr->scr_sclass ) {
                *err = cr->cr_oid;
@@ -434,12 +436,20 @@ cr_unparse( BerVarray *res, ContentRule *start, ContentRule *end, int sys )
        }
        i = 0;
        for ( cr=start; cr; cr=LDAP_STAILQ_NEXT(cr, scr_next)) {
+               LDAPContentRule lcr, *lcrp;
                if ( sys && !(cr->scr_flags & SLAP_CR_HARDCODE)) continue;
-               if ( ldap_contentrule2bv( &cr->scr_crule, &bv ) == NULL ) {
+               if ( cr->scr_oidmacro ) {
+                       lcr = cr->scr_crule;
+                       lcr.cr_oid = cr->scr_oidmacro;
+                       lcrp = &lcr;
+               } else {
+                       lcrp = &cr->scr_crule;
+               }
+               if ( ldap_contentrule2bv( lcrp, &bv ) == NULL ) {
                        ber_bvarray_free( bva );
                }
                if ( !sys ) {
-                       idx.bv_len = sprintf(idx.bv_val, "{%02d}", i);
+                       idx.bv_len = sprintf(idx.bv_val, "{%d}", i);
                }
                bva[i].bv_len = idx.bv_len + bv.bv_len;
                bva[i].bv_val = ch_malloc( bva[i].bv_len + 1 );
index 2b5b5f06f7f661d5494d9b921236427e55e26ef7..87f4728e0808969872c9fee42549dac15cfa81cc 100644 (file)
@@ -467,6 +467,7 @@ oc_add(
        ObjectClass     *soc;
        int             code;
        int             op = 0;
+       char    *oidm = NULL;
 
        if ( oc->oc_names != NULL ) {
                int i;
@@ -486,7 +487,7 @@ oc_add(
                        return SLAP_SCHERR_OIDM;
                }
                if ( oid != oc->oc_oid ) {
-                       ldap_memfree( oc->oc_oid );
+                       oidm = oc->oc_oid;
                        oc->oc_oid = oid;
                }
        }
@@ -494,6 +495,7 @@ oc_add(
        soc = (ObjectClass *) ch_calloc( 1, sizeof(ObjectClass) );
        AC_MEMCPY( &soc->soc_oclass, oc, sizeof(LDAPObjectClass) );
 
+       soc->soc_oidmacro = oidm;
        if( oc->oc_names != NULL ) {
                soc->soc_cname.bv_val = soc->soc_names[0];
        } else {
@@ -560,12 +562,20 @@ oc_unparse( BerVarray *res, ObjectClass *start, ObjectClass *end, int sys )
        }
        i = 0;
        for ( oc=start; oc; oc=LDAP_STAILQ_NEXT(oc, soc_next)) {
+               LDAPObjectClass loc, *locp;
                if ( sys && !(oc->soc_flags & SLAP_OC_HARDCODE)) continue;
-               if ( ldap_objectclass2bv( &oc->soc_oclass, &bv ) == NULL ) {
+               if ( oc->soc_oidmacro ) {
+                       loc = oc->soc_oclass;
+                       loc.oc_oid = oc->soc_oidmacro;
+                       locp = &loc;
+               } else {
+                       locp = &oc->soc_oclass;
+               }
+               if ( ldap_objectclass2bv( locp, &bv ) == NULL ) {
                        ber_bvarray_free( bva );
                }
                if ( !sys ) {
-                       idx.bv_len = sprintf(idx.bv_val, "{%02d}", i);
+                       idx.bv_len = sprintf(idx.bv_val, "{%d}", i);
                }
                bva[i].bv_len = idx.bv_len + bv.bv_len;
                bva[i].bv_val = ch_malloc( bva[i].bv_len + 1 );
index 0e0f6210a34363626f69820fa36f2479ec786c9d..25407644a495490c64e336492fde6bf2b787ec55 100644 (file)
@@ -184,7 +184,7 @@ void oidm_unparse( BerVarray *res, OidMacro *start, OidMacro *end, int sys )
                if ( sys && !(om->som_flags & SLAP_OM_HARDCODE)) continue;
                for ( j=0; !BER_BVISNULL(&om->som_names[j]); i++,j++ ) {
                        if ( !sys ) {
-                               idx.bv_len = sprintf(idx.bv_val, "{%02d}", i );
+                               idx.bv_len = sprintf(idx.bv_val, "{%d}", i );
                        }
                        bva[i].bv_len = idx.bv_len + om->som_names[j].bv_len +
                                om->som_subs[j].bv_len + 1;
index fc020433c299bb48c3409b93943a834805544c0d..bf9568880c910736190e17f6c7f4c7e945e1a886 100644 (file)
@@ -641,6 +641,7 @@ typedef struct slap_attribute_type {
        Syntax                                  *sat_syntax;
 
        AttributeTypeSchemaCheckFN      *sat_check;
+       char                                    *sat_oidmacro;
 
 #define SLAP_AT_NONE           0x0000U
 #define SLAP_AT_ABSTRACT       0x0100U /* cannot be instantiated */
@@ -700,6 +701,7 @@ typedef struct slap_object_class {
        AttributeType                           **soc_required;
        AttributeType                           **soc_allowed;
        ObjectClassSchemaCheckFN        *soc_check;
+       char                                    *soc_oidmacro;
        slap_mask_t                                     soc_flags;
 #define soc_oid                                soc_oclass.oc_oid
 #define soc_names                      soc_oclass.oc_names
@@ -751,6 +753,7 @@ typedef struct slap_content_rule {
 #define scr_at_oids_may                scr_crule.cr_at_oids_may
 #define scr_at_oids_not                scr_crule.cr_at_oids_not
 
+       char                            *scr_oidmacro;
 #define        SLAP_CR_HARDCODE        0x10000U
        int     scr_flags;