]> git.sur5r.net Git - openldap/commitdiff
add ldap_strdup and eliminate strdup in libldap
authorHallvard Furuseth <hallvard@openldap.org>
Thu, 19 Nov 1998 06:18:23 +0000 (06:18 +0000)
committerHallvard Furuseth <hallvard@openldap.org>
Thu, 19 Nov 1998 06:18:23 +0000 (06:18 +0000)
18 files changed:
libraries/libldap/Makefile.in
libraries/libldap/cldap.c
libraries/libldap/disptmpl.c
libraries/libldap/dsparse.c
libraries/libldap/friendly.c
libraries/libldap/getdn.c
libraries/libldap/getdxbyname.c
libraries/libldap/getfilter.c
libraries/libldap/init.c
libraries/libldap/ldap-int.h
libraries/libldap/open.c
libraries/libldap/options.c
libraries/libldap/os-ip.c
libraries/libldap/request.c
libraries/libldap/search.c
libraries/libldap/test.c
libraries/libldap/ufn.c
libraries/libldap/url.c

index 9580ac1db76e42b53a534eec8f6c9d4d95da5e92..82437c0806b65494ca09532f8179f8bcb04dc918 100644 (file)
@@ -14,14 +14,14 @@ SRCS        = bind.c open.c result.c error.c compare.c search.c \
        free.c disptmpl.c srchpref.c dsparse.c tmplout.c sort.c \
        getdn.c getentry.c getattr.c getvalues.c addentry.c \
        request.c getdxbyname.c os-ip.c url.c charset.c \
-       init.c options.c
+       init.c options.c strdup.c
 OBJS   = bind.o open.o result.o error.o compare.o search.o \
        modify.o add.o modrdn.o delete.o abandon.o ufn.o cache.o \
        getfilter.o sbind.o kbind.o unbind.o friendly.o cldap.o \
        free.o disptmpl.o srchpref.o dsparse.o tmplout.o sort.o \
        getdn.o getentry.o getattr.o getvalues.o addentry.o \
        request.o getdxbyname.o os-ip.o url.o charset.o \
-       init.o options.o
+       init.o options.o strdup.o
 
 LIBS = -L$(LDAP_LIBDIR) -lldap -llber $(AC_LIBS)
 LIBLBER = ../liblber/liblber.a
index 8af96273070a2e6e73f9a67068683a24cd69784a..5ae4c6a66350a2fe51235658ccf385b0dd543485 100644 (file)
@@ -134,7 +134,7 @@ cldap_open( char *host, int port )
            }
 
            if ( ld->ld_host == NULL ) {
-                   ld->ld_host = strdup( host );
+                   ld->ld_host = ldap_strdup( host );
            }
        }
 
index 54b493e7c7cb51891553ae98dd06cbe3faaeca11..35e61d11b2af318903f9cf34c5440295022954af 100644 (file)
@@ -384,7 +384,7 @@ ldap_tmplattrs( struct ldap_disptmpl *tmpl, char **includeattrs,
        for ( i = 0; !memerr && includeattrs[ i ] != NULL; ++i ) {
            if (( attrs = (char **)realloc( attrs, ( attrcnt + 2 ) *
                    sizeof( char * ))) == NULL || ( attrs[ attrcnt++ ] =
-                   strdup( includeattrs[ i ] )) == NULL ) {
+                   ldap_strdup( includeattrs[ i ] )) == NULL ) {
                memerr = 1;
            } else {
                attrs[ attrcnt ] = NULL;
@@ -411,7 +411,7 @@ ldap_tmplattrs( struct ldap_disptmpl *tmpl, char **includeattrs,
            if ( ticolp->ti_attrname != NULL ) {
                if (( attrs = (char **)realloc( attrs, ( attrcnt + 2 ) *
                        sizeof( char * ))) == NULL || ( attrs[ attrcnt++ ] =
-                       strdup( ticolp->ti_attrname )) == NULL ) {
+                       ldap_strdup( ticolp->ti_attrname )) == NULL ) {
                    memerr = 1;
                } else {
                    attrs[ attrcnt ] = NULL;
index 394e61ec34dbfc214bcf300774a33f4c90242e20..836e2c9007dcffa675e36a22c0d5bdb461aca9e7 100644 (file)
@@ -188,7 +188,7 @@ next_token( char **sp )
        return( NULL );
     }
 
-    return( strdup( tokstart ));
+    return( ldap_strdup( tokstart ));
 }
 
 
index 12896aad8370b9d75aa497100f91de6ad0a6a313..278c729cee01b27570c0fd60f9a2dd21375b3c8b 100644 (file)
@@ -83,8 +83,8 @@ ldap_friendly_name( char *filename, char *uname, FriendlyMap **map )
                                }
                        }
 
