+/* $OpenLDAP$ */
/*
- * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
/* Portions
#include "portable.h"
#include <stdio.h>
-#include <stdlib.h>
-#include <ac/ctype.h>
+#include <ac/stdlib.h>
+
#include <ac/errno.h>
#include <ac/regex.h>
#include <ac/string.h>
LDAPFiltDesc *
-ldap_init_getfilter_buf( char *buf, long buflen )
+ldap_init_getfilter_buf( char *buf, ber_len_t buflen )
{
LDAPFiltDesc *lfdp;
LDAPFiltList *flp, *nextflp;
fip = NULL;
tag = NULL;
- while ( buflen > 0 && ( tokcnt = next_line_tokens( &buf, &buflen, &tok ))
+ while ( buflen > 0 && ( tokcnt = ldap_int_next_line_tokens( &buf, &buflen, &tok ))
> 0 ) {
switch( tokcnt ) {
nextflp->lfl_pattern, error );
errno = EINVAL;
#endif /* LDAP_LIBUI */
- free_strarray( tok );
+ LDAP_VFREE( tok );
return( NULL );
}
regfree(&re);
if (( nextfip = (LDAPFiltInfo *)LDAP_CALLOC( 1,
sizeof( LDAPFiltInfo ))) == NULL ) {
ldap_getfilter_free( lfdp );
- free_strarray( tok );
+ LDAP_VFREE( tok );
return( NULL );
}
if ( fip == NULL ) { /* first one */
} else if ( strcasecmp( tok[ 2 ], "base" ) == 0 ) {
nextfip->lfi_scope = LDAP_SCOPE_BASE;
} else {
- free_strarray( tok );
+ LDAP_VFREE( tok );
ldap_getfilter_free( lfdp );
errno = EINVAL;
return( NULL );
break;
default:
- free_strarray( tok );
+ LDAP_VFREE( tok );
ldap_getfilter_free( lfdp );
errno = EINVAL;
return( NULL );
for ( flp = lfdp->lfd_filtlist; flp != NULL; flp = flp->lfl_next ) {
/* compile tagpat, continue if we fail */
- if (regcomp(&re, tagpat, 0) != 0)
+ if (regcomp(&re, tagpat, REG_EXTENDED|REG_NOSUB) != 0)
continue;
- /* match tagpatern and tag, continue if we fail */
+ /* match tagpattern and tag, continue if we fail */
rc = regexec(&re, flp->lfl_tag, 0, NULL, 0);
regfree(&re);
if (rc != 0)
continue;
/* compile flp->ifl_pattern, continue if we fail */
- if (regcomp(&re, flp->lfl_pattern, 0) != 0)
+ if (regcomp(&re, flp->lfl_pattern, REG_EXTENDED|REG_NOSUB) != 0)
continue;
/* match ifl_pattern and lfd_curval, continue if we fail */
void
ldap_build_filter(
char *filtbuf,
- unsigned long buflen,
+ ber_len_t buflen,
LDAP_CONST char *pattern,
LDAP_CONST char *prefix,
LDAP_CONST char *suffix,
if ( *p == '%' ) {
++p;
if ( *p == 'v' ) {
- if ( isdigit( (unsigned char) p[1] )) {
+ if ( LDAP_DIGIT( (unsigned char) p[1] )) {
++p;
wordnum = *p - '1';
if ( *(p+1) == '-' ) {
++p;
- if ( isdigit( (unsigned char) p[1] )) {
+ if ( LDAP_DIGIT( (unsigned char) p[1] )) {
++p;
endwordnum = *p - '1'; /* e.g., "%v2-4" */
if ( endwordnum > wordcount - 1 ) {
*f++ = *p;
}
- if ( (unsigned long) (f - filtbuf) > buflen ) {
+ if ( (size_t) (f - filtbuf) > buflen ) {
/* sanity check */
--f;
break;
}
}
- if ( suffix != NULL && (
- (unsigned long) ( f - filtbuf ) < buflen ) )
+ if ( suffix != NULL && ( (size_t) (f - filtbuf) < buflen ) )
{
strcpy( f, suffix );
} else {