From 1c359759ab99a3c663482b219971e75cb113daef Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Tue, 4 Feb 2003 14:57:41 +0000 Subject: [PATCH] 2003-02-01 Marcus Brinkmann * engine-gpgsm.c (start): Handle all errors, not only most of them. (xtoi_1, xtoi_2): Remove macro. (status_handler): Replace use of xtoi_2 with _gpgme_hextobyte. --- trunk/gpgme/ChangeLog | 7 +++++++ trunk/gpgme/engine-gpgsm.c | 18 +++++++----------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/trunk/gpgme/ChangeLog b/trunk/gpgme/ChangeLog index 31051c0..a122a7e 100644 --- a/trunk/gpgme/ChangeLog +++ b/trunk/gpgme/ChangeLog @@ -1,3 +1,10 @@ +2003-02-01 Marcus Brinkmann + + * engine-gpgsm.c (start): Handle all errors, not only most of + them. + (xtoi_1, xtoi_2): Remove macro. + (status_handler): Replace use of xtoi_2 with _gpgme_hextobyte. + 2003-02-01 Marcus Brinkmann * engine-gpgsm.c (map_assuan_error): Replace diff --git a/trunk/gpgme/engine-gpgsm.c b/trunk/gpgme/engine-gpgsm.c index da420fa..3f78ef9 100644 --- a/trunk/gpgme/engine-gpgsm.c +++ b/trunk/gpgme/engine-gpgsm.c @@ -43,12 +43,7 @@ #include "engine-backend.h" - -#define xtoi_1(p) (*(p) <= '9'? (*(p)- '0'): \ - *(p) <= 'F'? (*(p)-'A'+10):(*(p)-'a'+10)) -#define xtoi_2(p) ((xtoi_1(p) * 16) + xtoi_1((p)+1)) - - + typedef struct { int fd; /* FD we talk about. */ @@ -120,7 +115,7 @@ gpgsm_get_req_version (void) return NEED_GPGSM_VERSION; } - + static void close_notify_handler (int fd, void *opaque) { @@ -746,7 +741,7 @@ status_handler (void *opaque, int fd) { /* Handle escaped characters. */ ++src; - *dst = xtoi_2 (src); + *dst = (unsigned char) _gpgme_hextobyte (src); (*alinelen)++; src += 2; } @@ -828,10 +823,10 @@ add_io_cb (GpgsmObject gpgsm, iocb_data_t *iocbd, GpgmeIOCb handler) static GpgmeError start (GpgsmObject gpgsm, const char *command) { - GpgmeError err = 0; + GpgmeError err; err = add_io_cb (gpgsm, &gpgsm->status_cb, status_handler); - if (gpgsm->input_cb.fd != -1) + if (!err && gpgsm->input_cb.fd != -1) err = add_io_cb (gpgsm, &gpgsm->input_cb, _gpgme_data_outbound_handler); if (!err && gpgsm->output_cb.fd != -1) err = add_io_cb (gpgsm, &gpgsm->output_cb, _gpgme_data_inbound_handler); @@ -841,7 +836,8 @@ start (GpgsmObject gpgsm, const char *command) if (!err) err = assuan_write_line (gpgsm->assuan_ctx, command); - (*gpgsm->io_cbs.event) (gpgsm->io_cbs.event_priv, GPGME_EVENT_START, NULL); + if (!err) + (*gpgsm->io_cbs.event) (gpgsm->io_cbs.event_priv, GPGME_EVENT_START, NULL); return err; } -- 2.26.2