-                       (*map)[i].f_unfriendly = strdup( buf );
-                       (*map)[i].f_friendly strdup( s );
+                       (*map)[i].f_unfriendly = ldap_strdup( buf );
+                       (*map)[i].f_friendly   = ldap_strdup( s );
                        i++;
                }
 
index 70c09c7933c4c534a50a634345727a604ceb2761..1142c883643f4e0959864d0dd516862f40bfae37 100644 (file)
@@ -54,9 +54,9 @@ ldap_dn2ufn( char *dn )
        Debug( LDAP_DEBUG_TRACE, "ldap_dn2ufn\n", 0, 0, 0 );
 
        if ( ldap_is_dns_dn( dn ) || ( p = strchr( dn, '=' )) == NULL )
-               return( strdup( dn ));
+               return( ldap_strdup( dn ) );
 
-       ufn = strdup( ++p );
+       ufn = ldap_strdup( ++p );
 
 #define INQUOTE                1
 #define OUTQUOTE       2
@@ -139,7 +139,7 @@ ldap_explode_dns( char *dn )
                                return( NULL );
                        }
                }
-               rdns[ncomps++] = strdup( s );
+               rdns[ncomps++] = ldap_strdup( s );
        }
        rdns[ncomps] = NULL;
 
index c9ec19f9acf4d59d2519a1d0016ba9a03d4a4088..c31d926374b09d9dea095cdb43e01f92cd2d7691 100644 (file)
@@ -45,7 +45,7 @@ ldap_getdxbyname( char *domain )
         * punt:  return list conisting of the original domain name only
         */
        if (( dxs = (char **)malloc( 2 * sizeof( char * ))) == NULL ||
-               ( dxs[ 0 ] = strdup( domain )) == NULL ) {
+               ( dxs[ 0 ] = ldap_strdup( domain )) == NULL ) {
            if ( dxs != NULL ) {
                free( dxs );
            }
index b6272659c4366a982b99a2817c87b19361b03375..e466adc243cd70df73960a0ae09591ace8992777 100644 (file)
@@ -115,7 +115,7 @@ ldap_init_getfilter_buf( char *buf, long buflen )
                ldap_getfilter_free( lfdp );
                return( NULL );
            }
-           nextflp->lfl_tag = strdup( tag );
+           nextflp->lfl_tag = ldap_strdup( tag );
            nextflp->lfl_pattern = tok[ 0 ];
            if ( (rc = regcomp( &re, nextflp->lfl_pattern, 0 )) != 0 ) {
 #ifdef LDAP_LIBUI
@@ -210,12 +210,12 @@ ldap_setfilteraffixes( LDAPFiltDesc *lfdp, char *prefix, char *suffix )
     if ( lfdp->lfd_filtprefix != NULL ) {
        free( lfdp->lfd_filtprefix );
     }
-    lfdp->lfd_filtprefix = ( prefix == NULL ) ? NULL : strdup( prefix );
+    lfdp->lfd_filtprefix = ( prefix == NULL ) ? NULL : ldap_strdup( prefix );
 
     if ( lfdp->lfd_filtsuffix != NULL ) {
        free( lfdp->lfd_filtsuffix );
     }
-    lfdp->lfd_filtsuffix = ( suffix == NULL ) ? NULL : strdup( suffix );
+    lfdp->lfd_filtsuffix = ( suffix == NULL ) ? NULL : ldap_strdup( suffix );
 }
 
 
@@ -264,7 +264,7 @@ ldap_getfirstfilter( LDAPFiltDesc *lfdp, char *tagpat, char *value )
        return( NULL );
     }
 
