summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleg Pudeyev <oleg@bsdpower.com>2013-11-26 07:01:08 -0800
committerOleg Pudeyev <oleg@bsdpower.com>2013-11-26 07:01:08 -0800
commitc655a3c68f1a182aaa7f9626a5548c0a7df6cd84 (patch)
tree9a947c2a878bc452b34af1e3ffd24217d0f50d7f
parentf605453bea18fab520e123568e6670bb49bdc963 (diff)
parent0f12f880b88f018d7ab853a0dff44e28fdeabc16 (diff)
downloadpycurl-c655a3c68f1a182aaa7f9626a5548c0a7df6cd84.tar.gz
Merge pull request #65 from romuloceccon/feature_detection_cleanup
Feature detection cleanup
-rw-r--r--src/pycurl.c32
1 files changed, 8 insertions, 24 deletions
diff --git a/src/pycurl.c b/src/pycurl.c
index fe6c76e..5c687ca 100644
--- a/src/pycurl.c
+++ b/src/pycurl.c
@@ -96,6 +96,10 @@
#define HAVE_CURLOPT_RESOLVE
#endif
+#if LIBCURL_VERSION_NUM >= 0x071800 /* check for 7.24.0 or greater */
+#define HAVE_CURLOPT_DNS_SERVERS
+#endif
+
/* Python < 2.5 compat for Py_ssize_t */
#if PY_VERSION_HEX < 0x02050000
typedef int Py_ssize_t;
@@ -1581,24 +1585,14 @@ read_callback(char *ptr, size_t size, size_t nmemb, void *stream)
}
else if (PyInt_Check(result)) {
long r = PyInt_AsLong(result);
- if (r != CURL_READFUNC_ABORT
-#if LIBCURL_VERSION_NUM >= 0x071200 /* CURL_READFUNC_PAUSE appeared in libcurl 7.18.0 */
- && r != CURL_READFUNC_PAUSE
-#endif
- ) {
+ if (r != CURL_READFUNC_ABORT && r != CURL_READFUNC_PAUSE)
goto type_error;
- }
ret = r; /* either CURL_READFUNC_ABORT or CURL_READFUNC_PAUSE */
}
else if (PyLong_Check(result)) {
long r = PyLong_AsLong(result);
- if (r != CURL_READFUNC_ABORT
-#if LIBCURL_VERSION_NUM >= 0x071200 /* CURL_READFUNC_PAUSE appeared in libcurl 7.18.0 */
- && r != CURL_READFUNC_PAUSE
-#endif
- ) {
+ if (r != CURL_READFUNC_ABORT && r != CURL_READFUNC_PAUSE)
goto type_error;
- }
ret = r; /* either CURL_READFUNC_ABORT or CURL_READFUNC_PAUSE */
}
else {
@@ -1985,7 +1979,7 @@ do_curl_setopt(CurlObject *self, PyObject *args)
case CURLOPT_SSH_HOST_PUBLIC_KEY_MD5:
case CURLOPT_CRLFILE:
case CURLOPT_ISSUERCERT:
-#if LIBCURL_VERSION_NUM >= 0x071800
+#ifdef HAVE_CURLOPT_DNS_SERVERS
case CURLOPT_DNS_SERVERS:
#endif
/* FIXME: check if more of these options allow binary data */
@@ -2635,8 +2629,6 @@ do_curl_getinfo(CurlObject *self, PyObject *args)
return NULL;
}
-#if LIBCURL_VERSION_NUM >= 0x071200 /* curl_easy_pause() appeared in libcurl 7.18.0 */
-
/* curl_easy_pause() can be called from inside a callback or outside */
static PyObject *
do_curl_pause(CurlObject *self, PyObject *args)
@@ -2686,8 +2678,6 @@ static const char co_pause_doc [] =
"Pauses or unpauses a curl handle. Bitmask should be a value such as PAUSE_RECV or PAUSE_CONT. "
"Raises pycurl.error exception upon failure.\n";
-#endif
-
/*************************************************************************
// CurlMultiObject
**************************************************************************/
@@ -3428,9 +3418,7 @@ static PyMethodDef curlobject_methods[] = {
{"close", (PyCFunction)do_curl_close, METH_NOARGS, co_close_doc},
{"errstr", (PyCFunction)do_curl_errstr, METH_NOARGS, co_errstr_doc},
{"getinfo", (PyCFunction)do_curl_getinfo, METH_VARARGS, co_getinfo_doc},
-#if LIBCURL_VERSION_NUM >= 0x071200 /* curl_easy_pause() appeared in libcurl 7.18.0 */
{"pause", (PyCFunction)do_curl_pause, METH_VARARGS, co_pause_doc},
-#endif
{"perform", (PyCFunction)do_curl_perform, METH_NOARGS, co_perform_doc},
{"setopt", (PyCFunction)do_curl_setopt, METH_VARARGS, co_setopt_doc},
{"unsetopt", (PyCFunction)do_curl_unsetopt, METH_VARARGS, co_unsetopt_doc},
@@ -3937,9 +3925,7 @@ initpycurl(void)
/* Abort curl_read_callback(). */
insint_c(d, "READFUNC_ABORT", CURL_READFUNC_ABORT);
-#if LIBCURL_VERSION_NUM >= 0x071200 /* CURL_READFUNC_PAUSE appeared in libcurl 7.18.0 */
insint_c(d, "READFUNC_PAUSE", CURL_READFUNC_PAUSE);
-#endif
/* Pause curl_write_callback(). */
insint_c(d, "WRITEFUNC_PAUSE", CURL_WRITEFUNC_PAUSE);
@@ -4316,15 +4302,13 @@ initpycurl(void)
insint_c(d, "INFO_CERTINFO", CURLINFO_CERTINFO);
#endif
-#if LIBCURL_VERSION_NUM >= 0x071200 /* curl_easy_pause() appeared in libcurl 7.18.0 */
/* CURLPAUSE: symbolic constants for pause(bitmask) */
insint_c(d, "PAUSE_RECV", CURLPAUSE_RECV);
insint_c(d, "PAUSE_SEND", CURLPAUSE_SEND);
insint_c(d, "PAUSE_ALL", CURLPAUSE_ALL);
insint_c(d, "PAUSE_CONT", CURLPAUSE_CONT);
-#endif
-#if LIBCURL_VERSION_NUM >= 0x071800
+#ifdef HAVE_CURLOPT_DNS_SERVERS
insint_c(d, "DNS_SERVERS", CURLOPT_DNS_SERVERS);
#endif