[svn] dirmngr - r256 - trunk/src
svn author marcus
cvs at cvs.gnupg.org
Tue Jul 31 00:20:14 CEST 2007
Author: marcus
Date: 2007-07-31 00:19:44 +0200 (Tue, 31 Jul 2007)
New Revision: 256
Modified:
trunk/src/ChangeLog
trunk/src/crlfetch.c
trunk/src/ocsp.c
Log:
2007-07-31 Marcus Brinkmann <marcus at g10code.de>
* crlfetch.c: Include "estream.h".
(crl_fetch): Use es_read callback instead a file handle.
(crl_close_reader): Use es_fclose instead of fclose.
(struct file_reader_map_s): Change type of FP to estream_t.
(register_file_reader, crl_fetch, crl_close_reader): Likewise.
* ocsp.c: Include "estream.h".
(read_response): Change type of FP to estream_t.
(read_response, do_ocsp_request): Use es_* variants of I/O
functions.
Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog 2007-07-30 22:03:27 UTC (rev 255)
+++ trunk/src/ChangeLog 2007-07-30 22:19:44 UTC (rev 256)
@@ -1,5 +1,15 @@
2007-07-31 Marcus Brinkmann <marcus at g10code.de>
+ * crlfetch.c: Include "estream.h".
+ (crl_fetch): Use es_read callback instead a file handle.
+ (crl_close_reader): Use es_fclose instead of fclose.
+ (struct file_reader_map_s): Change type of FP to estream_t.
+ (register_file_reader, crl_fetch, crl_close_reader): Likewise.
+ * ocsp.c: Include "estream.h".
+ (read_response): Change type of FP to estream_t.
+ (read_response, do_ocsp_request): Use es_* variants of I/O
+ functions.
+
* http.c: Include <pth.h>.
(http_wait_response) [HAVE_W32_SYSTEM]: Use DuplicateHandle.
(cookie_read): Use pth_read instead read.
Modified: trunk/src/crlfetch.c
===================================================================
--- trunk/src/crlfetch.c 2007-07-30 22:03:27 UTC (rev 255)
+++ trunk/src/crlfetch.c 2007-07-30 22:19:44 UTC (rev 256)
@@ -30,13 +30,14 @@
#include "misc.h"
#include "http.h"
+#include "estream.h"
/* We need to associate a reader object with file streams. This table
is used for it. */
struct file_reader_map_s
{
ksba_reader_t reader;
- FILE *fp;
+ estream_t fp;
};
#define MAX_FILE_READER 50
static struct file_reader_map_s file_reader_map[MAX_FILE_READER];
@@ -44,7 +45,7 @@
/* Associate FP with READER. If the table is full wait until another
thread has removed an entry. */
static void
-register_file_reader (ksba_reader_t reader, FILE *fp)
+register_file_reader (ksba_reader_t reader, estream_t fp)
{
int i;
@@ -64,10 +65,10 @@
/* Scan the table for an entry matching READER, emove tha entry and
return the associated file pointer. */
-static FILE *
+static estream_t
get_file_reader (ksba_reader_t reader)
{
- FILE *fp = NULL;
+ estream_t fp = NULL;
int i;
for (i=0; i < MAX_FILE_READER; i++)
@@ -82,8 +83,6 @@
}
-
-
/* Fetch CRL from URL and return the entire CRL using new ksba reader
object in READER. Note that this reader object should be closed
only using ldap_close_reader. */
@@ -140,11 +139,11 @@
{
case 200:
{
- FILE *fp = http_get_read_ptr (hd);
+ estream_t fp = http_get_read_ptr (hd);
err = ksba_reader_new (reader);
if (!err)
- err = ksba_reader_set_file (*reader, fp);
+ err = ksba_reader_set_cb (*reader, &es_read, fp);
if (err)
{
log_error (_("error initializing reader object: %s\n"),
@@ -323,7 +322,7 @@
void
crl_close_reader (ksba_reader_t reader)
{
- FILE *fp;
+ estream_t fp;
if (!reader)
return;
@@ -331,7 +330,7 @@
/* Check whether this is a HTTP one. */
fp = get_file_reader (reader);
if (fp) /* This is an HTTP context. */
- fclose (fp);
+ es_fclose (fp);
else /* This is an ldap wrapper context. */
ldap_wrapper_release_context (reader);
Modified: trunk/src/ocsp.c
===================================================================
--- trunk/src/ocsp.c 2007-07-30 22:03:27 UTC (rev 255)
+++ trunk/src/ocsp.c 2007-07-30 22:19:44 UTC (rev 256)
@@ -29,8 +29,8 @@
#include "http.h"
#include "validate.h"
#include "certcache.h"
-
#include "ocsp.h"
+#include "estream.h"
/* The maximum size we allow as a response from an OCSP reponder. */
#define MAX_RESPONSE_SIZE 65536
@@ -53,7 +53,7 @@
/* Read from FP and return a newly allocated buffer in R_BUFFER with the
entire data read from FP. */
static gpg_error_t
-read_response (FILE *fp, unsigned char **r_buffer, size_t *r_buflen)
+read_response (estream_t fp, unsigned char **r_buffer, size_t *r_buflen)
{
gpg_error_t err;
unsigned char *buffer;
@@ -74,8 +74,8 @@
size_t nread = 0;
assert (nbytes < bufsize);
- nread = fread (buffer+nbytes, 1, bufsize-nbytes, fp);
- if (nread < bufsize-nbytes && ferror (fp))
+ nread = es_fread (buffer+nbytes, 1, bufsize-nbytes, fp);
+ if (nread < bufsize-nbytes && es_ferror (fp))
{
err = gpg_error_from_errno (errno);
log_error (_("error reading from responder: %s\n"),
@@ -83,7 +83,7 @@
xfree (buffer);
return err;
}
- if ( !(nread == bufsize-nbytes && !feof (fp)))
+ if ( !(nread == bufsize-nbytes && !es_feof (fp)))
{ /* Response succesfully received. */
nbytes += nread;
*r_buffer = buffer;
@@ -175,12 +175,12 @@
return err;
}
- fprintf (http_get_write_ptr (http),
- "Content-Type: application/ocsp-request\r\n"
- "Content-Length: %lu\r\n",
- (unsigned long)requestlen );
+ es_fprintf (http_get_write_ptr (http),
+ "Content-Type: application/ocsp-request\r\n"
+ "Content-Length: %lu\r\n",
+ (unsigned long)requestlen );
http_start_data (http);
- if (fwrite (request, requestlen, 1, http_get_write_ptr (http)) != 1)
+ if (es_fwrite (request, requestlen, 1, http_get_write_ptr (http)) != 1)
{
err = gpg_error_from_errno (errno);
log_error ("error sending request to `%s': %s\n", url, strerror (errno));
More information about the Gnupg-commits
mailing list