]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/options.c
Added the functions ldap_rename2() and ldap_rename2_s() to support LDAP
[openldap] / libraries / libldap / options.c
index 0fd9ef5c70ce506c4450c2da43f3be73ef85d83d..7bc03b141dcc389ff7db875906e0a5221cc204b8 100644 (file)
@@ -1,3 +1,8 @@
+/*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+
 #include "portable.h"
 
 #include <stdio.h>
@@ -88,13 +93,13 @@ ldap_get_option(
 
                                for(i=0; features[i].ldapaif_name != NULL; i++) {
                                        info->ldapai_extensions[i] =
-                                               ldap_strdup(features[i].ldapaif_name);
+                                               strdup(features[i].ldapaif_name);
                                }
 
                                info->ldapai_extensions[i] = NULL;
                        }
 
-                       info->ldapai_vendor_name = ldap_strdup(LDAP_VENDOR_NAME);
+                       info->ldapai_vendor_name = strdup(LDAP_VENDOR_NAME);
                        info->ldapai_vendor_version = LDAP_VENDOR_VERSION;
 
                        return 0;
@@ -106,7 +111,7 @@ ldap_get_option(
                        break;
                } 
 
-               * (int *) outvalue = ld->ld_sb.sb_sd;
+               * (int *) outvalue = lber_pvt_sb_get_desc( &(ld->ld_sb) );
                return 0;
 
        case LDAP_OPT_DEREF:
@@ -142,21 +147,25 @@ ldap_get_option(
                return 0;
 
        case LDAP_OPT_SERVER_CONTROLS:
-               /* not yet supported */
-               break;
+               * (LDAPControl ***) outvalue =
+                       ldap_controls_dup( lo->ldo_server_controls );
+
+               return 0;
 
        case LDAP_OPT_CLIENT_CONTROLS:
-               /* not yet supported */
-               break;
+               * (LDAPControl ***) outvalue =
+                       ldap_controls_dup( lo->ldo_client_controls );
+
+               return 0;
 
        case LDAP_OPT_HOST_NAME:
                /*
                 * draft-ietf-ldapext-ldap-c-api-01 doesn't state
-                * whether client to have to free host names or no,
-                * we do
+                * whether caller has to free host names or not,
+                * we do.
                 */
 
-               * (char **) outvalue = ldap_strdup(lo->ldo_defhost);
+               * (char **) outvalue = strdup(lo->ldo_defhost);
                return 0;
 
        case LDAP_OPT_ERROR_NUMBER:
@@ -181,8 +190,9 @@ ldap_get_option(
                if( ld->ld_error == NULL ) {
                        * (char **) outvalue = NULL;
                } else {
-                       * (char **) outvalue = ldap_strdup(ld->ld_error);
+                       * (char **) outvalue = strdup(ld->ld_error);
                }
+
                return 0;
 
        case LDAP_OPT_API_FEATURE_INFO: {
@@ -281,12 +291,42 @@ ldap_set_option(
                } return 0;
 
        case LDAP_OPT_SERVER_CONTROLS: {
-                       /* not yet supported */
-               } break;
+                       LDAPControl **controls = (LDAPControl **) invalue;
+
+                       ldap_controls_free( lo->ldo_server_controls );
+
+                       if( controls == NULL || *controls == NULL ) {
+                               lo->ldo_server_controls = NULL;
+                               return 0;
+                       }
+                               
+                       lo->ldo_server_controls =
+                               ldap_controls_dup( (LDAPControl **) invalue );
+
+                       if(lo->ldo_server_controls == NULL) {
+                               /* memory allocation error ? */
+                               break;
+                       }
+               } return 0;
 
        case LDAP_OPT_CLIENT_CONTROLS: {
-                       /* not yet supported */
-               } break;
+                       LDAPControl **controls = (LDAPControl **) invalue;
+
+                       ldap_controls_free( lo->ldo_client_controls );
+
+                       if( controls == NULL || *controls == NULL ) {
+                               lo->ldo_client_controls = NULL;
+                               return 0;
+                       }
+                               
+                       lo->ldo_client_controls =
+                               ldap_controls_dup( (LDAPControl **) invalue );
+
+                       if(lo->ldo_client_controls == NULL) {
+                               /* memory allocation error ? */
+                               break;
+                       }
+               } return 0;
 
        case LDAP_OPT_HOST_NAME: {
                        char* host = (char *) invalue;
@@ -297,7 +337,7 @@ ldap_set_option(
                        }
 
                        if(host != NULL) {
-                               lo->ldo_defhost = ldap_strdup(host);
+                               lo->ldo_defhost = strdup(host);
                                return 0;
                        }
 
@@ -306,14 +346,14 @@ ldap_set_option(
                                 * must want global default returned
                                 * to initial condition.
                                 */
-                               lo->ldo_defhost = ldap_strdup("localhost");
+                               lo->ldo_defhost = strdup("localhost");
 
                        } else {
                                /*
                                 * must want the session default
                                 *   updated to the current global default
                                 */
-                               lo->ldo_defhost = ldap_strdup(
+                               lo->ldo_defhost = strdup(
                                        openldap_ldap_global_options.ldo_defhost);
                        }
                } return 0;