From b083ea8da3619399b9c33887257d3c220941a704 Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Sun, 19 Jan 2003 21:51:07 +0000 Subject: [PATCH] 2003-01-19 Marcus Brinkmann * rungpg.c (_gpgme_engine_ops_gpg): Remove gpg_start. (gpg_start): Rename to ... (start): ... this function. Change arguments to GpgObject. (gpg_decrypt): Call start. (gpg_edit): Likewise. (gpg_encrypt): Likewise. (gpg_encrypt_sign): Likewise. (gpg_export): Likewise. (gpg_import): Likewise. (gpg_keylist): Likewise. (gpg_keylist_ext): Likewise. (gpg_trustlist): Likewise. (gpg_verify): Likewise. * engine-gpgsm.c (_gpgme_engine_ops_encrypt): Remove gpgsm_start. (gpgsm_start): Rename to ... (struct gpgsm_object_s): Remove member command. (gpgsm_release): Don't free command. (start): ... this function. Change arguments to GpgsmObject and const char *. (gpgsm_decrypt): Call start. (gpgsm_delete): Likewise. (gpgsm_encrypt): Likewise. (gpgsm_export): Likewise. (gpgsm_genkey): Likewise. (gpgsm_import): Likewise. (gpgsm_keylist): Likewise. (gpgsm_keylist_ext): Likewise. (gpgsm_verify): Likewise. * decrypt.c (_gpgme_decrypt_start): Don't call _gpgme_engine_start. * delete.c (_gpgme_op_delete_start): Likewise. * edit.c (_gpgme_op_edit_start): Likewise. * encrypt.c (_gpgme_op_encrypt_start): * encrypt-sign.c (_gpgme_op_encrypt_sign_start): * export.c (_gpgme_op_export_start): Likewise. * genkey.c (_gpgme_op_genkey_start): Likewise. * import.c (_gpgme_op_import_start): Likewise. * keylist.c (gpgme_op_keylist_ext_start): Likewise. (gpgme_op_keylist_start): Likewise. * sign.c (_gpgme_op_sign_start): Likewise. * trustlist.c (gpgme_op_trustlist_start): Likewise. * verify.c (_gpgme_op_verify_start): Likewise. * engine-backend.h (struct engine_ops): Remove member start. * engine.h (_gpgme_engine_start): Remove prototype. * engine.c (_gpgme_engine_start): Remove function. --- gpgme/ChangeLog | 52 +++++ gpgme/decrypt.c | 3 - gpgme/delete.c | 41 ++-- gpgme/edit.c | 44 ++-- gpgme/encrypt-sign.c | 44 ++-- gpgme/encrypt.c | 45 ++-- gpgme/engine-backend.h | 1 - gpgme/engine-gpgsm.c | 506 ++++++++++++++++++++--------------------- gpgme/engine.c | 13 -- gpgme/engine.h | 1 - gpgme/export.c | 41 ++-- gpgme/genkey.c | 3 - gpgme/import.c | 46 ++-- gpgme/key.c | 2 + gpgme/keylist.c | 7 - gpgme/rungpg.c | 43 +++- gpgme/sign.c | 54 +++-- gpgme/trustlist.c | 68 +++--- gpgme/verify.c | 2 - 19 files changed, 517 insertions(+), 499 deletions(-) diff --git a/gpgme/ChangeLog b/gpgme/ChangeLog index 040c458..1aec903 100644 --- a/gpgme/ChangeLog +++ b/gpgme/ChangeLog @@ -1,3 +1,55 @@ +2003-01-19 Marcus Brinkmann + + * rungpg.c (_gpgme_engine_ops_gpg): Remove gpg_start. + (gpg_start): Rename to ... + (start): ... this function. Change arguments to GpgObject. + (gpg_decrypt): Call start. + (gpg_edit): Likewise. + (gpg_encrypt): Likewise. + (gpg_encrypt_sign): Likewise. + (gpg_export): Likewise. + (gpg_import): Likewise. + (gpg_keylist): Likewise. + (gpg_keylist_ext): Likewise. + (gpg_trustlist): Likewise. + (gpg_verify): Likewise. + + * engine-gpgsm.c (_gpgme_engine_ops_encrypt): Remove gpgsm_start. + (gpgsm_start): Rename to ... + (struct gpgsm_object_s): Remove member command. + (gpgsm_release): Don't free command. + (start): ... this function. Change arguments to GpgsmObject and + const char *. + (gpgsm_decrypt): Call start. + (gpgsm_delete): Likewise. + (gpgsm_encrypt): Likewise. + (gpgsm_export): Likewise. + (gpgsm_genkey): Likewise. + (gpgsm_import): Likewise. + (gpgsm_keylist): Likewise. + (gpgsm_keylist_ext): Likewise. + (gpgsm_verify): Likewise. + + * decrypt.c (_gpgme_decrypt_start): Don't call + _gpgme_engine_start. + * delete.c (_gpgme_op_delete_start): Likewise. + * edit.c (_gpgme_op_edit_start): Likewise. + * encrypt.c (_gpgme_op_encrypt_start): + * encrypt-sign.c (_gpgme_op_encrypt_sign_start): + * export.c (_gpgme_op_export_start): Likewise. + * genkey.c (_gpgme_op_genkey_start): Likewise. + * import.c (_gpgme_op_import_start): Likewise. + * keylist.c (gpgme_op_keylist_ext_start): Likewise. + (gpgme_op_keylist_start): Likewise. + * sign.c (_gpgme_op_sign_start): Likewise. + * trustlist.c (gpgme_op_trustlist_start): Likewise. + * verify.c (_gpgme_op_verify_start): Likewise. + + * engine-backend.h (struct engine_ops): Remove member start. + + * engine.h (_gpgme_engine_start): Remove prototype. + * engine.c (_gpgme_engine_start): Remove function. + 2003-01-06 Werner Koch * keylist.c (set_mainkey_capability): Handle 'd' and 'D' used diff --git a/gpgme/decrypt.c b/gpgme/decrypt.c index 96fbc21..7438b37 100644 --- a/gpgme/decrypt.c +++ b/gpgme/decrypt.c @@ -192,9 +192,6 @@ _gpgme_decrypt_start (GpgmeCtx ctx, int synchronous, err = _gpgme_engine_op_decrypt (ctx->engine, ciph, plain); - if (!err) /* And kick off the process. */ - err = _gpgme_engine_start (ctx->engine, ctx); - leave: if (err) { diff --git a/gpgme/delete.c b/gpgme/delete.c index 33b83e1..a3ed47c 100644 --- a/gpgme/delete.c +++ b/gpgme/delete.c @@ -1,24 +1,25 @@ /* delete.c - delete a key - * Copyright (C) 2001, 2002 g10 Code GmbH - * - * This file is part of GPGME. - * - * GPGME is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * GPGME is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - */ - + Copyright (C) 2001, 2002 g10 Code GmbH + + This file is part of GPGME. + + GPGME is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + GPGME is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GPGME; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#if HAVE_CONFIG_H #include +#endif #include #include #include @@ -108,8 +109,6 @@ _gpgme_op_delete_start (GpgmeCtx ctx, int synchronous, _gpgme_engine_set_verbosity (ctx->engine, ctx->verbosity); err = _gpgme_engine_op_delete (ctx->engine, key, allow_secret); - if (!err) - err = _gpgme_engine_start (ctx->engine, ctx); leave: if (err) diff --git a/gpgme/edit.c b/gpgme/edit.c index 2c74b98..a12486c 100644 --- a/gpgme/edit.c +++ b/gpgme/edit.c @@ -1,24 +1,25 @@ /* edit.c - key edit functions - * Copyright (C) 2002 g10 Code GmbH - * - * This file is part of GPGME. - * - * GPGME is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * GPGME is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - */ - + Copyright (C) 2002 g10 Code GmbH + + This file is part of GPGME. + + GPGME is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + GPGME is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GPGME; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#if HAVE_CONFIG_H #include +#endif #include #include #include @@ -110,11 +111,8 @@ _gpgme_op_edit_start (GpgmeCtx ctx, int synchronous, _gpgme_engine_set_verbosity (ctx->engine, ctx->verbosity); - _gpgme_engine_op_edit (ctx->engine, key, out, ctx); + err = _gpgme_engine_op_edit (ctx->engine, key, out, ctx); - /* And kick off the process. */ - err = _gpgme_engine_start (ctx->engine, ctx); - leave: if (err) { diff --git a/gpgme/encrypt-sign.c b/gpgme/encrypt-sign.c index 43bd1dc..2ce43f0 100644 --- a/gpgme/encrypt-sign.c +++ b/gpgme/encrypt-sign.c @@ -1,25 +1,24 @@ /* encrypt-sign.c - encrypt and verify functions - * Copyright (C) 2000 Werner Koch (dd9jn) - * Copyright (C) 2001, 2002 g10 Code GmbH - * - * This file is part of GPGME. - * - * GPGME is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * GPGME is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - */ - -#ifdef HAVE_CONFIG_H + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002 g10 Code GmbH + + This file is part of GPGME. + + GPGME is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + GPGME is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GPGME; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#if HAVE_CONFIG_H #include #endif #include @@ -75,9 +74,6 @@ _gpgme_op_encrypt_sign_start (GpgmeCtx ctx, int synchronous, err = _gpgme_engine_op_encrypt_sign (ctx->engine, recp, plain, cipher, ctx->use_armor, ctx /* FIXME */); - if (!err) /* And kick off the process. */ - err = _gpgme_engine_start (ctx->engine, ctx); - leave: if (err) { diff --git a/gpgme/encrypt.c b/gpgme/encrypt.c index 8ed0202..03131fa 100644 --- a/gpgme/encrypt.c +++ b/gpgme/encrypt.c @@ -1,25 +1,26 @@ /* encrypt.c - encrypt functions - * Copyright (C) 2000 Werner Koch (dd9jn) - * Copyright (C) 2001, 2002 g10 Code GmbH - * - * This file is part of GPGME. - * - * GPGME is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * GPGME is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - */ - + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002 g10 Code GmbH + + This file is part of GPGME. + + GPGME is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + GPGME is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GPGME; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#if HAVE_CONFIG_H #include +#endif #include #include #include @@ -203,10 +204,6 @@ _gpgme_op_encrypt_start (GpgmeCtx ctx, int synchronous, err = _gpgme_engine_op_encrypt (ctx->engine, recp, plain, ciph, ctx->use_armor); - - if (!err) /* And kick off the process. */ - err = _gpgme_engine_start (ctx->engine, ctx); - leave: if (err) { diff --git a/gpgme/engine-backend.h b/gpgme/engine-backend.h index 70c2c03..4d4b800 100644 --- a/gpgme/engine-backend.h +++ b/gpgme/engine-backend.h @@ -72,7 +72,6 @@ struct engine_ops GpgmeError (*trustlist) (void *engine, const char *pattern); GpgmeError (*verify) (void *engine, GpgmeData sig, GpgmeData signed_text, GpgmeData plaintext); - GpgmeError (*start) (void *engine, void *opaque); void (*set_io_cbs) (void *engine, struct GpgmeIOCbs *io_cbs); void (*io_event) (void *engine, GpgmeEventIO type, void *type_data); diff --git a/gpgme/engine-gpgsm.c b/gpgme/engine-gpgsm.c index 545d26a..6b29de7 100644 --- a/gpgme/engine-gpgsm.c +++ b/gpgme/engine-gpgsm.c @@ -75,8 +75,6 @@ struct gpgsm_object_s iocb_data_t message_cb; int message_fd_server; - char *command; - struct { GpgmeStatusHandler fnc; @@ -294,7 +292,6 @@ gpgsm_release (void *engine) assuan_disconnect (gpgsm->assuan_ctx); free (gpgsm->colon.attic.line); - free (gpgsm->command); free (gpgsm); } @@ -659,6 +656,217 @@ map_input_enc (GpgmeData d) } +static int +status_cmp (const void *ap, const void *bp) +{ + const struct status_table_s *a = ap; + const struct status_table_s *b = bp; + + return strcmp (a->name, b->name); +} + + +static GpgmeStatusCode +parse_status (const char *name) +{ + struct status_table_s t, *r; + t.name = name; + r = bsearch (&t, status_table, DIM(status_table) - 1, + sizeof t, status_cmp); + return r ? r->code : -1; +} + + +static void +status_handler (void *opaque, int fd) +{ + AssuanError err; + GpgsmObject gpgsm = opaque; + char *line; + size_t linelen; + + do + { + err = assuan_read_line (gpgsm->assuan_ctx, &line, &linelen); + + if (err + || (linelen >= 2 + && line[0] == 'O' && line[1] == 'K' + && (line[2] == '\0' || line[2] == ' ')) + || (linelen >= 3 + && line[0] == 'E' && line[1] == 'R' && line[2] == 'R' + && (line[3] == '\0' || line[3] == ' '))) + { + /* XXX: If an error occured, find out what happened, then + save the error value before running the status handler + (so it takes precedence). */ + if (!err && line[0] == 'E' && line[3] == ' ') + { + err = map_assuan_error (atoi (&line[4])); + if (!err) + err = mk_error (General_Error); + } + if (err) + { + /* XXX Kludge ahead. We really, really, really must not + make use of status.fnc_value. */ + GpgmeCtx ctx = (GpgmeCtx) gpgsm->status.fnc_value; + if (!ctx->error) + ctx->error = err; + } + + if (gpgsm->status.fnc) + gpgsm->status.fnc (gpgsm->status.fnc_value, GPGME_STATUS_EOF, ""); + if (gpgsm->colon.fnc && gpgsm->colon.any ) + { + /* We must tell a colon fucntion about the EOF. We do + this only when we have seen any data lines. Note + that this inlined use of colon data lines will + eventually be changed into using a regular data + channel. */ + gpgsm->colon.any = 0; + gpgsm->colon.fnc (gpgsm->colon.fnc_value, NULL); + } + + /* XXX: Try our best to terminate the connection. */ + if (err) + assuan_write_line (gpgsm->assuan_ctx, "BYE"); + + _gpgme_io_close (gpgsm->status_cb.fd); + return; + } + + if (linelen > 2 + && line[0] == 'D' && line[1] == ' ' + && gpgsm->colon.fnc) + { + /* We are using the colon handler even for plain inline data + - strange name for that function but for historic reasons + we keep it. */ + /* FIXME We can't use this for binary data because we + assume this is a string. For the current usage of colon + output it is correct. */ + unsigned char *src = line + 2; + unsigned char *end = line + linelen; + unsigned char *dst; + unsigned char **aline = &gpgsm->colon.attic.line; + int *alinelen = &gpgsm->colon.attic.linelen; + + if (gpgsm->colon.attic.linesize + < *alinelen + linelen + 1) + { + unsigned char *newline = realloc (*aline, + *alinelen + linelen + 1); + if (!newline) + { + _gpgme_io_close (gpgsm->status_cb.fd); + return; + } + *aline = newline; + gpgsm->colon.attic.linesize += linelen + 1; + } + + dst = *aline + *alinelen; + + while (src < end) + { + if (*src == '%' && src + 2 < end) + { + /* Handle escaped characters. */ + ++src; + *dst = xtoi_2 (src); + (*alinelen)++; + src += 2; + } + else + { + *dst = *src++; + (*alinelen)++; + } + + if (*dst == '\n') + { + /* Terminate the pending line, pass it to the colon + handler and reset it. */ + + gpgsm->colon.any = 1; + if (*alinelen > 1 && *(dst - 1) == '\r') + dst--; + *dst = '\0'; + + /* FIXME How should we handle the return code? */ + gpgsm->colon.fnc (gpgsm->colon.fnc_value, *aline); + dst = *aline; + *alinelen = 0; + } + else + dst++; + } + } + else if (linelen > 2 + && line[0] == 'S' && line[1] == ' ') + { + char *rest; + GpgmeStatusCode r; + + rest = strchr (line + 2, ' '); + if (!rest) + rest = line + linelen; /* set to an empty string */ + else + *(rest++) = 0; + + r = parse_status (line + 2); + + if (r >= 0) + { + if (gpgsm->status.fnc) + gpgsm->status.fnc (gpgsm->status.fnc_value, r, rest); + } + else + fprintf (stderr, "[UNKNOWN STATUS]%s %s", line + 2, rest); + } + } + while (assuan_pending_line (gpgsm->assuan_ctx)); +} + + +static GpgmeError +add_io_cb (GpgsmObject gpgsm, iocb_data_t *iocbd, GpgmeIOCb handler) +{ + GpgmeError err; + + err = (*gpgsm->io_cbs.add) (gpgsm->io_cbs.add_priv, + iocbd->fd, iocbd->dir, + handler, iocbd->data, &iocbd->tag); + if (err) + return err; + if (!iocbd->dir) + /* FIXME Kludge around poll() problem. */ + err = _gpgme_io_set_nonblocking (iocbd->fd); + return err; +} + + +static GpgmeError +start (GpgsmObject gpgsm, const char *command) +{ + GpgmeError err = 0; + + err = add_io_cb (gpgsm, &gpgsm->status_cb, status_handler); + if (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 && gpgsm->message_cb.fd != -1) + err = add_io_cb (gpgsm, &gpgsm->message_cb, _gpgme_data_outbound_handler); + + if (!err) + err = assuan_write_line (gpgsm->assuan_ctx, command); + + return err; +} + + static GpgmeError gpgsm_decrypt (void *engine, GpgmeData ciph, GpgmeData plain) { @@ -668,10 +876,6 @@ gpgsm_decrypt (void *engine, GpgmeData ciph, GpgmeData plain) if (!gpgsm) return mk_error (Invalid_Value); - gpgsm->command = strdup ("DECRYPT"); - if (!gpgsm->command) - return mk_error (Out_Of_Core); - gpgsm->input_cb.data = ciph; err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server, map_input_enc (gpgsm->input_cb.data)); @@ -683,7 +887,8 @@ gpgsm_decrypt (void *engine, GpgmeData ciph, GpgmeData plain) return mk_error (General_Error); /* FIXME */ _gpgme_io_close (gpgsm->message_cb.fd); - return 0; + err = start (engine, "DECRYPT"); + return err; } @@ -691,6 +896,7 @@ static GpgmeError gpgsm_delete (void *engine, GpgmeKey key, int allow_secret) { GpgsmObject gpgsm = engine; + GpgmeError err; char *fpr = (char *) gpgme_key_get_string_attr (key, GPGME_ATTR_FPR, NULL, 0); char *linep = fpr; char *line; @@ -742,12 +948,14 @@ gpgsm_delete (void *engine, GpgmeKey key, int allow_secret) } *linep = '\0'; - gpgsm->command = line; _gpgme_io_close (gpgsm->output_cb.fd); _gpgme_io_close (gpgsm->input_cb.fd); _gpgme_io_close (gpgsm->message_cb.fd); - return 0; + err = start (gpgsm, line); + free (line); + + return err; } @@ -811,10 +1019,6 @@ gpgsm_encrypt (void *engine, GpgmeRecipients recp, GpgmeData plain, if (!recp) return mk_error (Not_Implemented); - gpgsm->command = strdup ("ENCRYPT"); - if (!gpgsm->command) - return mk_error (Out_Of_Core); - gpgsm->input_cb.data = plain; err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server, map_input_enc (gpgsm->input_cb.data)); @@ -828,10 +1032,11 @@ gpgsm_encrypt (void *engine, GpgmeRecipients recp, GpgmeData plain, _gpgme_io_close (gpgsm->message_cb.fd); err = set_recipients (gpgsm, recp); - if (err) - return err; - return 0; + if (!err) + err = start (gpgsm, "ENCRYPT"); + + return err; } @@ -885,8 +1090,6 @@ gpgsm_export (void *engine, GpgmeRecipients recp, GpgmeData keydata, return err; } - gpgsm->command = cmd; - gpgsm->output_cb.data = keydata; err = gpgsm_set_fd (gpgsm->assuan_ctx, "OUTPUT", gpgsm->output_fd_server, use_armor ? "--armor" : 0); @@ -895,7 +1098,9 @@ gpgsm_export (void *engine, GpgmeRecipients recp, GpgmeData keydata, _gpgme_io_close (gpgsm->input_cb.fd); _gpgme_io_close (gpgsm->message_cb.fd); - return 0; + err = start (gpgsm, cmd); + free (cmd); + return err; } @@ -909,10 +1114,6 @@ gpgsm_genkey (void *engine, GpgmeData help_data, int use_armor, if (!gpgsm || !pubkey || seckey) return mk_error (Invalid_Value); - gpgsm->command = strdup ("GENKEY"); - if (!gpgsm->command) - return mk_error (Out_Of_Core); - gpgsm->input_cb.data = help_data; err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server, map_input_enc (gpgsm->input_cb.data)); @@ -925,7 +1126,8 @@ gpgsm_genkey (void *engine, GpgmeData help_data, int use_armor, return err; _gpgme_io_close (gpgsm->message_cb.fd); - return 0; + err = start (gpgsm, "GENKEY"); + return err; } @@ -938,10 +1140,6 @@ gpgsm_import (void *engine, GpgmeData keydata) if (!gpgsm) return mk_error (Invalid_Value); - gpgsm->command = strdup ("IMPORT"); - if (!gpgsm->command) - return mk_error (Out_Of_Core); - gpgsm->input_cb.data = keydata; err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server, map_input_enc (gpgsm->input_cb.data)); @@ -950,7 +1148,8 @@ gpgsm_import (void *engine, GpgmeData keydata) _gpgme_io_close (gpgsm->output_cb.fd); _gpgme_io_close (gpgsm->message_cb.fd); - return 0; + err = start (gpgsm, "IMPORT"); + return err; } @@ -991,8 +1190,9 @@ gpgsm_keylist (void *engine, const char *pattern, int secret_only, _gpgme_io_close (gpgsm->output_cb.fd); _gpgme_io_close (gpgsm->message_cb.fd); - gpgsm->command = line; - return 0; + err = start (gpgsm, line); + free (line); + return err; } @@ -1091,8 +1291,9 @@ gpgsm_keylist_ext (void *engine, const char *pattern[], int secret_only, _gpgme_io_close (gpgsm->output_cb.fd); _gpgme_io_close (gpgsm->message_cb.fd); - gpgsm->command = line; - return 0; + err = start (gpgsm, line); + free (line); + return err; } @@ -1110,11 +1311,6 @@ gpgsm_sign (void *engine, GpgmeData in, GpgmeData out, GpgmeSigMode mode, if (!gpgsm) return mk_error (Invalid_Value); - gpgsm->command = strdup (mode == GPGME_SIG_MODE_DETACH - ? "SIGN --detached" : "SIGN"); - if (!gpgsm->command) - return mk_error (Out_Of_Core); - if (asprintf (&assuan_cmd, "OPTION include-certs %i", include_certs) < 0) return mk_error (Out_Of_Core); err = gpgsm_assuan_simple_command (gpgsm->assuan_ctx, assuan_cmd, NULL,NULL); @@ -1159,7 +1355,9 @@ gpgsm_sign (void *engine, GpgmeData in, GpgmeData out, GpgmeSigMode mode, return err; _gpgme_io_close (gpgsm->message_cb.fd); - return 0; + err = start (gpgsm, mode == GPGME_SIG_MODE_DETACH + ? "SIGN --detached" : "SIGN"); + return err; } @@ -1181,10 +1379,6 @@ gpgsm_verify (void *engine, GpgmeData sig, GpgmeData signed_text, if (!gpgsm) return mk_error (Invalid_Value); - gpgsm->command = strdup ("VERIFY"); - if (!gpgsm->command) - return mk_error (Out_Of_Core); - gpgsm->input_cb.data = sig; err = gpgsm_set_fd (gpgsm->assuan_ctx, "INPUT", gpgsm->input_fd_server, map_input_enc (gpgsm->input_cb.data)); @@ -1206,184 +1400,11 @@ gpgsm_verify (void *engine, GpgmeData sig, GpgmeData signed_text, gpgsm->message_fd_server, 0); _gpgme_io_close (gpgsm->output_cb.fd); } - if (err) - return err; - - return 0; -} - - -static int -status_cmp (const void *ap, const void *bp) -{ - const struct status_table_s *a = ap; - const struct status_table_s *b = bp; - - return strcmp (a->name, b->name); -} - - -static GpgmeStatusCode -parse_status (const char *name) -{ - struct status_table_s t, *r; - t.name = name; - r = bsearch (&t, status_table, DIM(status_table) - 1, - sizeof t, status_cmp); - return r ? r->code : -1; -} - - -static void -status_handler (void *opaque, int fd) -{ - AssuanError err; - GpgsmObject gpgsm = opaque; - char *line; - size_t linelen; - - do - { - err = assuan_read_line (gpgsm->assuan_ctx, &line, &linelen); - - if (err - || (linelen >= 2 - && line[0] == 'O' && line[1] == 'K' - && (line[2] == '\0' || line[2] == ' ')) - || (linelen >= 3 - && line[0] == 'E' && line[1] == 'R' && line[2] == 'R' - && (line[3] == '\0' || line[3] == ' '))) - { - /* XXX: If an error occured, find out what happened, then - save the error value before running the status handler - (so it takes precedence). */ - if (!err && line[0] == 'E' && line[3] == ' ') - { - err = map_assuan_error (atoi (&line[4])); - if (!err) - err = mk_error (General_Error); - } - if (err) - { - /* XXX Kludge ahead. We really, really, really must not - make use of status.fnc_value. */ - GpgmeCtx ctx = (GpgmeCtx) gpgsm->status.fnc_value; - if (!ctx->error) - ctx->error = err; - } - - if (gpgsm->status.fnc) - gpgsm->status.fnc (gpgsm->status.fnc_value, GPGME_STATUS_EOF, ""); - if (gpgsm->colon.fnc && gpgsm->colon.any ) - { - /* We must tell a colon fucntion about the EOF. We do - this only when we have seen any data lines. Note - that this inlined use of colon data lines will - eventually be changed into using a regular data - channel. */ - gpgsm->colon.any = 0; - gpgsm->colon.fnc (gpgsm->colon.fnc_value, NULL); - } - - /* XXX: Try our best to terminate the connection. */ - if (err) - assuan_write_line (gpgsm->assuan_ctx, "BYE"); - - _gpgme_io_close (gpgsm->status_cb.fd); - return; - } - - if (linelen > 2 - && line[0] == 'D' && line[1] == ' ' - && gpgsm->colon.fnc) - { - /* We are using the colon handler even for plain inline data - - strange name for that function but for historic reasons - we keep it. */ - /* FIXME We can't use this for binary data because we - assume this is a string. For the current usage of colon - output it is correct. */ - unsigned char *src = line + 2; - unsigned char *end = line + linelen; - unsigned char *dst; - unsigned char **aline = &gpgsm->colon.attic.line; - int *alinelen = &gpgsm->colon.attic.linelen; - - if (gpgsm->colon.attic.linesize - < *alinelen + linelen + 1) - { - unsigned char *newline = realloc (*aline, - *alinelen + linelen + 1); - if (!newline) - { - _gpgme_io_close (gpgsm->status_cb.fd); - return; - } - *aline = newline; - gpgsm->colon.attic.linesize += linelen + 1; - } - dst = *aline + *alinelen; - - while (src < end) - { - if (*src == '%' && src + 2 < end) - { - /* Handle escaped characters. */ - ++src; - *dst = xtoi_2 (src); - (*alinelen)++; - src += 2; - } - else - { - *dst = *src++; - (*alinelen)++; - } - - if (*dst == '\n') - { - /* Terminate the pending line, pass it to the colon - handler and reset it. */ - - gpgsm->colon.any = 1; - if (*alinelen > 1 && *(dst - 1) == '\r') - dst--; - *dst = '\0'; - - /* FIXME How should we handle the return code? */ - gpgsm->colon.fnc (gpgsm->colon.fnc_value, *aline); - dst = *aline; - *alinelen = 0; - } - else - dst++; - } - } - else if (linelen > 2 - && line[0] == 'S' && line[1] == ' ') - { - char *rest; - GpgmeStatusCode r; - - rest = strchr (line + 2, ' '); - if (!rest) - rest = line + linelen; /* set to an empty string */ - else - *(rest++) = 0; - - r = parse_status (line + 2); + if (!err) + err = start (gpgsm, "VERIFY"); - if (r >= 0) - { - if (gpgsm->status.fnc) - gpgsm->status.fnc (gpgsm->status.fnc_value, r, rest); - } - else - fprintf (stderr, "[UNKNOWN STATUS]%s %s", line + 2, rest); - } - } - while (assuan_pending_line (gpgsm->assuan_ctx)); + return err; } @@ -1411,50 +1432,6 @@ gpgsm_set_colon_line_handler (void *engine, GpgmeColonLineHandler fnc, } -static GpgmeError -add_io_cb (GpgsmObject gpgsm, iocb_data_t *iocbd, GpgmeIOCb handler) -{ - GpgmeError err; - - err = (*gpgsm->io_cbs.add) (gpgsm->io_cbs.add_priv, - iocbd->fd, iocbd->dir, - handler, iocbd->data, &iocbd->tag); - if (err) - return err; - if (!iocbd->dir) - /* FIXME Kludge around poll() problem. */ - err = _gpgme_io_set_nonblocking (iocbd->fd); - return err; -} - - -static GpgmeError -gpgsm_start (void *engine, void *opaque) -{ - GpgsmObject gpgsm = engine; - GpgmeError err = 0; - pid_t pid; - - if (!gpgsm) - return mk_error (Invalid_Value); - - pid = assuan_get_pid (gpgsm->assuan_ctx); - - err = add_io_cb (gpgsm, &gpgsm->status_cb, status_handler); - if (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 && gpgsm->message_cb.fd != -1) - err = add_io_cb (gpgsm, &gpgsm->message_cb, _gpgme_data_outbound_handler); - - if (!err) - err = assuan_write_line (gpgsm->assuan_ctx, gpgsm->command); - - return err; -} - - static void gpgsm_set_io_cbs (void *engine, struct GpgmeIOCbs *io_cbs) { @@ -1500,7 +1477,6 @@ struct engine_ops _gpgme_engine_ops_gpgsm = gpgsm_sign, gpgsm_trustlist, gpgsm_verify, - gpgsm_start, gpgsm_set_io_cbs, gpgsm_io_event }; diff --git a/gpgme/engine.c b/gpgme/engine.c index eb87eab..e96af13 100644 --- a/gpgme/engine.c +++ b/gpgme/engine.c @@ -426,19 +426,6 @@ _gpgme_engine_op_verify (EngineObject engine, GpgmeData sig, } -GpgmeError -_gpgme_engine_start (EngineObject engine, void *opaque) -{ - if (!engine) - return mk_error (Invalid_Value); - - if (!engine->ops->start) - return mk_error (Not_Implemented); - - return (*engine->ops->start) (engine->engine, opaque); -} - - void _gpgme_engine_set_io_cbs (EngineObject engine, struct GpgmeIOCbs *io_cbs) diff --git a/gpgme/engine.h b/gpgme/engine.h index 27fc5ac..54af330 100644 --- a/gpgme/engine.h +++ b/gpgme/engine.h @@ -81,7 +81,6 @@ GpgmeError _gpgme_engine_op_trustlist (EngineObject engine, const char *pattern); GpgmeError _gpgme_engine_op_verify (EngineObject engine, GpgmeData sig, GpgmeData signed_text, GpgmeData plaintext); -GpgmeError _gpgme_engine_start (EngineObject engine, void *opaque); void _gpgme_engine_set_io_cbs (EngineObject engine, struct GpgmeIOCbs *io_cbs); diff --git a/gpgme/export.c b/gpgme/export.c index ad4984d..93cd098 100644 --- a/gpgme/export.c +++ b/gpgme/export.c @@ -1,25 +1,26 @@ /* export.c - encrypt functions - * Copyright (C) 2000 Werner Koch (dd9jn) - * Copyright (C) 2001, 2002 g10 Code GmbH - * - * This file is part of GPGME. - * - * GPGME is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * GPGME is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - */ + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002 g10 Code GmbH + This file is part of GPGME. + + GPGME is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + GPGME is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GPGME; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#if HAVE_CONFIG_H #include +#endif #include #include #include @@ -61,8 +62,6 @@ _gpgme_op_export_start (GpgmeCtx ctx, int synchronous, _gpgme_engine_set_verbosity (ctx->engine, ctx->verbosity); err = _gpgme_engine_op_export (ctx->engine, recp, keydata, ctx->use_armor); - if (!err) - err = _gpgme_engine_start (ctx->engine, ctx); leave: if (err) diff --git a/gpgme/genkey.c b/gpgme/genkey.c index b4e6708..a4633da 100644 --- a/gpgme/genkey.c +++ b/gpgme/genkey.c @@ -130,9 +130,6 @@ _gpgme_op_genkey_start (GpgmeCtx ctx, int synchronous, const char *parms, err = _gpgme_engine_op_genkey (ctx->engine, ctx->help_data_1, ctx->use_armor, pubkey, seckey); - if (!err) - err = _gpgme_engine_start (ctx->engine, ctx); - leave: if (err) { diff --git a/gpgme/import.c b/gpgme/import.c index f95086a..9776cb7 100644 --- a/gpgme/import.c +++ b/gpgme/import.c @@ -1,25 +1,26 @@ /* import.c - encrypt functions - * Copyright (C) 2000 Werner Koch (dd9jn) - * Copyright (C) 2001, 2002 g10 Code GmbH - * - * This file is part of GPGME. - * - * GPGME is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * GPGME is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - */ - + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002 g10 Code GmbH + + This file is part of GPGME. + + GPGME is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + GPGME is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GPGME; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#if HAVE_CONFIG_H #include +#endif #include #include #include @@ -195,10 +196,7 @@ _gpgme_op_import_start (GpgmeCtx ctx, int synchronous, GpgmeData keydata) _gpgme_engine_set_status_handler (ctx->engine, import_status_handler, ctx); _gpgme_engine_set_verbosity (ctx->engine, ctx->verbosity); - _gpgme_engine_op_import (ctx->engine, keydata); - - if (!err) - err = _gpgme_engine_start (ctx->engine, ctx); + err = _gpgme_engine_op_import (ctx->engine, keydata); leave: if (err) diff --git a/gpgme/key.c b/gpgme/key.c index 377c714..dcd5771 100644 --- a/gpgme/key.c +++ b/gpgme/key.c @@ -1220,6 +1220,8 @@ gpgme_get_key (GpgmeCtx ctx, const char *fpr, GpgmeKey *r_key, } } + /* We need our own context because we have to avoid the user's I/O + callback handlers. */ /* Fixme: This can be optimized by keeping an internal context used for such key listings. */ err = gpgme_new (&listctx); diff --git a/gpgme/keylist.c b/gpgme/keylist.c index ac6bc4b..ed75341 100644 --- a/gpgme/keylist.c +++ b/gpgme/keylist.c @@ -772,9 +772,6 @@ gpgme_op_keylist_start (GpgmeCtx ctx, const char *pattern, int secret_only) err = _gpgme_engine_op_keylist (ctx->engine, pattern, secret_only, ctx->keylist_mode); - if (!err) /* And kick off the process. */ - err = _gpgme_engine_start (ctx->engine, ctx); - leave: if (err) { @@ -826,10 +823,6 @@ gpgme_op_keylist_ext_start (GpgmeCtx ctx, const char *pattern[], err = _gpgme_engine_op_keylist_ext (ctx->engine, pattern, secret_only, reserved, ctx->keylist_mode); - /* And kick off the process. */ - if (!err) - err = _gpgme_engine_start (ctx->engine, ctx); - leave: if (err) { diff --git a/gpgme/rungpg.c b/gpgme/rungpg.c index 88afaea..7677941 100644 --- a/gpgme/rungpg.c +++ b/gpgme/rungpg.c @@ -1079,9 +1079,8 @@ colon_line_handler (void *opaque, int fd) static GpgmeError -gpg_start (void *engine, void *opaque) +start (GpgObject gpg) { - GpgObject gpg = engine; GpgmeError rc; int i, n; int status; @@ -1223,6 +1222,8 @@ gpg_decrypt (void *engine, GpgmeData ciph, GpgmeData plain) if (!err) err = add_data (gpg, ciph, 0, 0); + if (!err) + start (gpg); return err; } @@ -1245,6 +1246,8 @@ gpg_delete (void *engine, GpgmeKey key, int allow_secret) err = add_arg (gpg, s); } + if (!err) + start (gpg); return err; } @@ -1297,6 +1300,8 @@ gpg_edit (void *engine, GpgmeKey key, GpgmeData out, GpgmeCtx ctx /* FIXME */) else err = add_arg (gpg, s); } + if (!err) + err = start (gpg); return err; } @@ -1357,9 +1362,13 @@ gpg_encrypt (void *engine, GpgmeRecipients recp, GpgmeData plain, if (!err) err = add_data (gpg, plain, 0, 0); + if (!err) + err = start (gpg); + return err; } + static GpgmeError gpg_encrypt_sign (void *engine, GpgmeRecipients recp, GpgmeData plain, GpgmeData ciph, int use_armor, GpgmeCtx ctx /* FIXME */) @@ -1396,9 +1405,13 @@ gpg_encrypt_sign (void *engine, GpgmeRecipients recp, GpgmeData plain, if (!err) err = add_data (gpg, plain, 0, 0); + if (!err) + err = start (gpg); + return err; } + static GpgmeError gpg_export (void *engine, GpgmeRecipients recp, GpgmeData keydata, int use_armor) @@ -1426,6 +1439,9 @@ gpg_export (void *engine, GpgmeRecipients recp, GpgmeData keydata, err = gpgme_recipients_enum_close (recp, &ec); } + if (!err) + err = start (gpg); + return err; } @@ -1453,6 +1469,9 @@ gpg_genkey (void *engine, GpgmeData help_data, int use_armor, if (!err) err = add_data (gpg, help_data, 0, 0); + if (!err) + err = start (gpg); + return err; } @@ -1467,6 +1486,9 @@ gpg_import (void *engine, GpgmeData keydata) if (!err) err = add_data (gpg, keydata, 0, 0); + if (!err) + err = start (gpg); + return err; } @@ -1496,6 +1518,9 @@ gpg_keylist (void *engine, const char *pattern, int secret_only, if (!err && pattern && *pattern) err = add_arg (gpg, pattern); + if (!err) + err = start (gpg); + return err; } @@ -1531,6 +1556,9 @@ gpg_keylist_ext (void *engine, const char *pattern[], int secret_only, err = add_arg (gpg, *(pattern++)); } + if (!err) + err = start (gpg); + return err; } @@ -1565,6 +1593,9 @@ gpg_sign (void *engine, GpgmeData in, GpgmeData out, GpgmeSigMode mode, if (!err) err = add_data (gpg, out, 1, 1); + if (!err) + start (gpg); + return err; } @@ -1584,6 +1615,9 @@ gpg_trustlist (void *engine, const char *pattern) if (!err) err = add_arg (gpg, pattern); + if (!err) + err = start (gpg); + return err; } @@ -1624,6 +1658,10 @@ gpg_verify (void *engine, GpgmeData sig, GpgmeData signed_text, err = add_data (gpg, signed_text, 0, 0); } } + + if (!err) + err = start (gpg); + return err; } @@ -1664,7 +1702,6 @@ struct engine_ops _gpgme_engine_ops_gpg = gpg_sign, gpg_trustlist, gpg_verify, - gpg_start, gpg_set_io_cbs, gpg_io_event }; diff --git a/gpgme/sign.c b/gpgme/sign.c index 58837d9..d45699b 100644 --- a/gpgme/sign.c +++ b/gpgme/sign.c @@ -1,25 +1,26 @@ /* sign.c - signing functions - * Copyright (C) 2000 Werner Koch (dd9jn) - * Copyright (C) 2001, 2002 g10 Code GmbH - * - * This file is part of GPGME. - * - * GPGME is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * GPGME is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - */ + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002 g10 Code GmbH + This file is part of GPGME. + + GPGME is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + GPGME is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GPGME; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#if HAVE_CONFIG_H #include +#endif #include #include #include @@ -52,9 +53,9 @@ _gpgme_release_sign_result (SignResult result) } /* Parse the args and save the information - * - * in an XML structure. With args of NULL the xml structure is closed. - */ + + in an XML structure. With args of NULL the xml structure is + closed. */ static void append_xml_siginfo (GpgmeData *rdh, char *args) { @@ -204,13 +205,10 @@ _gpgme_op_sign_start (GpgmeCtx ctx, int synchronous, ctx); _gpgme_engine_set_verbosity (ctx->engine, ctx->verbosity); - _gpgme_engine_op_sign (ctx->engine, in, out, mode, ctx->use_armor, - ctx->use_textmode, ctx->include_certs, - ctx /* FIXME */); + err = _gpgme_engine_op_sign (ctx->engine, in, out, mode, ctx->use_armor, + ctx->use_textmode, ctx->include_certs, + ctx /* FIXME */); - /* And kick off the process. */ - err = _gpgme_engine_start (ctx->engine, ctx); - leave: if (err) { diff --git a/gpgme/trustlist.c b/gpgme/trustlist.c index 60caa4c..5c4a848 100644 --- a/gpgme/trustlist.c +++ b/gpgme/trustlist.c @@ -1,25 +1,26 @@ /* trustlist.c - key listing - * Copyright (C) 2000 Werner Koch (dd9jn) - * Copyright (C) 2001, 2002 g10 Code GmbH - * - * This file is part of GPGME. - * - * GPGME is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * GPGME is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - */ - + Copyright (C) 2000 Werner Koch (dd9jn) + Copyright (C) 2001, 2002 g10 Code GmbH + + This file is part of GPGME. + + GPGME is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + GPGME is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GPGME; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#if HAVE_CONFIG_H #include +#endif #include #include #include @@ -68,19 +69,17 @@ trustlist_status_handler (GpgmeCtx ctx, GpgmeStatusCode code, char *args) } -/* - * This handler is used to parse the output of --list-trust-path: - * Format: - * level:keyid:type:recno:ot:val:mc:cc:name: - * With TYPE = U for a user ID - * K for a key - * The RECNO is either the one of the dir record or the one of the uid record. - * OT is the the usual trust letter and only availabel on K lines. - * VAL is the calcualted validity - * MC is the marginal trust counter and only available on U lines - * CC is the same for the complete count - * NAME ist the username and only printed on U lines - */ +/* This handler is used to parse the output of --list-trust-path: + Format: + level:keyid:type:recno:ot:val:mc:cc:name: + With TYPE = U for a user ID + K for a key + The RECNO is either the one of the dir record or the one of the uid + record. OT is the the usual trust letter and only availabel on K + lines. VAL is the calcualted validity MC is the marginal trust + counter and only available on U lines CC is the same for the + complete count NAME ist the username and only printed on U + lines. */ static void trustlist_colon_handler (GpgmeCtx ctx, char *line) { @@ -193,9 +192,6 @@ gpgme_op_trustlist_start (GpgmeCtx ctx, const char *pattern, int max_level) err =_gpgme_engine_op_trustlist (ctx->engine, pattern); - if (!err) /* And kick off the process. */ - err = _gpgme_engine_start (ctx->engine, ctx); - leave: if (err) { diff --git a/gpgme/verify.c b/gpgme/verify.c index b3d7314..a510d39 100644 --- a/gpgme/verify.c +++ b/gpgme/verify.c @@ -384,8 +384,6 @@ _gpgme_op_verify_start (GpgmeCtx ctx, int synchronous, goto leave; } err = _gpgme_engine_op_verify (ctx->engine, sig, signed_text, plaintext); - if (!err) /* And kick off the process. */ - err = _gpgme_engine_start (ctx->engine, ctx); leave: if (err) -- 2.26.2