mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-22 14:57:02 +01:00
* gpgkeys_hkp.c: New hkp handler that uses curl or curl-shim.
* Makefile.am: Build new gpgkeys_hkp. * curl-shim.c (curl_easy_perform): Cleanup.
This commit is contained in:
parent
5609f5eafd
commit
0884653a13
@ -1,5 +1,11 @@
|
||||
2005-04-16 David Shaw <dshaw@jabberwocky.com>
|
||||
|
||||
* gpgkeys_hkp.c: New hkp handler that uses curl or curl-shim.
|
||||
|
||||
* Makefile.am: Build new gpgkeys_hkp.
|
||||
|
||||
* curl-shim.c (curl_easy_perform): Cleanup.
|
||||
|
||||
* ksutil.h, ksutil.c (curl_writer), gpgkeys_curl.c (get_key): Pass
|
||||
a context to curl_writer so we can support multiple fetches in a
|
||||
single session.
|
||||
|
@ -29,7 +29,7 @@ gpglibexec_SCRIPTS = @GPGKEYS_MAILTO@
|
||||
noinst_SCRIPTS = gpgkeys_test
|
||||
|
||||
gpgkeys_ldap_SOURCES = gpgkeys_ldap.c ksutil.c ksutil.h
|
||||
gpgkeys_hkp_SOURCES = gpgkeys_hkp.c ksutil.c ksutil.h
|
||||
gpgkeys_hkp_SOURCES = ksutil.c ksutil.h
|
||||
gpgkeys_http_SOURCES = gpgkeys_http.c ksutil.c ksutil.h
|
||||
gpgkeys_finger_SOURCES = gpgkeys_finger.c ksutil.c ksutil.h
|
||||
gpgkeys_curl_SOURCES = gpgkeys_curl.c ksutil.c ksutil.h
|
||||
@ -37,15 +37,25 @@ gpgkeys_curl_SOURCES = gpgkeys_curl.c ksutil.c ksutil.h
|
||||
other_libs = $(LIBICONV) $(LIBINTL) $(CAPLIBS)
|
||||
|
||||
gpgkeys_ldap_LDADD = ../util/libutil.a @LDAPLIBS@ @NETLIBS@ $(other_libs) @GETOPT@ @W32LIBS@
|
||||
gpgkeys_hkp_LDADD = ../util/libutil.a @NETLIBS@ @SRVLIBS@ $(other_libs) @GETOPT@ @W32LIBS@
|
||||
gpgkeys_http_LDADD = ../util/libutil.a @NETLIBS@ @SRVLIBS@ $(other_libs) @GETOPT@ @W32LIBS@
|
||||
gpgkeys_finger_LDADD = ../util/libutil.a @NETLIBS@ $(other_libs) @GETOPT@ @W32LIBS@
|
||||
|
||||
if WITH_CURL
|
||||
gpgkeys_hkp_SOURCES += gpgkeys_hkp.c
|
||||
if FAKE_CURL
|
||||
gpgkeys_curl_SOURCES += curl-shim.c curl-shim.h
|
||||
gpgkeys_curl_CPPFLAGS = -DFAKE_CURL
|
||||
gpgkeys_curl_LDADD = ../util/libutil.a @NETLIBS@ @SRVLIBS@ $(other_libs) @GETOPT@ @W32LIBS@
|
||||
gpgkeys_hkp_SOURCES += curl-shim.c curl-shim.h
|
||||
gpgkeys_hkp_CPPFLAGS = -DFAKE_CURL
|
||||
gpgkeys_hkp_LDADD = ../util/libutil.a @NETLIBS@ @SRVLIBS@ $(other_libs) @GETOPT@ @W32LIBS@
|
||||
else
|
||||
gpgkeys_curl_CPPFLAGS = @LIBCURL_CPPFLAGS@
|
||||
gpgkeys_curl_LDADD = @LIBCURL@ @GETOPT@
|
||||
gpgkeys_hkp_CPPFLAGS = @LIBCURL_CPPFLAGS@
|
||||
gpgkeys_hkp_LDADD = @LIBCURL@ @GETOPT@
|
||||
endif
|
||||
else
|
||||
gpgkeys_hkp_SOURCES += gpgkeys_oldhkp.c
|
||||
gpgkeys_hkp_LDADD = ../util/libutil.a @NETLIBS@ @SRVLIBS@ $(other_libs) @GETOPT@ @W32LIBS@
|
||||
endif
|
||||
|
@ -30,10 +30,13 @@
|
||||
#include "util.h"
|
||||
#include "curl-shim.h"
|
||||
|
||||
static CURLcode handle_error(CURL *curl,CURLcode err,const char *str)
|
||||
static CURLcode
|
||||
handle_error(CURL *curl,CURLcode err,const char *str)
|
||||
{
|
||||
if(curl->errorbuffer)
|
||||
{
|
||||
/* Make sure you never exceed CURL_ERROR_SIZE, currently set to
|
||||
256 in curl-shim.h */
|
||||
switch(err)
|
||||
{
|
||||
case CURLE_OK:
|
||||
@ -67,24 +70,29 @@ static CURLcode handle_error(CURL *curl,CURLcode err,const char *str)
|
||||
return err;
|
||||
}
|
||||
|
||||
CURLcode curl_global_init(long flags)
|
||||
CURLcode
|
||||
curl_global_init(long flags)
|
||||
{
|
||||
return CURLE_OK;
|
||||
}
|
||||
|
||||
void curl_global_cleanup(void) {}
|
||||
void
|
||||
curl_global_cleanup(void) {}
|
||||
|
||||
CURL *curl_easy_init(void)
|
||||
CURL *
|
||||
curl_easy_init(void)
|
||||
{
|
||||
return calloc(1,sizeof(CURL));
|
||||
}
|
||||
|
||||
void curl_easy_cleanup(CURL *curl)
|
||||
void
|
||||
curl_easy_cleanup(CURL *curl)
|
||||
{
|
||||
free(curl);
|
||||
}
|
||||
|
||||
CURLcode curl_easy_setopt(CURL *curl,CURLoption option,...)
|
||||
CURLcode
|
||||
curl_easy_setopt(CURL *curl,CURLoption option,...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
@ -124,7 +132,8 @@ CURLcode curl_easy_setopt(CURL *curl,CURLoption option,...)
|
||||
return handle_error(curl,CURLE_OK,NULL);
|
||||
}
|
||||
|
||||
CURLcode curl_easy_perform(CURL *curl)
|
||||
CURLcode
|
||||
curl_easy_perform(CURL *curl)
|
||||
{
|
||||
int rc;
|
||||
CURLcode err=CURLE_OK;
|
||||
@ -133,16 +142,7 @@ CURLcode curl_easy_perform(CURL *curl)
|
||||
if(curl->flags.post)
|
||||
{
|
||||
rc=http_open(&curl->hd,HTTP_REQ_POST,curl->url,0,curl->proxy);
|
||||
if(rc!=0)
|
||||
{
|
||||
if(rc==G10ERR_NETWORK)
|
||||
errstr=strerror(errno);
|
||||
else
|
||||
errstr=g10_errstr(rc);
|
||||
|
||||
err=CURLE_COULDNT_CONNECT;
|
||||
}
|
||||
else
|
||||
if(rc==0)
|
||||
{
|
||||
char content_len[50];
|
||||
unsigned int post_len=strlen(curl->postfields);
|
||||
@ -156,47 +156,19 @@ CURLcode curl_easy_perform(CURL *curl)
|
||||
http_start_data(&curl->hd);
|
||||
iobuf_write(curl->hd.fp_write,curl->postfields,post_len);
|
||||
rc=http_wait_response(&curl->hd,&curl->status);
|
||||
if(rc!=0)
|
||||
{
|
||||
if(rc==G10ERR_NETWORK)
|
||||
errstr=strerror(errno);
|
||||
else
|
||||
errstr=g10_errstr(rc);
|
||||
|
||||
err=CURLE_COULDNT_CONNECT;
|
||||
}
|
||||
|
||||
if(curl->flags.failonerror && curl->status>=300)
|
||||
if(rc==0 && curl->flags.failonerror && curl->status>=300)
|
||||
err=CURLE_HTTP_RETURNED_ERROR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rc=http_open(&curl->hd,HTTP_REQ_GET,curl->url,0,curl->proxy);
|
||||
if(rc!=0)
|
||||
{
|
||||
if(rc==G10ERR_NETWORK)
|
||||
errstr=strerror(errno);
|
||||
else
|
||||
errstr=g10_errstr(rc);
|
||||
|
||||
err=CURLE_COULDNT_CONNECT;
|
||||
}
|
||||
else
|
||||
if(rc==0)
|
||||
{
|
||||
rc=http_wait_response(&curl->hd,&curl->status);
|
||||
if(rc)
|
||||
if(rc==0)
|
||||
{
|
||||
http_close(&curl->hd);
|
||||
|
||||
if(rc==G10ERR_NETWORK)
|
||||
errstr=strerror(errno);
|
||||
else
|
||||
errstr=g10_errstr(rc);
|
||||
|
||||
err=CURLE_COULDNT_CONNECT;
|
||||
}
|
||||
else if(curl->flags.failonerror && curl->status>=300)
|
||||
if(curl->flags.failonerror && curl->status>=300)
|
||||
err=CURLE_HTTP_RETURNED_ERROR;
|
||||
else
|
||||
{
|
||||
@ -221,6 +193,19 @@ CURLcode curl_easy_perform(CURL *curl)
|
||||
http_close(&curl->hd);
|
||||
}
|
||||
}
|
||||
else
|
||||
http_close(&curl->hd);
|
||||
}
|
||||
}
|
||||
|
||||
if(rc!=0)
|
||||
{
|
||||
if(rc==G10ERR_NETWORK)
|
||||
errstr=strerror(errno);
|
||||
else
|
||||
errstr=g10_errstr(rc);
|
||||
|
||||
err=CURLE_COULDNT_CONNECT;
|
||||
}
|
||||
|
||||
return handle_error(curl,err,errstr);
|
||||
@ -232,7 +217,8 @@ CURLcode curl_easy_perform(CURL *curl)
|
||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
|
||||
"0123456789"
|
||||
|
||||
char *curl_escape(char *str,int length)
|
||||
char *
|
||||
curl_escape(char *str,int length)
|
||||
{
|
||||
int len,max,idx,enc_idx=0;
|
||||
char *enc;
|
||||
@ -282,7 +268,8 @@ char *curl_escape(char *str,int length)
|
||||
return enc;
|
||||
}
|
||||
|
||||
void curl_free(char *ptr)
|
||||
void
|
||||
curl_free(char *ptr)
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user