]> git.sur5r.net Git - openldap/commitdiff
implement unload_extop for symmetry (needs test)
authorPierangelo Masarati <ando@openldap.org>
Wed, 30 Jun 2010 00:22:01 +0000 (00:22 +0000)
committerPierangelo Masarati <ando@openldap.org>
Wed, 30 Jun 2010 00:22:01 +0000 (00:22 +0000)
servers/slapd/extended.c
servers/slapd/proto-slap.h

index e53251290bbcdd45caed2d7fba29bf2e609ae350..8030803eb902522b2809cbd170e1ebfdf8c3af93 100644 (file)
@@ -324,6 +324,57 @@ load_extop2(
        return(0);
 }
 
+int
+unload_extop(
+       const struct berval *ext_oid,
+       SLAP_EXTOP_MAIN_FN *ext_main,
+       unsigned flags )
+{
+       struct berval           oidm = BER_BVNULL;
+       struct extop_list       *ext, **extp;
+
+       /* oid must be given */
+       if ( ext_oid == NULL || BER_BVISNULL( ext_oid ) ||
+               BER_BVISEMPTY( ext_oid ) )
+       {
+               return -1; 
+       }
+
+       /* if it's not an oid, check if it's a macto */
+       if ( numericoidValidate( NULL, (struct berval *)ext_oid ) !=
+               LDAP_SUCCESS )
+       {
+               oidm.bv_val = oidm_find( ext_oid->bv_val );
+               if ( oidm.bv_val == NULL ) {
+                       return -1;
+               }
+               oidm.bv_len = strlen( oidm.bv_val );
+               ext_oid = &oidm;
+       }
+
+       /* lookup the oid */
+       for ( extp = &supp_ext_list; *extp; extp = &(*extp)->next ) {
+               if ( bvmatch( ext_oid, &(*extp)->oid ) ) {
+                       /* if ext_main is given, only remove if it matches */
+                       if ( ext_main != NULL && (*extp)->ext_main != ext_main ) {
+                               return -1;
+                       }
+                       break;
+               }
+       }
+
+       if ( *extp == NULL ) {
+               return -1;
+       }
+
+       ext = *extp;
+       *extp = (*extp)->next;
+
+       ch_free( ext );
+
+       return 0;
+}
+
 int
 extops_init (void)
 {
@@ -334,6 +385,7 @@ extops_init (void)
                        builtin_extops[i].flags,
                        builtin_extops[i].ext_main );
        }
+
        return(0);
 }
 
index 7fdf090fac2801336d652447027cb49263e24622..666354ada0077f2974daab2ad86bc4fec6a9bd20 100644 (file)
@@ -1035,6 +1035,10 @@ LDAP_SLAPD_F (int) load_extop2 LDAP_P((
        unsigned tmpflags ));
 #define load_extop(ext_oid, flags, ext_main) \
        load_extop2((ext_oid), (flags), (ext_main), 0)
+LDAP_SLAPD_F (int) unload_extop LDAP_P((
+       const struct berval *ext_oid,
+       SLAP_EXTOP_MAIN_FN *ext_main,
+       unsigned tmpflags ));
 
 LDAP_SLAPD_F (int) extops_init LDAP_P(( void ));