+2003-02-01 Marcus Brinkmann <marcus@g10code.de>
+
+ * 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 <marcus@g10code.de>
* engine-gpgsm.c (map_assuan_error): Replace
#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))
-
-
+\f
typedef struct
{
int fd; /* FD we talk about. */
return NEED_GPGSM_VERSION;
}
-
+\f
static void
close_notify_handler (int fd, void *opaque)
{
{
/* Handle escaped characters. */
++src;
- *dst = xtoi_2 (src);
+ *dst = (unsigned char) _gpgme_hextobyte (src);
(*alinelen)++;
src += 2;
}
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);
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;
}