]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/extended.c
silence warning
[openldap] / servers / slapd / extended.c
index ba43d86ee1eb6a00d2c5ee7318cf4c533445064a..4c6f1718b34a2c3a89ec2a3a6ef7a43a058d3aa0 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2009 The OpenLDAP Foundation.
+ * Copyright 1999-2011 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -120,7 +120,6 @@ do_extended(
 )
 {
        struct berval reqdata = {0, NULL};
-       ber_tag_t tag;
        ber_len_t len;
 
        Debug( LDAP_DEBUG_TRACE, "%s do_extended\n",
@@ -142,8 +141,6 @@ do_extended(
                goto done;
        }
 
-       tag = ber_peek_tag( op->o_ber, &len );
-       
        if( ber_peek_tag( op->o_ber, &len ) == LDAP_TAG_EXOP_REQ_VALUE ) {
                if( ber_scanf( op->o_ber, "m", &reqdata ) == LBER_ERROR ) {
                        Debug( LDAP_DEBUG_ANY, "%s do_extended: ber_scanf failed\n",
@@ -247,10 +244,12 @@ fe_extended( Operation *op, SlapReply *rs )
 
                if ( rs->sr_rspoid != NULL ) {
                        free( (char *)rs->sr_rspoid );
+                       rs->sr_rspoid = NULL;
                }
 
                if ( rs->sr_rspdata != NULL ) {
                        ber_bvfree( rs->sr_rspdata );
+                       rs->sr_rspdata = NULL;
                }
        } /* end of OpenLDAP extended operation */
 
@@ -324,6 +323,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 +384,7 @@ extops_init (void)
                        builtin_extops[i].flags,
                        builtin_extops[i].ext_main );
        }
+
        return(0);
 }