mirror of
https://github.com/curl/curl.git
synced 2026-08-24 11:33:33 +03:00
Moved strdup replacement from src/main.c into src/strdup.c so it's available
in libcurl as well, if necessary.
This commit is contained in:
parent
012d75442a
commit
c6fc5a1a26
7 changed files with 105 additions and 31 deletions
|
|
@ -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
|
||||
|
|
|
|||
25
src/main.c
25
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;
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue