Added place holder for LDAP_FILTER_EXTENDED code.
Added assert() here and there and removed lint.
Removed version promotion code (version must be manually set).
Added messages.c to MSVC project.
* rc = ldap_add_ext( ld, dn, attrs, NULL, NULL, &msgid );
*/
int
-ldap_add_ext( LDAP *ld, LDAP_CONST char *dn, LDAPMod **attrs,
+ldap_add_ext(
+ LDAP *ld,
+ LDAP_CONST char *dn,
+ LDAPMod **attrs,
LDAPControl **sctrls,
LDAPControl **cctrls,
int *msgidp )
int i, rc;
Debug( LDAP_DEBUG_TRACE, "ldap_add\n", 0, 0, 0 );
+ assert( ld != NULL );
+ assert( LDAP_VALID( ld ) );
+ assert( dn != NULL );
+ assert( msgidp != NULL );
/* create a message to send */
if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) {
ldap_set_rebind_proc( LDAP *ld, int (*rebindproc)( LDAP *ld, char **dnp,
char **passwdp, int *authmethodp, int freeit ))
{
+ assert( ld != NULL );
+ assert( LDAP_VALID( ld ) );
+
ld->ld_rebindproc = rebindproc;
}
Debug( LDAP_DEBUG_TRACE, "ldap_compare\n", 0, 0, 0 );
+ assert( ld != NULL );
+ assert( LDAP_VALID( ld ) );
+ assert( dn != NULL );
+ assert( attr != NULL );
+ assert( msgidp != NULL );
+
/* create a message to send */
if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) {
return( LDAP_NO_MEMORY );
void
ldap_control_free( LDAPControl *c )
{
+ assert( c != NULL );
+
if ( c != NULL ) {
if( c->ldctl_oid != NULL) {
LDAP_FREE( c->ldctl_oid );
void
ldap_controls_free( LDAPControl **controls )
{
+ assert( controls != NULL );
+
if ( controls != NULL ) {
LDAPControl *c;
Debug( LDAP_DEBUG_TRACE, "ldap_delete\n", 0, 0, 0 );
+ assert( ld != NULL );
+ assert( LDAP_VALID( ld ) );
+ assert( dn != NULL );
+ assert( msgidp != NULL );
+
/* create a message to send */
if ( (ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) {
ld->ld_errno = LDAP_NO_MEMORY;
void
ldap_perror( LDAP *ld, LDAP_CONST char *str )
{
- char *s;
+ const char *s;
struct ldaperror *e;
Debug( LDAP_DEBUG_TRACE, "ldap_perror\n", 0, 0, 0 );
assert( ld != NULL );
assert( LDAP_VALID( ld ) );
- assert( s );
+ assert( str );
- s = ( str != NULL ) ? (char *) str : "ldap_perror";
+ s = ( str != NULL ) ? str : "ldap_perror";
if ( ld == NULL ) {
perror( s );
assert( msgidp != NULL );
/* must be version 3 (or greater) */
- if ( ld->ld_version == 0 ) {
- ld->ld_version = LDAP_VERSION3;
- }
-
if ( ld->ld_version < LDAP_VERSION3 ) {
ld->ld_errno = LDAP_NOT_SUPPORTED;
return( ld->ld_errno );
LDAP_FREE( (char *) mods[i] );
}
- if ( freemods )
+ if ( freemods ) {
LDAP_FREE( (char *) mods );
+ }
}
{
char *attr;
+ Debug( LDAP_DEBUG_TRACE, "ldap_first_attribute\n", 0, 0, 0 );
+
assert( ld != NULL );
+ assert( LDAP_VALID( ld ) );
assert( entry != NULL );
assert( ber != NULL );
- Debug( LDAP_DEBUG_TRACE, "ldap_first_attribute\n", 0, 0, 0 );
-
if ( (*ber = ldap_alloc_ber_with_options( ld )) == NULLBER ) {
*ber = NULL;
return( NULL );
{
char *attr;
+ Debug( LDAP_DEBUG_TRACE, "ldap_next_attribute\n", 0, 0, 0 );
+
assert( ld != NULL );
+ assert( LDAP_VALID( ld ) );
assert( entry != NULL );
assert( ber != NULL );
- Debug( LDAP_DEBUG_TRACE, "ldap_next_attribute\n", 0, 0, 0 );
-
/* skip sequence, snarf attribute type, skip values */
if ( ber_scanf( ber, "{ax}", &attr )
== LBER_ERROR ) {
LDAPMessage *
ldap_first_entry( LDAP *ld, LDAPMessage *chain )
{
+ assert( ld != NULL );
+ assert( LDAP_VALID( ld ) );
+
if( ld == NULL || chain == NULLMSG ) {
return NULLMSG;
}
: ldap_next_entry( ld, chain );
}
-/* ARGSUSED */
LDAPMessage *
ldap_next_entry( LDAP *ld, LDAPMessage *entry )
{
+ assert( ld != NULL );
+ assert( LDAP_VALID( ld ) );
+
if ( ld == NULL || entry == NULLMSG ) {
return NULLMSG;
}
return( NULLMSG );
}
-/* ARGSUSED */
int
ldap_count_entries( LDAP *ld, LDAPMessage *chain )
{
int i;
+ assert( ld != NULL );
+ assert( LDAP_VALID( ld ) );
+
if ( ld == NULL ) {
return -1;
}
ldap_get_entry_controls(
LDAP *ld,
LDAPMessage *entry,
- LDAPControl ***serverctrls)
+ LDAPControl ***sctrls )
{
int rc;
BerElement be;
- if ( ld == NULL || serverctrls == NULL ||
+ assert( ld != NULL );
+ assert( LDAP_VALID( ld ) );
+ assert( entry != NULL );
+ assert( sctrls != NULL );
+
+ if ( ld == NULL || sctrls == NULL ||
entry == NULL || entry->lm_msgtype == LDAP_RES_SEARCH_ENTRY )
{
return LDAP_PARAM_ERROR;
goto cleanup_and_return;
}
- rc = ldap_int_get_controls( &be, serverctrls );
+ rc = ldap_int_get_controls( &be, sctrls );
cleanup_and_return:
if( rc != LDAP_SUCCESS ) {
# End Source File
# Begin Source File
+SOURCE=.\messages.c
+# End Source File
+# Begin Source File
+
SOURCE=.\modify.c
# End Source File
# Begin Source File
#include "ldap-int.h"
-/* ARGSUSED */
LDAPMessage *
ldap_first_message( LDAP *ld, LDAPMessage *chain )
{
- return( ld == NULL || chain == NULLMSG
- ? NULLMSG : chain );
+ assert( ld != NULL );
+ assert( LDAP_VALID( ld ) );
+
+ if ( ld == NULL || chain == NULLMSG ) {
+ return NULLMSG;
+ }
+
+ return chain;
}
-/* ARGSUSED */
LDAPMessage *
ldap_next_message( LDAP *ld, LDAPMessage *msg )
{
+ assert( ld != NULL );
+ assert( LDAP_VALID( ld ) );
+
if ( ld == NULL || msg == NULLMSG || msg->lm_chain == NULL ) {
return NULLMSG;
}
return( msg->lm_chain );
}
-/* ARGSUSED */
int
ldap_count_messages( LDAP *ld, LDAPMessage *chain )
{
int i;
+ assert( ld != NULL );
+ assert( LDAP_VALID( ld ) );
+
if ( ld == NULL ) {
return -1;
}
if( newSuperior != NULL ) {
/* must be version 3 (or greater) */
- if ( ld->ld_version == 0 ) {
- ld->ld_version = LDAP_VERSION3;
- }
-
if ( ld->ld_version < LDAP_VERSION3 ) {
ld->ld_errno = LDAP_NOT_SUPPORTED;
ber_free( ber, 1 );
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 = LDAP_STRDUP(lo->ldo_defhost);
return LDAP_OPT_SUCCESS;
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 {
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 = LDAP_STRDUP(ld->ld_matched);
}
- return 0;
+ return LDAP_OPT_SUCCESS;
case LDAP_OPT_API_FEATURE_INFO: {
LDAPAPIFeatureInfo *info = (LDAPAPIFeatureInfo *) outvalue;
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:
/* read-only */
break;
Debug( LDAP_DEBUG_TRACE, "ldap_simple_bind\n", 0, 0, 0 );
+ assert( ld != NULL );
+ assert( LDAP_VALID( ld ) );
+
if ( dn == NULL )
dn = "";
if ( passwd == NULL )
#include "ldap-int.h"
-static char *find_right_paren LDAP_P(( char *s ));
-static char *put_complex_filter LDAP_P(( BerElement *ber, char *str,
- unsigned long tag, int not ));
-static int put_filter LDAP_P(( BerElement *ber, char *str ));
-static int put_simple_filter LDAP_P(( BerElement *ber, char *str ));
-static int put_substring_filter LDAP_P(( BerElement *ber, char *type, char *str ));
-static int put_filter_list LDAP_P(( BerElement *ber, char *str ));
+static char *find_right_paren LDAP_P((
+ char *s ));
+
+static char *put_complex_filter LDAP_P((
+ BerElement *ber,
+ char *str,
+ unsigned long tag,
+ int not ));
+
+static int put_filter LDAP_P((
+ BerElement *ber,
+ char *str ));
+
+static int put_simple_filter LDAP_P((
+ BerElement *ber,
+ char *str ));
+
+static int put_substring_filter LDAP_P((
+ BerElement *ber,
+ char *type,
+ char *str ));
+
+static int put_filter_list LDAP_P((
+ BerElement *ber,
+ char *str ));
/*
* ldap_search_ext - initiate an ldap search operation.
if ( ber_printf( ber, "t{", tag ) == -1 )
return( NULL );
-#if 0
- if ( !not && ber_printf( ber, "{" ) == -1 )
- return( NULL );
-#endif
-
str++;
if ( (next = find_right_paren( str )) == NULL )
return( NULL );
if ( ber_printf( ber, "}" ) == -1 )
return( NULL );
-#if 0
- if ( !not && ber_printf( ber, "}" ) == -1 )
- return( NULL );
-#endif
-
return( next );
}
}
static int
-put_simple_filter( BerElement *ber, char *str )
+put_simple_filter(
+ BerElement *ber,
+ char *str )
{
char *s;
char *value, savechar;
ftype = LDAP_FILTER_APPROX;
*s = '\0';
break;
+ case ':': /* LDAPv3 extended filter */
+ ftype = LDAP_FILTER_EXTENDED;
+ return -1;
+ break;
default:
if ( strchr( value, '*' ) == NULL ) {
ftype = LDAP_FILTER_EQUALITY;