]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/getfilter.c
rename ldap_pvt_init_utils() to ldap_int_utils_init() and provide
[openldap] / libraries / libldap / getfilter.c
index a780851688e25ed02f6fa31b4df7c9c12470996c..94f73c3c77d804c8014b9678cfa21c507b15b9ce 100644 (file)
 
 #include "ldap-int.h"
 
-static int break_into_words LDAP_P(( char *str, char *delims, char ***wordsp ));
+static int break_into_words LDAP_P((
+       /* LDAP_CONST */ char *str,
+       LDAP_CONST char *delims,
+       char ***wordsp ));
 
 #define FILT_MAX_LINE_LEN      1024
 
 LDAPFiltDesc *
-ldap_init_getfilter( char *fname )
+ldap_init_getfilter( LDAP_CONST char *fname )
 {
     FILE               *fp;
     char               *buf;
@@ -115,14 +118,14 @@ ldap_init_getfilter_buf( char *buf, long buflen )
                ldap_getfilter_free( lfdp );
                return( NULL );
            }
-           nextflp->lfl_tag = ldap_strdup( tag );
+           nextflp->lfl_tag = strdup( tag );
            nextflp->lfl_pattern = tok[ 0 ];
            if ( (rc = regcomp( &re, nextflp->lfl_pattern, 0 )) != 0 ) {
 #ifdef LDAP_LIBUI
                char error[512];
                regerror(rc, &re, error, sizeof(error));
                ldap_getfilter_free( lfdp );
-               fprintf( stderr, "bad regular expresssion %s, %s\n",
+               fprintf( stderr, "bad regular expression %s, %s\n",
                        nextflp->lfl_pattern, error );
                errno = EINVAL;
 #endif /* LDAP_LIBUI */
@@ -205,22 +208,25 @@ ldap_init_getfilter_buf( char *buf, long buflen )
 
 
 void
-ldap_setfilteraffixes( LDAPFiltDesc *lfdp, char *prefix, char *suffix )
+ldap_setfilteraffixes( LDAPFiltDesc *lfdp, LDAP_CONST char *prefix, LDAP_CONST char *suffix )
 {
     if ( lfdp->lfd_filtprefix != NULL ) {
        free( lfdp->lfd_filtprefix );
     }
-    lfdp->lfd_filtprefix = ( prefix == NULL ) ? NULL : ldap_strdup( prefix );
+    lfdp->lfd_filtprefix = ( prefix == NULL ) ? NULL : strdup( prefix );
 
     if ( lfdp->lfd_filtsuffix != NULL ) {
        free( lfdp->lfd_filtsuffix );
     }
-    lfdp->lfd_filtsuffix = ( suffix == NULL ) ? NULL : ldap_strdup( suffix );
+    lfdp->lfd_filtsuffix = ( suffix == NULL ) ? NULL : strdup( suffix );
 }
 
 
 LDAPFiltInfo *
-ldap_getfirstfilter( LDAPFiltDesc *lfdp, char *tagpat, char *value )
+ldap_getfirstfilter(
+       LDAPFiltDesc *lfdp,
+       /* LDAP_CONST */ char *tagpat,
+       /* LDAP_CONST */ char *value )
 {
     LDAPFiltList       *flp;
        int                             rc;
@@ -264,7 +270,7 @@ ldap_getfirstfilter( LDAPFiltDesc *lfdp, char *tagpat, char *value )
        return( NULL );
     }
 
-    if (( lfdp->lfd_curvalcopy = ldap_strdup( value )) == NULL ) {
+    if (( lfdp->lfd_curvalcopy = strdup( value )) == NULL ) {
        return( NULL );
     }
 
@@ -305,10 +311,18 @@ ldap_getnextfilter( LDAPFiltDesc *lfdp )
 
 
 void
-ldap_build_filter( char *filtbuf, unsigned long buflen, char *pattern,
-       char *prefix, char *suffix, char *attr, char *value, char **valwords )
+ldap_build_filter(
+       char *filtbuf,
+       unsigned long buflen,
+       LDAP_CONST char *pattern,
+       LDAP_CONST char *prefix,
+       LDAP_CONST char *suffix,
+       LDAP_CONST char *attr,
+       LDAP_CONST char *value,
+       char **valwords )
 {
-       char    *p, *f;
+       const char *p;
+       char *f;
        size_t  slen;
        int     i, wordcount, wordnum, endwordnum;
        
@@ -331,12 +345,12 @@ ldap_build_filter( char *filtbuf, unsigned long buflen, char *pattern,
            if ( *p == '%' ) {
                ++p;
                if ( *p == 'v' ) {
-                   if ( isdigit( *(p+1))) {
+                   if ( isdigit( (unsigned char) p[1] )) {
                        ++p;
                        wordnum = *p - '1';
                        if ( *(p+1) == '-' ) {
                            ++p;
-                           if ( isdigit( *(p+1))) {
+                           if ( isdigit( (unsigned char) p[1] )) {
                                ++p;
                                endwordnum = *p - '1';  /* e.g., "%v2-4" */
                                if ( endwordnum > wordcount - 1 ) {
@@ -401,7 +415,7 @@ ldap_build_filter( char *filtbuf, unsigned long buflen, char *pattern,
 
 
 static int
-break_into_words( char *str, char *delims, char ***wordsp )
+break_into_words( /* LDAP_CONST */ char *str, LDAP_CONST char *delims, char ***wordsp )
 {
     char       *word, **words;
     int                count;
@@ -413,7 +427,7 @@ break_into_words( char *str, char *delims, char ***wordsp )
     count = 0;
     words[ count ] = NULL;
 
-    word = ldap_int_strtok( str, delims, &tok_r );
+    word = ldap_pvt_strtok( str, delims, &tok_r );
     while ( word != NULL ) {
        if (( words = (char **)realloc( words,
                ( count + 2 ) * sizeof( char * ))) == NULL ) {
@@ -422,7 +436,7 @@ break_into_words( char *str, char *delims, char ***wordsp )
 
        words[ count ] = word;
        words[ ++count ] = NULL;
-       word = ldap_int_strtok( NULL, delims, &tok_r );
+       word = ldap_pvt_strtok( NULL, delims, &tok_r );
     }
        
     *wordsp = words;