]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/ufn.c
rename ldap_pvt_init_utils() to ldap_int_utils_init() and provide
[openldap] / libraries / libldap / ufn.c
index 546481b2e49d1bdadbe5a5f91b5a0205645218b9..aad63aa341faff00a9b45a40c9d3494ea143dcdd 100644 (file)
@@ -1,4 +1,8 @@
 /*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/*  Portions
  *  Copyright (c) 1990 Regents of the University of Michigan.
  *  All rights reserved.
  *
@@ -7,10 +11,6 @@
 
 #include "portable.h"
 
-#ifndef lint 
-static char copyright[] = "@(#) Copyright (c) 1993 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
-
 #include <stdio.h>
 #include <ac/string.h>
 #include <ctype.h>
@@ -18,7 +18,6 @@ static char copyright[] = "@(#) Copyright (c) 1993 Regents of the University of
 
 #include <ac/socket.h>
 #include <ac/time.h>
-extern char *strdup (const char *);
 
 #include "ldap-int.h"
 #include "ldapconfig.h"
@@ -47,8 +46,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
@@ -98,7 +97,8 @@ ldap_ufn_search_ctx( LDAP *ld, char **ufncomp, int ncomp, char *prefix,
 
                        if ( (quote = strrchr( ufncomp[ncomp], '"' )) != NULL )
                                *quote = '\0';
-                       strcpy( ufncomp[ncomp], ufncomp[ncomp] + 1 );
+                       SAFEMEMCPY( ufncomp[ncomp], ufncomp[ncomp] + 1,
+                                   strlen( ufncomp[ncomp] + 1 ) + 1 );
                }
                if ( ncomp == 0 )
                        phase = 3;
@@ -217,7 +217,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 )
 {
@@ -302,7 +303,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 +315,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 +430,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 +462,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,7 +471,7 @@ 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 );