aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Shaw <[email protected]>2005-07-20 21:15:04 +0000
committerDavid Shaw <[email protected]>2005-07-20 21:15:04 +0000
commita918d63fd5462f5c5e33066f6313dd15bacbd409 (patch)
tree9a7ddfeb6de6771b169093a618e5bb9c7fcd7b48
parent* configure.ac: Add a define for FAKE_CURL. (diff)
downloadgnupg-a918d63fd5462f5c5e33066f6313dd15bacbd409.tar.gz
gnupg-a918d63fd5462f5c5e33066f6313dd15bacbd409.zip
* keyserver.c (curl_can_handle): New. Do a runtime check against libcurl
to see if it can handle a particular protocol. (keyserver_typemap): Call it here. * Makefile.am: Pull in libcurl for curl_version_info() if used.
Diffstat (limited to '')
-rw-r--r--g10/ChangeLog8
-rw-r--r--g10/Makefile.am3
-rw-r--r--g10/keyserver.c48
3 files changed, 43 insertions, 16 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog
index f2275364d..5a9fa6860 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,11 @@
+2005-07-20 David Shaw <[email protected]>
+
+ * keyserver.c (curl_can_handle): New. Do a runtime check against
+ libcurl to see if it can handle a particular protocol.
+ (keyserver_typemap): Call it here.
+
+ * Makefile.am: Pull in libcurl for curl_version_info() if used.
+
2005-07-19 Werner Koch <[email protected]>
* g10.c, options.h: New option --limit-card-insert-tries.
diff --git a/g10/Makefile.am b/g10/Makefile.am
index 887f4c595..9e50eeb9a 100644
--- a/g10/Makefile.am
+++ b/g10/Makefile.am
@@ -124,7 +124,8 @@ gpgv_SOURCES = gpgv.c \
verify.c
LDADD = $(needed_libs) $(other_libs) @ZLIBS@ @W32LIBS@ @LIBREADLINE@
-gpg_LDADD = $(LDADD) @DLLIBS@ @NETLIBS@ @LIBUSB@
+gpg_LDADD = $(LDADD) @DLLIBS@ @NETLIBS@ @LIBUSB@ @LIBCURL@
+##gpg_CPPFLAGS = @LIBCURL_CPPFLAGS@
$(PROGRAMS): $(needed_libs)
diff --git a/g10/keyserver.c b/g10/keyserver.c
index 39911acc9..e3c2391d9 100644
--- a/g10/keyserver.c
+++ b/g10/keyserver.c
@@ -25,6 +25,9 @@
#include <string.h>
#include <stdlib.h>
#include <assert.h>
+#ifdef HAVE_LIBCURL
+#include <curl/curl.h>
+#endif
#include "filter.h"
#include "keydb.h"
#include "status.h"
@@ -155,6 +158,10 @@ free_keyserver_spec(struct keyserver_spec *keyserver)
m_free(keyserver);
}
+/* TODO: once we cut over to an all-curl world, we don't need this
+ parser any longer so it can be removed, or at least moved to
+ keyserver/ksutil.c for limited use in gpgkeys_ldap or the like. */
+
struct keyserver_spec *
parse_keyserver_uri(const char *uri,int require_scheme,
const char *configname,unsigned int configlineno)
@@ -822,6 +829,31 @@ keyserver_search_prompt(IOBUF buffer,const char *searchstr)
m_free(line);
}
+static int
+curl_can_handle(const char *scheme)
+{
+#if defined(HAVE_LIBCURL)
+
+ const char * const *proto;
+ curl_version_info_data *data=curl_version_info(CURLVERSION_NOW);
+
+ assert(data);
+
+ for(proto=data->protocols;*proto;proto++)
+ if(strcasecmp(*proto,scheme)==0)
+ return 1;
+
+#elif defined(FAKE_CURL)
+
+ /* If we're faking curl, then we only support HTTP */
+ if(strcasecmp(scheme,"http")==0)
+ return 1;
+
+#endif
+
+ return 0;
+}
+
/* We sometimes want to use a different gpgkeys_xxx for a given
protocol (for example, ldaps is handled by gpgkeys_ldap). Map
these here. */
@@ -830,22 +862,8 @@ keyserver_typemap(const char *type)
{
if(strcmp(type,"ldaps")==0)
return "ldap";
-#ifdef FTP_VIA_LIBCURL
- else if(strcmp(type,"ftp")==0)
- return "curl";
-#endif
-#ifdef FTPS_VIA_LIBCURL
- else if(strcmp(type,"ftps")==0)
+ else if(curl_can_handle(type))
return "curl";
-#endif
-#ifdef HTTP_VIA_LIBCURL
- else if(strcmp(type,"http")==0)
- return "curl";
-#endif
-#ifdef HTTPS_VIA_LIBCURL
- else if(strcmp(type,"https")==0)
- return "curl";
-#endif
else
return type;
}