-    if (( lfdp->lfd_curvalcopy = strdup( value )) == NULL ) {
+    if (( lfdp->lfd_curvalcopy = ldap_strdup( value )) == NULL ) {
        return( NULL );
     }
 
index 57f6d2423f0fc3a7edff2be57b91137c12049d66..3801899ceba76c077f8fbd809be377f4f4b09558 100644 (file)
@@ -156,7 +156,7 @@ static void openldap_ldap_init_w_conf(const char *file)
 
                        case ATTR_STRING:
                                if (* (char**) p != NULL) free(* (char**) p);
-                               * (char**) p = strdup(opt);
+                               * (char**) p = ldap_strdup(opt);
                                break;
                        }
                }
@@ -251,7 +251,7 @@ static void openldap_ldap_init_w_env(const char *prefix)
                        if (*value == '\0') {
                                * (char**) p = NULL;
                        } else {
-                               * (char**) p = strdup(value);
+                               * (char**) p = ldap_strdup(value);
                        }
                        break;
                }
@@ -269,7 +269,7 @@ void openldap_ldap_initialize( void )
        gopts.ldo_timelimit = LDAP_NO_LIMIT;
        gopts.ldo_sizelimit = LDAP_NO_LIMIT;
 
-       gopts.ldo_defhost = strdup("localhost");
+       gopts.ldo_defhost = ldap_strdup("localhost");
        gopts.ldo_defport = LDAP_PORT;
 
        gopts.ldo_refhoplimit = LDAP_DEFAULT_REFHOPLIMIT;
index bd3335c1533e15ac4313116c08206dcf76782a80..09628931fc7cbc8a1f1b265c122208888313c896 100644 (file)
@@ -139,7 +139,6 @@ struct ldap {
 #endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS */
 };
 
-
 /*
  * in init.c
  */
@@ -240,6 +239,15 @@ LDAP_F int cldap_getmsg    ( LDAP *ld, struct timeval *timeout, BerElement *ber );
 BerElement *ldap_build_search_req( LDAP *ld, char *base, int scope,
        char *filter, char **attrs, int attrsonly );
 
+/*
+ * in strdup.c
+ */
+#ifdef HAVE_STRDUP
+#define      ldap_strdup(s)    strdup(s)
+extern char *strdup();
+#else
+extern char *ldap_strdup LDAP_P(( const char * ));
+#endif
 
 /*
  * in unbind.c
index ff88c634638995dade20d91634f61a77315dcaaf..2aa8eafcb259dc01894da1ca5b3b0b1481af666d 100644 (file)
@@ -59,7 +59,7 @@ ldap_open( char *host, int port )
 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
        if (( srv = (LDAPServer *)calloc( 1, sizeof( LDAPServer ))) ==
            NULL || ( ld->ld_defhost != NULL && ( srv->lsrv_host =
-           strdup( ld->ld_defhost )) == NULL )) {
+           ldap_strdup( ld->ld_defhost )) == NULL )) {
                ldap_ld_free( ld, 0 );
                return( NULL );
        }
@@ -158,9 +158,9 @@ ldap_init( char *defhost, int defport )
        ld->ld_options.ldo_defhost = NULL;
 
        if ( defhost != NULL ) {
-               ld->ld_options.ldo_defhost = strdup( defhost );
+               ld->ld_options.ldo_defhost = ldap_strdup( defhost );
        } else {
-               ld->ld_options.ldo_defhost = strdup(
+               ld->ld_options.ldo_defhost = ldap_strdup(
                        openldap_ldap_global_options.ldo_defhost);
        }
 
index 182e7df67d0a45a9e45eeb42525e58a584557147..07374e228c011b0b2d195c28265331100a363113 100644 (file)
@@ -66,13 +66,14 @@ ldap_get_option(
                                info->ldapai_extensions = malloc(sizeof(features));
 
                                for(i=0; features[i] != NULL; i++) {
-                                       info->ldapai_extensions[i] = strdup(features[i]);
+                                       info->ldapai_extensions[i] =
+                                               ldap_strdup(features[i]);
                                }
 
                                info->ldapai_extensions[i] = NULL;
                        }
 
-                       info->ldapai_vendor_name = strdup(LDAP_VENDOR_NAME);
+                       info->ldapai_vendor_name = ldap_strdup(LDAP_VENDOR_NAME);
                        info->ldapai_vendor_version = LDAP_VENDOR_VERSION;
 
                        return 0;
@@ -131,7 +132,7 @@ ldap_get_option(
                 * we do
                 */
 
