aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDan Fandrich <dan@coneharvesters.com>2006-07-11 17:02:06 +0000
committerDan Fandrich <dan@coneharvesters.com>2006-07-11 17:02:06 +0000
commitc6fc5a1a269796a47ac265751e0baafcf436391a (patch)
tree24d7bf0d6bc52449d3e31fa4f610b66e1b726d8f /src
parent012d75442ab21cbf7c487a3548c6db9151567507 (diff)
Moved strdup replacement from src/main.c into src/strdup.c so it's available
in libcurl as well, if necessary.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.inc3
-rw-r--r--src/main.c25
-rw-r--r--src/setup.h5
3 files changed, 10 insertions, 23 deletions
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 <direct.h>
#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 */