]> git.sur5r.net Git - openldap/commitdiff
ITS#8262 more
authorHoward Chu <hyc@openldap.org>
Fri, 2 Oct 2015 04:14:53 +0000 (05:14 +0100)
committerQuanah Gibson-Mount <quanah@openldap.org>
Mon, 5 Oct 2015 20:59:40 +0000 (15:59 -0500)
extended ops

libraries/libldap/compare.c
libraries/libldap/extended.c
libraries/libldap/ldap-int.h

index dbeb44aee2fa783b6111fe0d80adcd93df6453ce..822f1e927a845d57137861c9e86d172aee25fb14 100644 (file)
@@ -77,6 +77,8 @@ ldap_build_compare_req(
                ber_free( ber, 1 );
                return( NULL );
        }
+
+       return( ber );
 }
 
 /*
index af69bbf64aea82ef95e0f97578d7b5c7792496ce..3e52e91fecbc43d9a6b4176439429e46b0b69a5b 100644 (file)
 #include "ldap-int.h"
 #include "ldap_log.h"
 
+BerElement *
+ldap_build_extended_req(
+       LDAP                    *ld,
+       LDAP_CONST char *reqoid,
+       struct berval   *reqdata,
+       LDAPControl             **sctrls,
+       LDAPControl             **cctrls,
+       ber_int_t               *msgidp )
+{
+       BerElement *ber;
+       int rc;
+
+       /* create a message to send */
+       if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
+               return( NULL );
+       }
+
+       LDAP_NEXT_MSGID( ld, *msgidp );
+       if ( reqdata != NULL ) {
+               rc = ber_printf( ber, "{it{tstON}", /* '}' */
+                       *msgidp, LDAP_REQ_EXTENDED,
+                       LDAP_TAG_EXOP_REQ_OID, reqoid,
+                       LDAP_TAG_EXOP_REQ_VALUE, reqdata );
+
+       } else {
+               rc = ber_printf( ber, "{it{tsN}", /* '}' */
+                       *msgidp, LDAP_REQ_EXTENDED,
+                       LDAP_TAG_EXOP_REQ_OID, reqoid );
+       }
+
+       if( rc == -1 ) {
+               ld->ld_errno = LDAP_ENCODING_ERROR;
+               ber_free( ber, 1 );
+               return( NULL );
+       }
+
+       /* Put Server Controls */
+       if( ldap_int_put_controls( ld, sctrls, ber ) != LDAP_SUCCESS ) {
+               ber_free( ber, 1 );
+               return( NULL );
+       }
+
+       if ( ber_printf( ber, /*{*/ "N}" ) == -1 ) {
+               ld->ld_errno = LDAP_ENCODING_ERROR;
+               ber_free( ber, 1 );
+               return( NULL );
+       }
+
+       return( ber );
+}
+
 /*
  * LDAPv3 Extended Operation Request
  *     ExtendedRequest ::= [APPLICATION 23] SEQUENCE {
@@ -68,42 +119,10 @@ ldap_extended_operation(
                return( ld->ld_errno );
        }
 
-       /* create a message to send */
-       if ( (ber = ldap_alloc_ber_with_options( ld )) == NULL ) {
-               ld->ld_errno = LDAP_NO_MEMORY;
-               return( ld->ld_errno );
-       }
-
-       LDAP_NEXT_MSGID( ld, id );
-       if ( reqdata != NULL ) {
-               rc = ber_printf( ber, "{it{tstON}", /* '}' */
-                       id, LDAP_REQ_EXTENDED,
-                       LDAP_TAG_EXOP_REQ_OID, reqoid,
-                       LDAP_TAG_EXOP_REQ_VALUE, reqdata );
-
-       } else {
-               rc = ber_printf( ber, "{it{tsN}", /* '}' */
-                       id, LDAP_REQ_EXTENDED,
-                       LDAP_TAG_EXOP_REQ_OID, reqoid );
-       }
-
-       if( rc == -1 ) {
-               ld->ld_errno = LDAP_ENCODING_ERROR;
-               ber_free( ber, 1 );
-               return( ld->ld_errno );
-       }
-
-       /* Put Server Controls */
-       if( ldap_int_put_controls( ld, sctrls, ber ) != LDAP_SUCCESS ) {
-               ber_free( ber, 1 );
-               return ld->ld_errno;
-       }
-
-       if ( ber_printf( ber, /*{*/ "N}" ) == -1 ) {
-               ld->ld_errno = LDAP_ENCODING_ERROR;
-               ber_free( ber, 1 );
+       ber = ldap_build_extended_req( ld, reqoid, reqdata,
+               sctrls, cctrls, &id );
+       if ( !ber )
                return( ld->ld_errno );
-       }
 
        /* send the message */
        *msgidp = ldap_send_initial_request( ld, LDAP_REQ_EXTENDED, NULL, ber, id );
index 65e5becbe3b23550cb121e1c283750746bd0c443..ba7979d393a1a3f0d6216a7fadbc53f42e4c8fba 100644 (file)
@@ -562,6 +562,18 @@ LDAP_F (BerElement *) ldap_build_delete_req LDAP_P((
        LDAPControl **cctrls,
        ber_int_t *msgidp ));
 
+/*
+ * in extended.c
+ */
+
+LDAP_F (BerElement *) ldap_build_extended_req LDAP_P((
+       LDAP *ld,
+       const char *reqoid,
+       struct berval *reqdata,
+       LDAPControl **sctrls,
+       LDAPControl **cctrls,
+       ber_int_t *msgidp ));
+
 /*
  * in init.c
  */