aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorColin Hogben <curl@pythontech.co.uk>2012-02-05 17:44:22 +0000
committerDaniel Stenberg <daniel@haxx.se>2012-02-13 22:36:10 +0100
commit2b26eb98573a1402a8f39603b9fdaa9d04142c07 (patch)
tree2c1bec67d87918d5d05d25744b2408bed3b04e4a /src
parente71ac0c6fad6643ad99b5cf6f1d566dfb79990d2 (diff)
configure: add option disable --libcurl output
Diffstat (limited to 'src')
-rw-r--r--src/tool_easysrc.c5
-rw-r--r--src/tool_easysrc.h5
-rw-r--r--src/tool_getparam.c6
-rw-r--r--src/tool_help.c2
-rw-r--r--src/tool_operate.c8
-rw-r--r--src/tool_setopt.c5
-rw-r--r--src/tool_setopt.h43
7 files changed, 59 insertions, 15 deletions
diff --git a/src/tool_easysrc.c b/src/tool_easysrc.c
index 5c42e808e..ba1e78e0d 100644
--- a/src/tool_easysrc.c
+++ b/src/tool_easysrc.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2012, 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
@@ -23,6 +23,8 @@
#include <curl/curl.h>
+#ifndef CURL_DISABLE_LIBCURL_OPTION
+
#define ENABLE_CURLX_PRINTF
/* use our own printf() functions */
#include "curlx.h"
@@ -110,3 +112,4 @@ void dumpeasysrc(struct Configurable *config)
easysrc = NULL;
}
+#endif /* CURL_DISABLE_LIBCURL_OPTION */
diff --git a/src/tool_easysrc.h b/src/tool_easysrc.h
index 21b567458..8e81d5567 100644
--- a/src/tool_easysrc.h
+++ b/src/tool_easysrc.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2012, 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
@@ -22,6 +22,7 @@
*
***************************************************************************/
#include "setup.h"
+#ifndef CURL_DISABLE_LIBCURL_OPTION
/* global variable declarations, for easy-interface source code generation */
@@ -30,5 +31,7 @@ extern struct curl_slist *easysrc_remarks;
void dumpeasysrc(struct Configurable *config);
+#endif /* CURL_DISABLE_LIBCIRL_CMD */
+
#endif /* HEADER_CURL_TOOL_EASYSRC_H */
diff --git a/src/tool_getparam.c b/src/tool_getparam.c
index c8519c201..50450c25f 100644
--- a/src/tool_getparam.c
+++ b/src/tool_getparam.c
@@ -739,8 +739,14 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
config->ftp_ssl_ccc_mode = ftpcccmethod(config, nextarg);
break;
case 'z': /* --libcurl */
+#ifdef CURL_DISABLE_LIBCURL_OPTION
+ warnf(config,
+ "--libcurl option was disabled at build-time!\n");
+ return PARAM_OPTION_UNKNOWN;
+#else
GetStr(&config->libcurl, nextarg);
break;
+#endif
case '#': /* --raw */
config->raw = toggle;
break;
diff --git a/src/tool_help.c b/src/tool_help.c
index 77b6df546..222af4225 100644
--- a/src/tool_help.c
+++ b/src/tool_help.c
@@ -110,7 +110,9 @@ static const char *const helptext[] = {
" --key KEY Private key file name (SSL/SSH)",
" --key-type TYPE Private key file type (DER/PEM/ENG) (SSL)",
" --krb LEVEL Enable Kerberos with specified security level (F)",
+#ifndef CURL_DISABLE_LIBCURL_OPTION
" --libcurl FILE Dump libcurl equivalent code of this command line",
+#endif
" --limit-rate RATE Limit transfer speed to this rate",
" -l, --list-only List only names of an FTP directory (F)",
" --local-port RANGE Force use of these local port numbers",
diff --git a/src/tool_operate.c b/src/tool_operate.c
index f3fb8ef2a..53da5f3b5 100644
--- a/src/tool_operate.c
+++ b/src/tool_operate.c
@@ -354,6 +354,7 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
}
}
+#ifndef CURL_DISABLE_LIBCURL_OPTION
/* This is the first entry added to easysrc and it initializes the slist */
easysrc = curl_slist_append(easysrc, "CURL *hnd = curl_easy_init();");
if(!easysrc) {
@@ -361,6 +362,7 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
res = CURLE_OUT_OF_MEMORY;
goto quit_curl;
}
+#endif
if(config->list_engines) {
struct curl_slist *engines = NULL;
@@ -1246,10 +1248,12 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
retry_sleep = retry_sleep_default; /* ms */
retrystart = tvnow();
+#ifndef CURL_DISABLE_LIBCURL_OPTION
if(!curl_slist_append(easysrc, "ret = curl_easy_perform(hnd);")) {
res = CURLE_OUT_OF_MEMORY;
goto show_error;
}
+#endif
for(;;) {
res = curl_easy_perform(curl);
@@ -1572,8 +1576,10 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
curl_easy_cleanup(curl);
config->easy = curl = NULL;
}
+#ifndef CURL_DISABLE_LIBCURL_OPTION
if(easysrc)
curl_slist_append(easysrc, "curl_easy_cleanup(hnd);");
+#endif
/* Close function-local opened file descriptors */
@@ -1585,10 +1591,12 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
if(config->trace_fopened && config->trace_stream)
fclose(config->trace_stream);
+#ifndef CURL_DISABLE_LIBCURL_OPTION
/* Dump the libcurl code if previously enabled.
NOTE: that this function relies on config->errors amongst other things
so not everything can be closed and cleaned before this is called */
dumpeasysrc(config);
+#endif
if(config->errors_fopened && config->errors)
fclose(config->errors);
diff --git a/src/tool_setopt.c b/src/tool_setopt.c
index b636aab38..6fc604716 100644
--- a/src/tool_setopt.c
+++ b/src/tool_setopt.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2012, 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
@@ -21,6 +21,8 @@
***************************************************************************/
#include "setup.h"
+#ifndef CURL_DISABLE_LIBCURL_OPTION
+
#include <curl/curl.h>
#define ENABLE_CURLX_PRINTF
@@ -123,3 +125,4 @@ CURLcode tool_setopt(CURL *curl, bool str, struct Configurable *config,
return ret;
}
+#endif /* CURL_DISABLE_LIBCURL_OPTION */
diff --git a/src/tool_setopt.h b/src/tool_setopt.h
index d01c9eb24..fcd60f856 100644
--- a/src/tool_setopt.h
+++ b/src/tool_setopt.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2012, 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
@@ -23,28 +23,47 @@
***************************************************************************/
#include "setup.h"
-CURLcode tool_setopt(CURL *curl, bool str, struct Configurable *config,
- const char *name, CURLoption tag, ...);
-
/*
* Macros used in operate()
*/
-#define my_setopt(x,y,z) do { \
- res = tool_setopt(x, FALSE, config, #y, y, z); \
+#define SETOPT_CHECK(v) do { \
+ res = (v); \
if(res) \
goto show_error; \
} WHILE_FALSE
-#define my_setopt_str(x,y,z) do { \
- res = tool_setopt(x, TRUE, config, #y, y, z); \
- if(res) \
- goto show_error; \
-} WHILE_FALSE
+#ifndef CURL_DISABLE_LIBCURL_OPTION
+
+/* Intercept setopt calls for --libcurl */
+
+CURLcode tool_setopt(CURL *curl, bool str, struct Configurable *config,
+ const char *name, CURLoption tag, ...);
+
+#define my_setopt(x,y,z) \
+ SETOPT_CHECK(tool_setopt(x, FALSE, config, #y, y, z))
+
+#define my_setopt_str(x,y,z) \
+ SETOPT_CHECK(tool_setopt(x, TRUE, config, #y, y, z))
#define res_setopt(x,y,z) tool_setopt(x, FALSE, config, #y, y, z)
#define res_setopt_str(x,y,z) tool_setopt(x, TRUE, config, #y, y, z)
-#endif /* HEADER_CURL_TOOL_SETOPT_H */
+#else
+
+/* No --libcurl, so pass options directly to library */
+
+#define my_setopt(x,y,z) \
+ SETOPT_CHECK(curl_easy_setopt(x, y, z))
+#define my_setopt_str(x,y,z) \
+ SETOPT_CHECK(curl_easy_setopt(x, y, z))
+
+#define res_setopt(x,y,z) curl_easy_setopt(x,y,z)
+
+#define res_setopt_str(x,y,z) curl_easy_setopt(x,y,z)
+
+#endif /* CURL_DISABLE_LIBCURL_OPTION */
+
+#endif /* HEADER_CURL_TOOL_SETOPT_H */