-               * (char **) outvalue = strdup(lo->ldo_defhost);
+               * (char **) outvalue = ldap_strdup(lo->ldo_defhost);
                return 0;
 
        case LDAP_OPT_ERROR_NUMBER:
@@ -157,7 +158,7 @@ ldap_get_option(
                if( ld->ld_error == NULL ) {
                        * (char **) outvalue = NULL;
                } else {
-                       * (char **) outvalue = strdup(ld->ld_error);
+                       * (char **) outvalue = ldap_strdup(ld->ld_error);
                }
                break;
 
@@ -249,7 +250,7 @@ ldap_set_option(
                        }
 
                        if(host != NULL) {
-                               lo->ldo_defhost = strdup(host);
+                               lo->ldo_defhost = ldap_strdup(host);
                                return 0;
                        }
 
@@ -258,14 +259,14 @@ ldap_set_option(
                                 * must want global default returned
                                 * to initial condition.
                                 */
-                               lo->ldo_defhost = strdup("localhost");
+                               lo->ldo_defhost = ldap_strdup("localhost");
 
                        } else {
                                /*
                                 * must want the session default
                                 *   updated to the current global default
                                 */
-                               lo->ldo_defhost = strdup(
+                               lo->ldo_defhost = ldap_strdup(
                                        openldap_ldap_global_options.ldo_defhost);
                        }
                } return 0;
index b56809cda4bbfc70db365dc80da78e12f291879e..1b22917a46e95c5f996beb6a58801bbf0b4a3dc2 100644 (file)
@@ -179,7 +179,7 @@ ldap_host_connected_to( Sockbuf *sb )
        if (( hp = gethostbyaddr( (char *) &sin.sin_addr,
            sizeof( sin.sin_addr ), AF_INET )) != NULL ) {
                if ( hp->h_name != NULL ) {
-                       return( strdup( hp->h_name ));
+                       return( ldap_strdup( hp->h_name ));
                }
        }
 
index f9b724ef8a2b76bea686ab86d5fd14b1cc4160d0..821a29aa7498e1d4626ef8f608b4283d416f9366 100644 (file)
@@ -685,7 +685,7 @@ ldap_chase_referrals( LDAP *ld, LDAPRequest *lr, char **errstrp, int *hadrefp )
                                return( -1 );
                        }
 
