gnupg/keyserver (ChangeLog gpgkeys_curl.c ksutil.c ksutil.h)
cvs user dshaw
cvs at cvs.gnupg.org
Sun Apr 17 03:35:31 CEST 2005
Date: Sunday, April 17, 2005 @ 03:52:04
Author: dshaw
Path: /cvs/gnupg/gnupg/keyserver
Modified: ChangeLog gpgkeys_curl.c ksutil.c ksutil.h
* 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.
----------------+
ChangeLog | 4 ++++
gpgkeys_curl.c | 6 +++++-
ksutil.c | 37 +++++++++++++++++++++----------------
ksutil.h | 10 +++++++++-
4 files changed, 39 insertions(+), 18 deletions(-)
Index: gnupg/keyserver/ChangeLog
diff -u gnupg/keyserver/ChangeLog:1.123 gnupg/keyserver/ChangeLog:1.124
--- gnupg/keyserver/ChangeLog:1.123 Sun Apr 17 03:39:24 2005
+++ gnupg/keyserver/ChangeLog Sun Apr 17 03:52:04 2005
@@ -1,5 +1,9 @@
2005-04-16 David Shaw <dshaw at jabberwocky.com>
+ * 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.
+
* curl-shim.h, curl-shim.c (handle_error, curl_easy_setopt,
curl_easy_perform): Add POST functionality to the curl shim.
Index: gnupg/keyserver/gpgkeys_curl.c
diff -u gnupg/keyserver/gpgkeys_curl.c:1.16 gnupg/keyserver/gpgkeys_curl.c:1.17
--- gnupg/keyserver/gpgkeys_curl.c:1.16 Sat Apr 16 20:50:46 2005
+++ gnupg/keyserver/gpgkeys_curl.c Sun Apr 17 03:52:04 2005
@@ -48,6 +48,9 @@
CURLcode res;
char errorbuffer[CURL_ERROR_SIZE];
char request[MAX_URL];
+ struct curl_writer_ctx ctx;
+
+ memset(&ctx,0,sizeof(ctx));
if(strncmp(getkey,"0x",2)==0)
getkey+=2;
@@ -62,7 +65,8 @@
curl_easy_setopt(curl,CURLOPT_URL,request);
curl_easy_setopt(curl,CURLOPT_WRITEFUNCTION,curl_writer);
- curl_easy_setopt(curl,CURLOPT_FILE,output);
+ ctx.stream=output;
+ curl_easy_setopt(curl,CURLOPT_FILE,&ctx);
curl_easy_setopt(curl,CURLOPT_ERRORBUFFER,errorbuffer);
res=curl_easy_perform(curl);
Index: gnupg/keyserver/ksutil.c
diff -u gnupg/keyserver/ksutil.c:1.7 gnupg/keyserver/ksutil.c:1.8
--- gnupg/keyserver/ksutil.c:1.7 Sat Apr 16 20:50:46 2005
+++ gnupg/keyserver/ksutil.c Sun Apr 17 03:52:04 2005
@@ -329,39 +329,44 @@
}
size_t
-curl_writer(const void *ptr,size_t size,size_t nmemb,void *stream)
+curl_writer(const void *ptr,size_t size,size_t nmemb,void *cw_ctx)
{
+ struct curl_writer_ctx *ctx=cw_ctx;
const char *buf=ptr;
size_t i;
- static int markeridx=0,begun=0,done=0;
- static const char *marker=BEGIN;
+
+ if(!ctx->initialized)
+ {
+ ctx->marker=BEGIN;
+ ctx->initialized=1;
+ }
/* scan the incoming data for our marker */
- for(i=0;!done && i<(size*nmemb);i++)
+ for(i=0;!ctx->done && i<(size*nmemb);i++)
{
- if(buf[i]==marker[markeridx])
+ if(buf[i]==ctx->marker[ctx->markeridx])
{
- markeridx++;
- if(marker[markeridx]=='\0')
+ ctx->markeridx++;
+ if(ctx->marker[ctx->markeridx]=='\0')
{
- if(begun)
- done=1;
+ if(ctx->begun)
+ ctx->done=1;
else
{
/* We've found the BEGIN marker, so now we're looking
for the END marker. */
- begun=1;
- marker=END;
- markeridx=0;
- fprintf(stream,BEGIN);
+ ctx->begun=1;
+ ctx->marker=END;
+ ctx->markeridx=0;
+ fprintf(ctx->stream,BEGIN);
continue;
}
}
}
else
- markeridx=0;
+ ctx->markeridx=0;
- if(begun)
+ if(ctx->begun)
{
/* Canonicalize CRLF to just LF by stripping CRs. This
actually makes sense, since on Unix-like machines LF is
@@ -372,7 +377,7 @@
the like. */
if(buf[i]!='\r')
- fputc(buf[i],stream);
+ fputc(buf[i],ctx->stream);
}
}
Index: gnupg/keyserver/ksutil.h
diff -u gnupg/keyserver/ksutil.h:1.9 gnupg/keyserver/ksutil.h:1.10
--- gnupg/keyserver/ksutil.h:1.9 Sat Apr 16 20:50:46 2005
+++ gnupg/keyserver/ksutil.h Sun Apr 17 03:52:04 2005
@@ -101,6 +101,14 @@
const char *ks_action_to_string(enum ks_action action);
void print_nocr(FILE *stream,const char *str);
int curl_err_to_gpg_err(CURLcode error);
-size_t curl_writer(const void *ptr,size_t size,size_t nmemb,void *stream);
+
+struct curl_writer_ctx
+{
+ int initialized,markeridx,begun,done;
+ const char *marker;
+ FILE *stream;
+};
+
+size_t curl_writer(const void *ptr,size_t size,size_t nmemb,void *cw_ctx);
#endif /* !_KSUTIL_H_ */
More information about the Gnupg-commits
mailing list