aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/Symbian/group/curl.mmp2
-rw-r--r--src/Makefile.inc5
-rw-r--r--src/Makefile.vc66
-rw-r--r--src/main.c21
-rw-r--r--src/tool_cfgable.c5
-rw-r--r--src/tool_myfunc.c48
-rw-r--r--src/tool_myfunc.h29
-rw-r--r--src/vc6curlsrc.dsp8
8 files changed, 105 insertions, 19 deletions
diff --git a/packages/Symbian/group/curl.mmp b/packages/Symbian/group/curl.mmp
index 1c8dd30a2..d5a87b7d9 100644
--- a/packages/Symbian/group/curl.mmp
+++ b/packages/Symbian/group/curl.mmp
@@ -10,7 +10,7 @@ SOURCEPATH ../../../src
SOURCE \
main.c hugehelp.c urlglob.c writeout.c writeenv.c \
getpass.c homedir.c curlutil.c os-specific.c xattr.c \
- tool_cfgable.c tool_convert.c tool_mfiles.c
+ tool_cfgable.c tool_convert.c tool_mfiles.c tool_myfunc.c
SOURCEPATH ../../../lib
SOURCE \
diff --git a/src/Makefile.inc b/src/Makefile.inc
index 5d14ba52c..97d7f0056 100644
--- a/src/Makefile.inc
+++ b/src/Makefile.inc
@@ -16,12 +16,13 @@ CURLX_ONES = $(top_srcdir)/lib/strtoofft.c \
CURL_CFILES = main.c hugehelp.c urlglob.c writeout.c writeenv.c \
getpass.c homedir.c curlutil.c os-specific.c xattr.c \
- tool_cfgable.c tool_convert.c tool_mfiles.c
+ tool_cfgable.c tool_convert.c tool_mfiles.c tool_myfunc.c
CURL_HFILES = hugehelp.h setup.h config-win32.h config-mac.h \
config-riscos.h urlglob.h version.h os-specific.h \
writeout.h writeenv.h getpass.h homedir.h curlutil.h \
- xattr.h tool_cfgable.h tool_convert.h tool_mfiles.h
+ xattr.h tool_cfgable.h tool_convert.h tool_mfiles.h \
+ tool_myfunc.h
curl_SOURCES = $(CURL_CFILES) $(CURLX_ONES) $(CURL_HFILES)
diff --git a/src/Makefile.vc6 b/src/Makefile.vc6
index ca6c4f927..435970f85 100644
--- a/src/Makefile.vc6
+++ b/src/Makefile.vc6
@@ -145,6 +145,7 @@ RELEASE_OBJS= \
tool_cfgabler.obj \
tool_convertr.obj \
tool_mfilesr.obj \
+ tool_myfuncr.obj \
urlglobr.obj \
writeoutr.obj \
xattrr.obj \
@@ -163,6 +164,7 @@ DEBUG_OBJS= \
tool_cfgabled.obj \
tool_convertd.obj \
tool_mfilesd.obj \
+ tool_myfuncd.obj \
urlglobd.obj \
writeoutd.obj \
xattrd.obj \
@@ -314,6 +316,8 @@ tool_convertr.obj: tool_convert.c
$(CCR) $(CFLAGS) /Fo"$@" tool_convert.c
tool_mfilesr.obj: tool_mfiles.c
$(CCR) $(CFLAGS) /Fo"$@" tool_mfiles.c
+tool_myfuncr.obj: tool_myfunc.c
+ $(CCR) $(CFLAGS) /Fo"$@" tool_myfunc.c
xattrr.obj: xattr.c
$(CCR) $(CFLAGS) /Fo"$@" xattr.c
mainr.obj: main.c
@@ -348,6 +352,8 @@ tool_convertd.obj: tool_convert.c
$(CCD) $(CFLAGS) /Fo"$@" tool_convert.c
tool_mfilesd.obj: tool_mfiles.c
$(CCD) $(CFLAGS) /Fo"$@" tool_mfiles.c
+tool_myfuncd.obj: tool_myfunc.c
+ $(CCD) $(CFLAGS) /Fo"$@" tool_myfunc.c
xattrd.obj: xattr.c
$(CCD) $(CFLAGS) /Fo"$@" xattr.c
maind.obj: main.c
diff --git a/src/main.c b/src/main.c
index 5ef8998c3..8ea8f0507 100644
--- a/src/main.c
+++ b/src/main.c
@@ -114,6 +114,7 @@
#include "tool_convert.h"
#include "tool_mfiles.h"
#include "tool_cfgable.h"
+#include "tool_myfunc.h"
#ifdef USE_MANUAL
# include "hugehelp.h"
#endif
@@ -4132,7 +4133,6 @@ static int
operate(struct Configurable *config, int argc, argv_item_t argv[])
{
char errorbuffer[CURL_ERROR_SIZE];
- char useragent[256]; /* buah, we don't want a larger default user agent */
struct ProgressData progressbar;
struct getout *urlnode;
struct getout *nextnode;
@@ -4150,8 +4150,6 @@ operate(struct Configurable *config, int argc, argv_item_t argv[])
curl_off_t uploadfilesize; /* -1 means unknown */
bool stillflags=TRUE;
- bool allocuseragent=FALSE;
-
char *httpgetfields=NULL;
CURL *curl;
@@ -4281,14 +4279,14 @@ operate(struct Configurable *config, int argc, argv_item_t argv[])
helpf(config->errors, "no URL specified!\n");
return CURLE_FAILED_INIT;
}
- if(NULL == config->useragent) {
- /* set non-zero default values: */
- snprintf(useragent, sizeof(useragent),
- CURL_NAME "/" CURL_VERSION " (" OS ") " "%s", curl_version());
- config->useragent= useragent;
+
+ if(!config->useragent)
+ config->useragent = my_useragent();
+ if(!config->useragent) {
+ clean_getout(config);
+ res = CURLE_OUT_OF_MEMORY;
+ goto quit_curl;
}
- else
- allocuseragent = TRUE;
/* On WIN32 we can't set the path to curl-ca-bundle.crt
* at compile time. So we look here for the file in two ways:
@@ -5393,9 +5391,6 @@ operate(struct Configurable *config, int argc, argv_item_t argv[])
if(heads.stream && (heads.stream != stdout))
fclose(heads.stream);
- if(allocuseragent)
- Curl_safefree(config->useragent);
-
if(config->trace_fopened && config->trace_stream)
fclose(config->trace_stream);
diff --git a/src/tool_cfgable.c b/src/tool_cfgable.c
index c2cfac673..2ec57cc32 100644
--- a/src/tool_cfgable.c
+++ b/src/tool_cfgable.c
@@ -38,9 +38,7 @@ void free_config_fields(struct Configurable *config)
Curl_safefree(config->random_file);
Curl_safefree(config->egd_file);
-
- /* config->useragent not handled */
-
+ Curl_safefree(config->useragent);
Curl_safefree(config->cookie);
Curl_safefree(config->cookiejar);
Curl_safefree(config->cookiefile);
@@ -123,3 +121,4 @@ void free_config_fields(struct Configurable *config)
/* config->outs not handled */
}
+
diff --git a/src/tool_myfunc.c b/src/tool_myfunc.c
new file mode 100644
index 000000000..08afc996f
--- /dev/null
+++ b/src/tool_myfunc.c
@@ -0,0 +1,48 @@
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at http://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+#include "setup.h"
+
+#include <curl/curl.h>
+
+#define ENABLE_CURLX_PRINTF
+/* use our own printf() functions */
+#include "curlx.h"
+
+#include "version.h"
+#include "tool_myfunc.h"
+
+#include "memdebug.h" /* keep this as LAST include */
+
+/*
+ * my_useragent: returns allocated string with default user agent
+ */
+
+char *my_useragent(void)
+{
+ char useragent[256]; /* we don't want a larger default user agent */
+
+ snprintf(useragent, sizeof(useragent),
+ CURL_NAME "/" CURL_VERSION " (" OS ") " "%s", curl_version());
+
+ return strdup(useragent);
+}
+
diff --git a/src/tool_myfunc.h b/src/tool_myfunc.h
new file mode 100644
index 000000000..b1d9c6618
--- /dev/null
+++ b/src/tool_myfunc.h
@@ -0,0 +1,29 @@
+#ifndef HEADER_CURL_TOOL_MYFUNC_H
+#define HEADER_CURL_TOOL_MYFUNC_H
+/***************************************************************************
+ * _ _ ____ _
+ * Project ___| | | | _ \| |
+ * / __| | | | |_) | |
+ * | (__| |_| | _ <| |___
+ * \___|\___/|_| \_\_____|
+ *
+ * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at http://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+#include "setup.h"
+
+char *my_useragent(void);
+
+#endif /* HEADER_CURL_TOOL_MYFUNC_H */
+
diff --git a/src/vc6curlsrc.dsp b/src/vc6curlsrc.dsp
index 336bae9c7..9959db8ee 100644
--- a/src/vc6curlsrc.dsp
+++ b/src/vc6curlsrc.dsp
@@ -187,6 +187,10 @@ SOURCE=.\tool_mfiles.c
# End Source File
# Begin Source File
+SOURCE=.\tool_myfunc.c
+# End Source File
+# Begin Source File
+
SOURCE=.\urlglob.c
# End Source File
# Begin Source File
@@ -259,6 +263,10 @@ SOURCE=.\tool_mfiles.h
# End Source File
# Begin Source File
+SOURCE=.\tool_myfunc.h
+# End Source File
+# Begin Source File
+
SOURCE=.\urlglob.h
# End Source File
# Begin Source File