-                       if (( srv->lsrv_host = strdup( tmpref )) == NULL ) {
+                       if (( srv->lsrv_host = ldap_strdup( tmpref )) == NULL ) {
                                free( (char *)srv );
                                ber_free( ber, 1 );
                                ld->ld_errno = LDAP_NO_MEMORY;
@@ -919,9 +919,9 @@ dn2servers( LDAP *ld, char *dn )    /* dn can also be a domain.... */
                        prevsrv = srv;
                        
                        /* copy in info. */
-                       if (( srv->lsrv_host = strdup( host )) == NULL ||
+                       if (( srv->lsrv_host = ldap_strdup( host )) == NULL ||
                            ( server_dn != NULL && ( srv->lsrv_dn =
-                           strdup( server_dn )) == NULL )) {
+                           ldap_strdup( server_dn )) == NULL )) {
                                free_servers( srvlist );
                                srvlist = NULL;
                                break;          /* exit loop & return */
index 2a45f1ce6d6fec74ff93db8a3cb369be285de35a..c6be97c4d761cf84037089b301d7c6e29725139f 100644 (file)
@@ -135,7 +135,7 @@ ldap_build_search_req( LDAP *ld, char *base, int scope, char *filter,
                return( NULLBER );
        }
 
-       filter = strdup( filter );
+       filter = ldap_strdup( filter );
        err = put_filter( ber, filter );
        free( filter );
 
@@ -317,7 +317,7 @@ put_filter( BerElement *ber, char *str )
                                        return( -1 );
 
                                *next = '\0';
-                               tmp = strdup( str );
+                               tmp = ldap_strdup( str );
                                if ( gotescape ) {
                                        escape = 0;
                                        for ( s = d = tmp; *s; s++ ) {
@@ -359,7 +359,7 @@ put_filter( BerElement *ber, char *str )
                        Debug( LDAP_DEBUG_TRACE, "put_filter: default\n", 0, 0,
                            0 );
                        next = strchr( str, '\0' );
-                       tmp = strdup( str );
+                       tmp = ldap_strdup( str );
                        if ( strchr( tmp, '\\' ) != NULL ) {
                                escape = 0;
                                for ( s = d = tmp; *s; s++ ) {
index 66e86efb85d0f159be6b70819956226299f71297..ad50e483ca3b1a19a7a8b47bfef8d84f597e4a3f 100644 (file)
@@ -78,7 +78,7 @@ get_list( char *prompt )
                        result = (char **) realloc( result,
                            sizeof(char *) * (num + 1) );
 
-               result[num++] = (char *) strdup( buf );
+               result[num++] = (char *) ldap_strdup( buf );
        }
        if ( result == (char **) 0 )
                return( NULL );
@@ -172,7 +172,7 @@ get_modlist( char *prompt1, char *prompt2, char *prompt3 )
                getline( buf, sizeof(buf), stdin, prompt2 );
                if ( buf[0] == '\0' )
                        break;
-               tmp.mod_type = strdup( buf );
+               tmp.mod_type = ldap_strdup( buf );
 
                tmp.mod_values = get_list( prompt3 );
 
@@ -316,12 +316,12 @@ main( int argc, char **argv )
                        break;
 
                case 't':       /* copy ber's to given file */
-                       copyfname = strdup( optarg );
+                       copyfname = ldap_strdup( optarg );
                        copyoptions = LBER_TO_FILE;
                        break;
 
                case 'T':       /* only output ber's to given file */
-                       copyfname = strdup( optarg );
+                       copyfname = ldap_strdup( optarg );
                        copyoptions = (LBER_TO_FILE | LBER_TO_FILE_ONLY);
                        break;
 
index 6a2ef9ec8360c02aa275c2a908c3c8e9dfb28390..d56dc5799dbead14e344b36c1ef50ecd45fc06e6 100644 (file)
@@ -128,7 +128,7 @@ ldap_ufn_search_ctx( LDAP *ld, char **ufncomp, int ncomp, char *prefix,
                                    * 2 )) == NULL ) {
                                        return( ld->ld_errno = LDAP_NO_MEMORY );
                                }
-                               dns[0] = strdup( prefix );
+                               dns[0] = ldap_strdup( prefix );
                                dns[1] = NULL;
                        } else {
                                dns = NULL;
@@ -472,7 +472,7 @@ ldap_ufn_setprefix( LDAP *ld, char *prefix )
        if ( ld->ld_ufnprefix != NULL )
                free( ld->ld_ufnprefix );
 
-       ld->ld_ufnprefix = strdup( prefix );
+       ld->ld_ufnprefix = ldap_strdup( prefix );
 }
 
 int
index 4de1a914e0562e47e09f8e0308f7f6e853030d99..bc6726164fe63cd7abd28f52b2aecff7ad1c9a18 100644 (file)
@@ -113,7 +113,7 @@ ldap_url_parse( char *url, LDAPURLDesc **ludpp )
        }
 
        /* make working copy of the remainder of the URL */
-       if (( url = strdup( url )) == NULL ) {
+       if (( url = ldap_strdup( url )) == NULL ) {
                ldap_free_urldesc( ludp );
                return( LDAP_URL_ERR_MEM );
        }
@@ -263,7 +263,7 @@ ldap_url_search( LDAP *ld, char *url, int attrsonly )
        if ( ludp->lud_host != NULL || ludp->lud_port != 0 ) {
 #ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_REFERRALS
                if (( srv = (LDAPServer *)calloc( 1, sizeof( LDAPServer )))
-                   == NULL || ( srv->lsrv_host = strdup( ludp->lud_host ==
+                   == NULL || ( srv->lsrv_host = ldap_strdup( ludp->lud_host ==
                    NULL ? ld->ld_defhost : ludp->lud_host )) == NULL ) {
                        if ( srv != NULL ) {
                                free( srv );