From c6fc5a1a269796a47ac265751e0baafcf436391a Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Tue, 11 Jul 2006 17:02:06 +0000 Subject: Moved strdup replacement from src/main.c into src/strdup.c so it's available in libcurl as well, if necessary. --- src/Makefile.inc | 3 ++- src/main.c | 25 +++---------------------- src/setup.h | 5 +++++ 3 files changed, 10 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/Makefile.inc b/src/Makefile.inc index 4f2aff9a2..b6583e72c 100644 --- a/src/Makefile.inc +++ b/src/Makefile.inc @@ -2,7 +2,8 @@ # libcurl has sources that provide functions named curlx_* that aren't part of # the official API, but we re-use the code here to avoid duplication. -CURLX_ONES = $(top_srcdir)/lib/strtoofft.c $(top_srcdir)/lib/timeval.c +CURLX_ONES = $(top_srcdir)/lib/strtoofft.c $(top_srcdir)/lib/timeval.c \ + $(top_srcdir)/lib/strdup.c CURL_SOURCES = main.c hugehelp.c urlglob.c writeout.c writeenv.c \ getpass.c homedir.c diff --git a/src/main.c b/src/main.c index 3eb11eec8..5df84d9c7 100644 --- a/src/main.c +++ b/src/main.c @@ -183,25 +183,6 @@ typedef enum { /* Send authentication (user+password) when following * locations, even when hostname changed */ -#ifndef HAVE_STRDUP -/* Ultrix doesn't have strdup(), so make a quick clone: */ -char *strdup(char *str) -{ - int len; - char *newstr; - - len = strlen(str); - newstr = (char *) malloc((len+1)*sizeof(char)); - if (!newstr) - return (char *)NULL; - - strcpy(newstr,str); - - return newstr; - -} -#endif - #ifdef WIN32 #include #define F_OK 0 @@ -1271,11 +1252,11 @@ static ParameterError add2list(struct curl_slist **list, static int ftpfilemethod(struct Configurable *config, char *str) { - if(strequal("singlecwd", str)) + if(curlx_strequal("singlecwd", str)) return CURLFTPMETHOD_SINGLECWD; - if(strequal("nocwd", str)) + if(curlx_strequal("nocwd", str)) return CURLFTPMETHOD_NOCWD; - if(strequal("multicwd", str)) + if(curlx_strequal("multicwd", str)) return CURLFTPMETHOD_MULTICWD; warnf(config, "unrecognized ftp file method '%s', using default\n", str); return CURLFTPMETHOD_MULTICWD; diff --git a/src/setup.h b/src/setup.h index d3814fef4..e911922c9 100644 --- a/src/setup.h +++ b/src/setup.h @@ -177,4 +177,9 @@ int fileno( FILE *stream); #define UNPRINTABLE_CHAR '.' #endif +#ifndef HAVE_STRDUP +#include "strdup.h" +#define strdup(ptr) curlx_strdup(ptr) +#endif + #endif /* __SRC_CURL_SETUP_H */ -- cgit v1.2.3