[svn] GnuPG - r4459 - branches/STABLE-BRANCH-1-4/keyserver
svn author dshaw
cvs at cvs.gnupg.org
Tue Mar 13 18:53:58 CET 2007
Author: dshaw
Date: 2007-03-13 18:53:57 +0100 (Tue, 13 Mar 2007)
New Revision: 4459
Modified:
branches/STABLE-BRANCH-1-4/keyserver/ChangeLog
branches/STABLE-BRANCH-1-4/keyserver/curl-shim.c
branches/STABLE-BRANCH-1-4/keyserver/curl-shim.h
branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_curl.c
Log:
* gpgkeys_curl.c (main): Use curl_version_info to verify that the
protocol we're about to use is actually available.
* curl-shim.h, curl-shim.c (curl_free): Make into a macro.
(curl_version_info): New. Only advertises "http" for our shim, of
course.
Modified: branches/STABLE-BRANCH-1-4/keyserver/ChangeLog
===================================================================
--- branches/STABLE-BRANCH-1-4/keyserver/ChangeLog 2007-03-10 04:52:57 UTC (rev 4458)
+++ branches/STABLE-BRANCH-1-4/keyserver/ChangeLog 2007-03-13 17:53:57 UTC (rev 4459)
@@ -1,3 +1,12 @@
+2007-03-13 David Shaw <dshaw at jabberwocky.com>
+
+ * gpgkeys_curl.c (main): Use curl_version_info to verify that the
+ protocol we're about to use is actually available.
+
+ * curl-shim.h, curl-shim.c (curl_free): Make into a macro.
+ (curl_version_info): New. Only advertises "http" for our shim, of
+ course.
+
2007-02-10 David Shaw <dshaw at jabberwocky.com>
* gpgkeys_ldap.c (send_key): Missing a free().
Modified: branches/STABLE-BRANCH-1-4/keyserver/curl-shim.c
===================================================================
--- branches/STABLE-BRANCH-1-4/keyserver/curl-shim.c 2007-03-10 04:52:57 UTC (rev 4458)
+++ branches/STABLE-BRANCH-1-4/keyserver/curl-shim.c 2007-03-13 17:53:57 UTC (rev 4459)
@@ -322,8 +322,13 @@
return enc;
}
-void
-curl_free(char *ptr)
+curl_version_info_data *
+curl_version_info(int type)
{
- free(ptr);
+ static curl_version_info_data data;
+ static const char *protocols[]={"http",NULL};
+
+ data.protocols=protocols;
+
+ return &data;
}
Modified: branches/STABLE-BRANCH-1-4/keyserver/curl-shim.h
===================================================================
--- branches/STABLE-BRANCH-1-4/keyserver/curl-shim.h 2007-03-10 04:52:57 UTC (rev 4458)
+++ branches/STABLE-BRANCH-1-4/keyserver/curl-shim.h 2007-03-13 17:53:57 UTC (rev 4459)
@@ -76,8 +76,14 @@
struct http_context hd;
} CURL;
+typedef struct
+{
+ const char **protocols;
+} curl_version_info_data;
+
#define CURL_ERROR_SIZE 256
#define CURL_GLOBAL_DEFAULT 0
+#define CURLVERSION_NOW 0
CURLcode curl_global_init(long flags);
void curl_global_cleanup(void);
@@ -86,7 +92,8 @@
CURLcode curl_easy_perform(CURL *curl);
void curl_easy_cleanup(CURL *curl);
char *curl_easy_escape(CURL *curl,char *str,int len);
-void curl_free(char *ptr);
+#define curl_free(x) free(x)
#define curl_version() "GnuPG curl-shim "VERSION
+curl_version_info_data *curl_version_info(int type);
#endif /* !_CURL_SHIM_H_ */
Modified: branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_curl.c
===================================================================
--- branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_curl.c 2007-03-10 04:52:57 UTC (rev 4458)
+++ branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_curl.c 2007-03-13 17:53:57 UTC (rev 4459)
@@ -1,5 +1,5 @@
/* gpgkeys_curl.c - fetch a key via libcurl
- * Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
+ * Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@@ -112,11 +112,12 @@
int
main(int argc,char *argv[])
{
- int arg,ret=KEYSERVER_INTERNAL_ERROR;
+ int arg,ret=KEYSERVER_INTERNAL_ERROR,i;
char line[MAX_LINE];
char *thekey=NULL;
long follow_redirects=5;
char *proxy=NULL;
+ curl_version_info_data *curldata;
console=stderr;
@@ -261,6 +262,7 @@
}
curl_global_init(CURL_GLOBAL_DEFAULT);
+
curl=curl_easy_init();
if(!curl)
{
@@ -269,6 +271,20 @@
goto fail;
}
+ /* Make sure we have the protocol the user is asking for so we can
+ print a nicer error message. */
+ curldata=curl_version_info(CURLVERSION_NOW);
+ for(i=0;curldata->protocols[i];i++)
+ if(strcasecmp(curldata->protocols[i],opt->scheme)==0)
+ break;
+
+ if(curldata->protocols[i]==NULL)
+ {
+ fprintf(console,"gpgkeys: protocol `%s' not supported\n",opt->scheme);
+ ret=KEYSERVER_SCHEME_NOT_FOUND;
+ goto fail;
+ }
+
if(follow_redirects)
{
curl_easy_setopt(curl,CURLOPT_FOLLOWLOCATION,1);
More information about the Gnupg-commits
mailing list