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 \
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)
tool_cfgabler.obj \\r
tool_convertr.obj \\r
tool_mfilesr.obj \\r
+ tool_myfuncr.obj \\r
urlglobr.obj \\r
writeoutr.obj \\r
xattrr.obj \\r
tool_cfgabled.obj \\r
tool_convertd.obj \\r
tool_mfilesd.obj \\r
+ tool_myfuncd.obj \\r
urlglobd.obj \\r
writeoutd.obj \\r
xattrd.obj \\r
$(CCR) $(CFLAGS) /Fo"$@" tool_convert.c\r
tool_mfilesr.obj: tool_mfiles.c\r
$(CCR) $(CFLAGS) /Fo"$@" tool_mfiles.c\r
+tool_myfuncr.obj: tool_myfunc.c\r
+ $(CCR) $(CFLAGS) /Fo"$@" tool_myfunc.c\r
xattrr.obj: xattr.c\r
$(CCR) $(CFLAGS) /Fo"$@" xattr.c\r
mainr.obj: main.c\r
$(CCD) $(CFLAGS) /Fo"$@" tool_convert.c\r
tool_mfilesd.obj: tool_mfiles.c\r
$(CCD) $(CFLAGS) /Fo"$@" tool_mfiles.c\r
+tool_myfuncd.obj: tool_myfunc.c\r
+ $(CCD) $(CFLAGS) /Fo"$@" tool_myfunc.c\r
xattrd.obj: xattr.c\r
$(CCD) $(CFLAGS) /Fo"$@" xattr.c\r
maind.obj: main.c\r
#include "tool_convert.h"
#include "tool_mfiles.h"
#include "tool_cfgable.h"
+#include "tool_myfunc.h"
#ifdef USE_MANUAL
# include "hugehelp.h"
#endif
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;
curl_off_t uploadfilesize; /* -1 means unknown */
bool stillflags=TRUE;
- bool allocuseragent=FALSE;
-
char *httpgetfields=NULL;
CURL *curl;
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:
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);
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);
/* config->outs not handled */
}
+
--- /dev/null
+/***************************************************************************
+ * _ _ ____ _
+ * 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);
+}
+
--- /dev/null
+#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 */
+
# End Source File\r
# Begin Source File\r
\r
+SOURCE=.\tool_myfunc.c\r
+# End Source File\r
+# Begin Source File\r
+\r
SOURCE=.\urlglob.c\r
# End Source File\r
# Begin Source File\r
# End Source File\r
# Begin Source File\r
\r
+SOURCE=.\tool_myfunc.h\r
+# End Source File\r
+# Begin Source File\r
+\r
SOURCE=.\urlglob.h\r
# End Source File\r
# Begin Source File\r