X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Flibldap%2Fufn.c;h=9d215cdec999aa45eb2333482374cbee70225c60;hb=91e24173d0fa168bdd3e585af2d56f3299a20c00;hp=342bd8a1e94e1068b2374780c5cf84e37d8563cf;hpb=027d2fadc635098e4238f3acc391748ba87950e4;p=openldap diff --git a/libraries/libldap/ufn.c b/libraries/libldap/ufn.c index 342bd8a1e9..9d215cdec9 100644 --- a/libraries/libldap/ufn.c +++ b/libraries/libldap/ufn.c @@ -1,3 +1,4 @@ +/* $OpenLDAP$ */ /* * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved. * COPYING RESTRICTIONS APPLY, see COPYRIGHT file @@ -12,15 +13,16 @@ #include "portable.h" #include -#include -#include -#include +#include + +#include #include +#include #include #include "ldap-int.h" -#include "ldapconfig.h" +#include "ldap_defaults.h" typedef int (*cancelptype) LDAP_P(( void *cancelparm )); @@ -46,8 +48,8 @@ static LDAPMessage *ldap_ufn_expand LDAP_P(( LDAP *ld, cancelptype cancelproc, * attrsonly 1 => attributes only 0 => attributes and values * res will contain the result of the search * cancelproc routine that returns non-zero if operation should be - * cancelled. This can be NULL. If it is non-NULL, the - * routine will be called periodically. + * cancelled. This can be a null function pointer. If + * it is not 0, the routine will be called periodically. * cancelparm void * that is passed to cancelproc * tag[123] the ldapfilter.conf tag that will be used in phases * 1, 2, and 3 of the search, respectively @@ -125,11 +127,11 @@ ldap_ufn_search_ctx( LDAP *ld, char **ufncomp, int ncomp, char *prefix, if ( candidates == NULL ) { if ( prefix != NULL ) { - if ( (dns = (char **) malloc( sizeof(char *) + if ( (dns = (char **) LDAP_MALLOC( sizeof(char *) * 2 )) == NULL ) { return( ld->ld_errno = LDAP_NO_MEMORY ); } - dns[0] = strdup( prefix ); + dns[0] = LDAP_STRDUP( prefix ); dns[1] = NULL; } else { dns = NULL; @@ -144,14 +146,14 @@ ldap_ufn_search_ctx( LDAP *ld, char **ufncomp, int ncomp, char *prefix, continue; if ( dns == NULL ) { - if ( (dns = (char **) malloc( + if ( (dns = (char **) LDAP_MALLOC( sizeof(char *) * 8 )) == NULL ) { ld->ld_errno = LDAP_NO_MEMORY; return( LDAP_NO_MEMORY ); } max = 8; } else if ( i >= max ) { - if ( (dns = (char **) realloc( dns, + if ( (dns = (char **) LDAP_REALLOC( dns, sizeof(char *) * 2 * max )) == NULL ) { @@ -217,7 +219,8 @@ ldap_ufn_search_ctx( LDAP *ld, char **ufncomp, int ncomp, char *prefix, } int -ldap_ufn_search_ct( LDAP *ld, char *ufn, char **attrs, int attrsonly, +ldap_ufn_search_ct( + LDAP *ld, LDAP_CONST char *ufn, char **attrs, int attrsonly, LDAPMessage **res, cancelptype cancelproc, void *cancelparm, char *tag1, char *tag2, char *tag3 ) { @@ -263,7 +266,7 @@ ldap_ufn_search_ct( LDAP *ld, char *ufn, char **attrs, int attrsonly, } for ( pcomp = 0; prefixcomp[pcomp] != NULL; pcomp++ ) ; /* NULL */ - if ( (pbuf = (char *) malloc( strlen( ld->ld_ufnprefix ) + 1 )) + if ( (pbuf = (char *) LDAP_MALLOC( strlen( ld->ld_ufnprefix ) + 1 )) == NULL ) { ldap_value_free( ufncomp ); ldap_value_free( prefixcomp ); @@ -292,7 +295,7 @@ ldap_ufn_search_ct( LDAP *ld, char *ufn, char **attrs, int attrsonly, ldap_value_free( ufncomp ); ldap_value_free( prefixcomp ); - free( pbuf ); + LDAP_FREE( pbuf ); return( err ); } @@ -302,7 +305,8 @@ ldap_ufn_search_ct( LDAP *ld, char *ufn, char **attrs, int attrsonly, * ldapfilter.conf tags. */ int -ldap_ufn_search_c( LDAP *ld, char *ufn, char **attrs, int attrsonly, +ldap_ufn_search_c( + LDAP *ld, LDAP_CONST char *ufn, char **attrs, int attrsonly, LDAPMessage **res, cancelptype cancelproc, void *cancelparm ) { return( ldap_ufn_search_ct( ld, ufn, attrs, attrsonly, res, cancelproc, @@ -313,7 +317,8 @@ ldap_ufn_search_c( LDAP *ld, char *ufn, char **attrs, int attrsonly, * same as ldap_ufn_search_c without the cancel function */ int -ldap_ufn_search_s( LDAP *ld, char *ufn, char **attrs, int attrsonly, +ldap_ufn_search_s( + LDAP *ld, LDAP_CONST char *ufn, char **attrs, int attrsonly, LDAPMessage **res ) { struct timeval tv; @@ -427,7 +432,7 @@ ldap_ufn_expand( LDAP *ld, cancelptype cancelproc, void *cancelparm, do { *err = ldap_result( ld, msgid, 1, &tv, &tmpres ); - if ( *err == 0 && cancelproc != NULL && + if ( *err == 0 && cancelproc != 0 && (*cancelproc)( cancelparm ) != 0 ) { ldap_abandon( ld, msgid ); *err = LDAP_USER_CANCELLED; @@ -459,7 +464,7 @@ ldap_ufn_expand( LDAP *ld, cancelptype cancelproc, void *cancelparm, */ LDAPFiltDesc * -ldap_ufn_setfilter( LDAP *ld, char *fname ) +ldap_ufn_setfilter( LDAP *ld, LDAP_CONST char *fname ) { if ( ld->ld_filtd != NULL ) ldap_getfilter_free( ld->ld_filtd ); @@ -468,12 +473,12 @@ ldap_ufn_setfilter( LDAP *ld, char *fname ) } void -ldap_ufn_setprefix( LDAP *ld, char *prefix ) +ldap_ufn_setprefix( LDAP *ld, LDAP_CONST char *prefix ) { if ( ld->ld_ufnprefix != NULL ) - free( ld->ld_ufnprefix ); + LDAP_FREE( ld->ld_ufnprefix ); - ld->ld_ufnprefix = strdup( prefix ); + ld->ld_ufnprefix = LDAP_STRDUP( prefix ); } int