mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-03-01 14:15:49 +08:00
s/LDAP_OPT_MATCHED_STRING/LDAP_OPT_MATCHED_DN/
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.
This commit is contained in:
parent
b219b6aa48
commit
8c772985c7
@ -87,7 +87,10 @@ ldap_add( LDAP *ld, LDAP_CONST char *dn, LDAPMod **attrs )
|
||||
* 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 )
|
||||
@ -96,6 +99,10 @@ ldap_add_ext( LDAP *ld, LDAP_CONST char *dn, LDAPMod **attrs,
|
||||
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 ) {
|
||||
|
@ -135,5 +135,8 @@ void
|
||||
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;
|
||||
}
|
||||
|
@ -54,6 +54,12 @@ ldap_compare_ext(
|
||||
|
||||
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 );
|
||||
|
@ -218,6 +218,8 @@ int ldap_int_get_controls LDAP_P((
|
||||
void
|
||||
ldap_control_free( LDAPControl *c )
|
||||
{
|
||||
assert( c != NULL );
|
||||
|
||||
if ( c != NULL ) {
|
||||
if( c->ldctl_oid != NULL) {
|
||||
LDAP_FREE( c->ldctl_oid );
|
||||
@ -237,6 +239,8 @@ ldap_control_free( LDAPControl *c )
|
||||
void
|
||||
ldap_controls_free( LDAPControl **controls )
|
||||
{
|
||||
assert( controls != NULL );
|
||||
|
||||
if ( controls != NULL ) {
|
||||
LDAPControl *c;
|
||||
|
||||
|
@ -48,6 +48,11 @@ ldap_delete_ext(
|
||||
|
||||
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;
|
||||
|
@ -120,15 +120,15 @@ ldap_err2string( int err )
|
||||
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 );
|
||||
|
@ -49,10 +49,6 @@ ldap_extended_operation(
|
||||
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 );
|
||||
|
@ -126,6 +126,7 @@ ldap_mods_free( LDAPMod **mods, int freemods )
|
||||
LDAP_FREE( (char *) mods[i] );
|
||||
}
|
||||
|
||||
if ( freemods )
|
||||
if ( freemods ) {
|
||||
LDAP_FREE( (char *) mods );
|
||||
}
|
||||
}
|
||||
|
@ -26,12 +26,13 @@ ldap_first_attribute( LDAP *ld, LDAPMessage *entry, BerElement **ber )
|
||||
{
|
||||
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 );
|
||||
@ -62,12 +63,13 @@ ldap_next_attribute( LDAP *ld, LDAPMessage *entry, BerElement *ber )
|
||||
{
|
||||
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 ) {
|
||||
|
@ -25,6 +25,9 @@
|
||||
LDAPMessage *
|
||||
ldap_first_entry( LDAP *ld, LDAPMessage *chain )
|
||||
{
|
||||
assert( ld != NULL );
|
||||
assert( LDAP_VALID( ld ) );
|
||||
|
||||
if( ld == NULL || chain == NULLMSG ) {
|
||||
return NULLMSG;
|
||||
}
|
||||
@ -34,10 +37,12 @@ ldap_first_entry( LDAP *ld, LDAPMessage *chain )
|
||||
: 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;
|
||||
}
|
||||
@ -55,12 +60,14 @@ ldap_next_entry( LDAP *ld, LDAPMessage *entry )
|
||||
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;
|
||||
}
|
||||
@ -78,12 +85,17 @@ int
|
||||
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;
|
||||
@ -97,7 +109,7 @@ ldap_get_entry_controls(
|
||||
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 ) {
|
||||
|
@ -255,6 +255,10 @@ SOURCE=..\..\include\ldapconfig.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\messages.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\modify.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -19,18 +19,25 @@
|
||||
|
||||
#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;
|
||||
}
|
||||
@ -38,12 +45,14 @@ ldap_next_message( LDAP *ld, LDAPMessage *msg )
|
||||
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;
|
||||
}
|
||||
|
@ -76,10 +76,6 @@ ldap_rename(
|
||||
|
||||
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 );
|
||||
|
@ -200,12 +200,6 @@ ldap_get_option(
|
||||
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;
|
||||
|
||||
@ -223,11 +217,6 @@ ldap_get_option(
|
||||
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 {
|
||||
@ -236,24 +225,19 @@ ldap_get_option(
|
||||
|
||||
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;
|
||||
@ -460,6 +444,21 @@ ldap_set_option(
|
||||
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;
|
||||
|
@ -58,6 +58,9 @@ ldap_simple_bind( LDAP *ld, LDAP_CONST char *dn, LDAP_CONST char *passwd )
|
||||
|
||||
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 )
|
||||
|
@ -22,13 +22,31 @@
|
||||
|
||||
#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.
|
||||
@ -341,11 +359,6 @@ put_complex_filter( BerElement *ber, char *str, unsigned long tag, int not )
|
||||
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 );
|
||||
@ -359,11 +372,6 @@ put_complex_filter( BerElement *ber, char *str, unsigned long tag, int not )
|
||||
if ( ber_printf( ber, "}" ) == -1 )
|
||||
return( NULL );
|
||||
|
||||
#if 0
|
||||
if ( !not && ber_printf( ber, "}" ) == -1 )
|
||||
return( NULL );
|
||||
#endif
|
||||
|
||||
return( next );
|
||||
}
|
||||
|
||||
@ -576,7 +584,9 @@ put_filter_list( BerElement *ber, char *str )
|
||||
}
|
||||
|
||||
static int
|
||||
put_simple_filter( BerElement *ber, char *str )
|
||||
put_simple_filter(
|
||||
BerElement *ber,
|
||||
char *str )
|
||||
{
|
||||
char *s;
|
||||
char *value, savechar;
|
||||
@ -604,6 +614,10 @@ put_simple_filter( BerElement *ber, char *str )
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user