2000-11-07 13:32:38 +00:00
|
|
|
/* ops.h - internal operations stuff
|
|
|
|
* Copyright (C) 2000 Werner Koch (dd9jn)
|
2002-01-31 00:31:44 +00:00
|
|
|
* Copyright (C) 2001, 2002 g10 Code GmbH
|
2000-11-07 13:32:38 +00:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef OPS_H
|
|
|
|
#define OPS_H
|
|
|
|
|
|
|
|
#include "types.h"
|
2001-11-16 00:20:11 +00:00
|
|
|
#include "rungpg.h"
|
2000-11-07 13:32:38 +00:00
|
|
|
|
2002-02-02 Marcus Brinkmann <marcus@g10code.de>
This patch has gotten a bit large... mmh. The main thing that
happens here is that error values are now not determined in the
operation function after gpgme_wait completed, but in the status
handler when EOF is received. It should always be the case that
either an error is flagged or EOF is received, so that after a
gpgme_wait you should never have the situation that no error is
flagged and EOF is not received. One problem is that the engine
status handlers don't have access to the context, a horrible
kludge works around this for now. All errors that happen during a
pending operation should be catched and reported in ctx->error,
including out-of-core and cancellation. This rounds up neatly a
couple of loose ends, and makes it possible to pass up any errors
in the communication with the backend as well. As a bonus, there
will be a function to access gpgme->wait, so that the operations
can truly be implemented with their _start function.
* engine-gpgsm.c (gpgsm_status_handler): Horrible kludge to report
error back to the context.
* rungpg.c (gpg_status_handler): Same horrible kludge applied here.
* engine-gpgsm.c (gpgsm_assuan_simple_command): Add error checking.
* wait.c (_gpgme_wait_on_condition): If canceled, set CTX->error
to a value indication that.
* verify.c (add_notation): Set error, not out_of_core.
(finish_sig): Likewise.
(gpgme_op_verify_start): Don't clear out_of_core.
(_gpgme_verify_status_handler): At EOF, clean up the notation data.
(gpgme_op_verify): And don't do it here.
* trustlist.c (trustlist_status_handler): Check error, not out_of_core.
(gpgme_op_trustlist_start): Don't clear out_of_core.
(gpgme_op_trustlist_next): Check error, not out_of_core.
(gpgme_op_trustlist_end): Likewise.
* ops.h (test_and_allocate_result): New macro.
(_gpgme_passphrase_result): Remove prototype.
* delete.c (gpgme_op_delete): Return error from context.
(delete_status_handler): Use macro test_and_allocate_result.
Perform error checking at EOF.
(gpgme_op_delete_start): Release result.
* passphrase.c (_gpgme_passphrase_status_handler): Use macro
test_and_allocate_result, and perform error checking here.
(_gpgme_passphrase_result): Function removed.
* sign.c (gpgme_op_sign_start): Do not set out_of_core to zero.
(gpgme_op_sign): Just return the error value from the context.
(sign_status_handler): Only progress if no error is set yet. If
we process an EOF, set the resulting error value (if any).
* decrypt.c (_gpgme_decrypt_result): Function removed.
(create_result_struct): Function removed.
(_gpgme_decrypt_status_handler): Use macro test_and_allocate_result,
caclulate error on EOF, do not progress with errors.
(_gpgme_decrypt_start): Do not set out_of_core to zero.
(gpgme_op_decrypt): Just return the error value from the context.
* encrypt.c (encrypt_status_handler): Perform the error checking
here.
(gpgme_op_encrypt_start): Do not clear out_of_core.
* export.c (export_status_handler): Return if error is set in context.
(gpgme_op_export_start): Release result.
(gpgme_op_export): Return error from context.
* decrypt-verify.c (gpgme_op_decrypt_verify): Return the error in
the context.
* genkey.c (genkey_status_handler): Use macro
test_and_allocate_result. Perform error checking at EOF.
(gpgme_op_genkey): Just return the error from context.
* import.c (gpgme_op_import): Return the error from context.
(import_status_handler): Use macro test_and_allocate_result.
* keylist.c (gpgme_op_keylist_start): Do not clear out_of_core.
(gpgme_op_keylist_next): Return error of context.
(keylist_colon_handler): Set error instead out_of_code.
(finish_key): Likewise.
* context.h: Remove member out_of_core, add member error.
* gpgme.c (_gpgme_release_result): Clear error flag.
* engine.h (_gpgme_engine_get_error): New prototype.
* engine.c (_gpgme_engine_get_error): New function.
* engine-gpgsm.c (_gpgme_gpgsm_get_error): New function.
* engine-gpgsm.c (map_assuan_error): New function.
(gpgsm_assuan_simple_command): Change return type to GpgmeError,
use the new function to map error values.
(gpgsm_set_fd): Change return type tp GpgmeError.
(_gpgme_gpgsm_op_decrypt): Change type of ERR to GpgmeError.
(gpgsm_set_recipients): Likewise. Change type of return value
equivalently. Adjust error values.
(_gpgme_gpgsm_op_import): Likewise.
(_gpgme_gpgsm_op_sign): Likewise.
(struct gpgsm_object_s): New member error.
(gpgsm_status_handler): Set error if error occurs. Determine
error number from ERR line received. If assuan_read_line fails,
terminate the connection.
2002-02-02 03:52:59 +00:00
|
|
|
/* Support macros. */
|
|
|
|
|
|
|
|
#define test_and_allocate_result(ctx,field) \
|
|
|
|
do \
|
|
|
|
{ \
|
|
|
|
if (!ctx->result.field) \
|
|
|
|
{ \
|
|
|
|
ctx->result.field = xtrycalloc (1, sizeof *ctx->result.field); \
|
|
|
|
if (!ctx->result.field) \
|
|
|
|
{ \
|
|
|
|
ctx->error = mk_error (Out_Of_Core); \
|
|
|
|
return; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
while (0)
|
|
|
|
|
2000-11-09 16:35:35 +00:00
|
|
|
/*-- gpgme.c --*/
|
|
|
|
void _gpgme_release_result ( GpgmeCtx c );
|
2001-08-28 11:11:10 +00:00
|
|
|
void _gpgme_set_op_info (GpgmeCtx c, GpgmeData info);
|
2000-11-09 16:35:35 +00:00
|
|
|
|
2000-11-10 20:56:02 +00:00
|
|
|
/*-- wait.c --*/
|
|
|
|
GpgmeCtx _gpgme_wait_on_condition ( GpgmeCtx c,
|
|
|
|
int hang, volatile int *cond );
|
2000-12-12 13:31:25 +00:00
|
|
|
void _gpgme_freeze_fd ( int fd );
|
|
|
|
void _gpgme_thaw_fd ( int fd );
|
2000-11-10 20:56:02 +00:00
|
|
|
|
2000-11-07 13:32:38 +00:00
|
|
|
|
|
|
|
/*-- recipient.c --*/
|
2001-01-11 11:56:34 +00:00
|
|
|
int _gpgme_recipients_all_valid ( const GpgmeRecipients rset );
|
2000-11-07 13:32:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*-- data.c --*/
|
2000-11-15 21:36:48 +00:00
|
|
|
char * _gpgme_data_release_and_return_string ( GpgmeData dh );
|
2000-11-13 13:25:22 +00:00
|
|
|
GpgmeDataMode _gpgme_data_get_mode ( GpgmeData dh );
|
|
|
|
void _gpgme_data_set_mode ( GpgmeData dh, GpgmeDataMode mode );
|
2000-11-15 21:36:48 +00:00
|
|
|
char * _gpgme_data_get_as_string ( GpgmeData dh );
|
2000-11-13 13:25:22 +00:00
|
|
|
GpgmeError _gpgme_data_append ( GpgmeData dh,
|
2000-11-09 16:35:35 +00:00
|
|
|
const char *buffer, size_t length );
|
2000-11-15 21:36:48 +00:00
|
|
|
GpgmeError _gpgme_data_append_string ( GpgmeData dh, const char *s );
|
|
|
|
GpgmeError _gpgme_data_append_string_for_xml ( GpgmeData dh,
|
|
|
|
const char *s);
|
|
|
|
GpgmeError _gpgme_data_append_for_xml ( GpgmeData dh,
|
|
|
|
const char *buffer,
|
|
|
|
size_t len );
|
|
|
|
GpgmeError _gpgme_data_append_percentstring_for_xml ( GpgmeData dh,
|
|
|
|
const char *string );
|
|
|
|
|
2000-12-06 12:17:10 +00:00
|
|
|
GpgmeError _gpgme_data_unread (GpgmeData dh,
|
|
|
|
const char *buffer, size_t length );
|
|
|
|
|
2001-11-22 Marcus Brinkmann <marcus@g10code.de>
* rungpg.c (gpg_inbound_handler, write_mem_data, write_cb_data,
gpg_outbound_handler): Moved to ...
* data.c (_gpgme_data_inbound_handler, write_mem_data,
write_cb_data, _gpgme_data_outbound_handler): ... here. Make the
_gpgme_* ones non-static.
* data.c: Include io.h.
* ops.h (_gpgme_data_inbound_handler): New prototype.
(_gpgme_data_outbound_handler): Likewise.
(_gpgme_gpg_spawn): Use these new functions.
* engine-gpgsm.h (_gpgme_gpgsm_op_decrypt, _gpgme_gpgsm_op_delete,
_gpgme_gpgsm_op_encrypt, _gpgme_gpgsm_op_export,
_gpgme_gpgsm_op_genkey, _gpgme_gpgsm_op_import,
_gpgme_gpgsm_op_keylist, _gpgme_gpgsm_op_sign,
_gpgme_gpgsm_op_trustlist, _gpgme_gpgsm_op_verify,
_gpgme_gpgsm_start, _gpgme_gpgsm_set_status_handler): New prototype.
Include <rungpg.h> for status handler function.
* engine-gpgsm.c (struct gpgsm_object_s): New members input_fd,
input_data, output_fd, output_data, message_fd, message_data, command
and status.
(_gpgme_gpgsm_new): Open input, output and message pipes before
connecting to the client. Close server's ends afterwards.
(_gpgme_gpgsm_release): Close open file descriptors. Remove
server process from wait queue.
(_gpgme_gpgsm_op_verify, _gpgme_gpgsm_start,
_gpgme_gpgsm_set_status_handler, gpgms_status_handler): New function.
* engine.c (_gpgme_engine_start): Implement for GPGME_PROTOCOL_CMS.
(_gpgme_engine_set_status_handler): Likewise.
(_gpgme_engine_op_verify): Likewise.
2001-11-22 03:08:58 +00:00
|
|
|
int _gpgme_data_inbound_handler (void *opaque, int pid, int fd);
|
|
|
|
int _gpgme_data_outbound_handler (void *opaque, int pid, int fd);
|
|
|
|
|
2000-11-07 13:32:38 +00:00
|
|
|
|
2000-11-10 17:50:24 +00:00
|
|
|
/*-- key.c --*/
|
2001-01-30 11:01:41 +00:00
|
|
|
GpgmeError _gpgme_key_new ( GpgmeKey *r_key );
|
|
|
|
GpgmeError _gpgme_key_new_secret ( GpgmeKey *r_key );
|
2000-11-10 17:50:24 +00:00
|
|
|
|
|
|
|
|
2000-11-09 16:35:35 +00:00
|
|
|
/*-- verify.c --*/
|
2001-11-16 01:37:06 +00:00
|
|
|
void _gpgme_release_verify_result (VerifyResult result);
|
|
|
|
GpgmeSigStat _gpgme_intersect_stati (VerifyResult result);
|
|
|
|
void _gpgme_verify_status_handler (GpgmeCtx ctx, GpgStatusCode code,
|
|
|
|
char *args);
|
2000-11-07 13:32:38 +00:00
|
|
|
|
2000-11-16 13:15:48 +00:00
|
|
|
/*-- decrypt.c --*/
|
2001-11-16 01:37:06 +00:00
|
|
|
void _gpgme_release_decrypt_result (DecryptResult result);
|
|
|
|
void _gpgme_decrypt_status_handler (GpgmeCtx ctx, GpgStatusCode code,
|
|
|
|
char *args);
|
|
|
|
GpgmeError _gpgme_decrypt_start (GpgmeCtx ctx, GpgmeData ciph, GpgmeData plain,
|
|
|
|
void *status_handler);
|
|
|
|
GpgmeError _gpgme_decrypt_result (GpgmeCtx ctx);
|
2000-11-16 13:15:48 +00:00
|
|
|
|
2000-11-16 14:53:52 +00:00
|
|
|
/*-- sign.c --*/
|
|
|
|
void _gpgme_release_sign_result ( SignResult res );
|
2002-02-26 00:08:09 +00:00
|
|
|
void _gpgme_sign_status_handler (GpgmeCtx ctx, GpgStatusCode code,
|
|
|
|
char *args);
|
2000-11-16 14:53:52 +00:00
|
|
|
|
2001-09-03 18:41:53 +00:00
|
|
|
/*-- encrypt.c --*/
|
|
|
|
void _gpgme_release_encrypt_result ( EncryptResult res );
|
2002-02-26 00:08:09 +00:00
|
|
|
void _gpgme_encrypt_status_handler (GpgmeCtx ctx, GpgStatusCode code,
|
|
|
|
char *args);
|
2001-09-03 18:41:53 +00:00
|
|
|
|
2001-11-16 00:20:11 +00:00
|
|
|
/*-- passphrase.c --*/
|
|
|
|
void _gpgme_release_passphrase_result (PassphraseResult result);
|
|
|
|
void _gpgme_passphrase_status_handler (GpgmeCtx ctx, GpgStatusCode code,
|
|
|
|
char *args);
|
|
|
|
GpgmeError _gpgme_passphrase_start (GpgmeCtx ctx);
|
2000-11-07 13:32:38 +00:00
|
|
|
|
2002-01-31 00:31:44 +00:00
|
|
|
/*-- progress.c --*/
|
|
|
|
void _gpgme_progress_status_handler (GpgmeCtx ctx, GpgStatusCode code,
|
|
|
|
char *args);
|
|
|
|
|
2002-01-30 21:52:32 +00:00
|
|
|
/*-- import.c --*/
|
|
|
|
void _gpgme_release_import_result (ImportResult res);
|
|
|
|
|
2002-01-30 22:45:22 +00:00
|
|
|
/*-- delete.c --*/
|
|
|
|
void _gpgme_release_delete_result (DeleteResult res);
|
|
|
|
|
2002-01-31 00:31:44 +00:00
|
|
|
/*-- genkey.c --*/
|
|
|
|
void _gpgme_release_genkey_result (GenKeyResult res);
|
|
|
|
|
2001-11-20 04:02:38 +00:00
|
|
|
/*-- version.c --*/
|
2001-11-20 06:01:24 +00:00
|
|
|
const char *_gpgme_compare_versions (const char *my_version,
|
|
|
|
const char *req_version);
|
2001-11-20 04:02:38 +00:00
|
|
|
char *_gpgme_get_program_version (const char *const path);
|
|
|
|
|
2002-01-31 00:31:44 +00:00
|
|
|
|
2000-11-07 13:32:38 +00:00
|
|
|
#endif /* OPS_H */
|