#include "portable.h"
#include <stdio.h>
-#include <stdlib.h>
+
+#include <ac/stdlib.h>
#include <ac/socket.h>
#include <ac/string.h>
ldap_int_initialize();
}
- if(outvalue == NULL) {
- /* no place to get to */
- return LDAP_OPT_ERROR;
- }
-
if(ld == NULL) {
lo = &ldap_int_global_options;
lo = &ld->ld_options;
}
+ if(outvalue == NULL) {
+ /* no place to get to */
+ return LDAP_OPT_ERROR;
+ }
+
switch(option) {
case LDAP_OPT_API_INFO: {
struct ldapapiinfo *info = (struct ldapapiinfo *) outvalue;
for(i=0; features[i].ldapaif_name != NULL; i++) {
info->ldapai_extensions[i] =
- strdup(features[i].ldapaif_name);
+ LDAP_STRDUP(features[i].ldapaif_name);
}
info->ldapai_extensions[i] = NULL;
}
- info->ldapai_vendor_name = strdup(LDAP_VENDOR_NAME);
+ info->ldapai_vendor_name = LDAP_STRDUP(LDAP_VENDOR_NAME);
info->ldapai_vendor_version = LDAP_VENDOR_VERSION;
return LDAP_OPT_SUCCESS;
break;
}
- * (int *) outvalue = ber_pvt_sb_get_desc( &(ld->ld_sb) );
+ * (ber_socket_t *) outvalue = ber_pvt_sb_get_desc( &(ld->ld_sb) );
return LDAP_OPT_SUCCESS;
case LDAP_OPT_DEREF:
return LDAP_OPT_SUCCESS;
case LDAP_OPT_HOST_NAME:
- /*
- * draft-ietf-ldapext-ldap-c-api-01 doesn't state
- * whether caller has to free host names or not,
- * we do.
- */
-
- * (char **) outvalue = strdup(lo->ldo_defhost);
+ * (char **) outvalue = LDAP_STRDUP(lo->ldo_defhost);
return LDAP_OPT_SUCCESS;
case LDAP_OPT_ERROR_NUMBER:
break;
}
- /*
- * draft-ietf-ldapext-ldap-c-api-01 doesn't require
- * the client to have to free error strings, we do
- */
-
if( ld->ld_error == NULL ) {
* (char **) outvalue = NULL;
} else {
- * (char **) outvalue = strdup(ld->ld_error);
+ * (char **) outvalue = LDAP_STRDUP(ld->ld_error);
}
return LDAP_OPT_SUCCESS;
- case LDAP_OPT_MATCH_STRING:
+ case LDAP_OPT_MATCHED_DN:
if(ld == NULL) {
/* bad param */
break;
}
- /*
- * draft-ietf-ldapext-ldap-c-api-01 doesn't require
- * the client to have to free error strings, we do
- */
-
if( ld->ld_matched == NULL ) {
* (char **) outvalue = NULL;
} else {
- * (char **) outvalue = strdup(ld->ld_matched);
+ * (char **) outvalue = LDAP_STRDUP(ld->ld_matched);
}
- return 0;
+ return LDAP_OPT_SUCCESS;
case LDAP_OPT_API_FEATURE_INFO: {
LDAPAPIFeatureInfo *info = (LDAPAPIFeatureInfo *) outvalue;
}
if(host != NULL) {
- lo->ldo_defhost = strdup(host);
+ lo->ldo_defhost = LDAP_STRDUP(host);
return LDAP_OPT_SUCCESS;
}
* must want global default returned
* to initial condition.
*/
- lo->ldo_defhost = strdup("localhost");
+ lo->ldo_defhost = LDAP_STRDUP("localhost");
} else {
/*
* must want the session default
* updated to the current global default
*/
- lo->ldo_defhost = strdup(
+ lo->ldo_defhost = LDAP_STRDUP(
ldap_int_global_options.ldo_defhost);
}
} return LDAP_OPT_SUCCESS;
LDAP_FREE(ld->ld_error);
}
- ld->ld_error = strdup(err);
+ ld->ld_error = LDAP_STRDUP(err);
+ } return LDAP_OPT_SUCCESS;
+
+ case LDAP_OPT_MATCHED_DN: {
+ char* err = (char *) invalue;
+
+ if(ld == NULL) {
+ /* need a struct ldap */
+ break;
+ }
+
+ if( ld->ld_matched ) {
+ LDAP_FREE(ld->ld_matched);
+ }
+
+ ld->ld_matched = LDAP_STRDUP(err);
} return LDAP_OPT_SUCCESS;
case LDAP_OPT_API_FEATURE_INFO: