doc/
2003-01-29 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (I/O Callback Interface): Document new even
GPGME_EVENT_START.
(Waiting For Completion): Document new possible return values.
(I/O Callback Interface): Document return type of GpgmeIOCb.
gpgme/
2003-01-29 Marcus Brinkmann <marcus@g10code.de>
* context.h (gpgme_context_s): Remove member ERROR.
* types.h (GpgmeStatusHandler): Change return type to GpgmeError.
(GpgmeCommandHandler): Change return type to GpgmeError and add
new argument RESULT.
* gpgme.h (GpgmeIOCb): Change return type to GpgmeError.
(GpgmeEventIO): New event GPGME_EVENT_START.
(GpgmeIdleFunc): Remove type.
(gpgme_register_idle): Remove prototype.
* data.c: Include <assert.h>.
(_gpgme_data_inbound_handler): Change return type to GpgmeError.
Return any error instead ignoring it, don't close file descriptor
on error.
(_gpgme_data_outbound_handler): Likewise.
* decrypt.c: Do not include <stdio.h>, <string.h> and <assert.h>.
(_gpgme_decrypt_status_handler): Change return type to GpgmeError.
Return error instead setting ctx->error. Return success at end of
function.
(gpgme_op_decrypt): Don't work around the old kludge anymore.
* decrypt-verify.c (decrypt_verify_status_handler): Change return
type to GpgmeError. Return possible errors.
* delete.c: Do not include <stdio.h>, <string.h>, <time.h> and
<assert.h>.
(delete_status_handler): Change return type to GpgmeError. Return
error instead setting ctx->error. Return success at end of
function.
* edit.c: Do not include <stdio.h> and <string.h>.
(_gpgme_edit_status_handler): Change type to GpgmeError,
make static and rename to ...
(edit_status_handler): ... this. Return error directly.
(command_handler): Change return type to GpgmeError, add result
argument. Return error directly.
* encrypt.c (status_handler_finish): Remove function.
(_gpgme_encrypt_status_handler): Change return type to GpgmeError.
Return error directly.
(_gpgme_encrypt_sym_status_handler): Likewise.
* encrypt-sign.c (encrypt_sign_status_handler): Likewise.
* engine-gpgsm.c (close_notify_handler): Do not signal done event
anymore.
(status_handler): Change return type to GpgmeError. Diddle things
around a bit to return errors directly.
(start): Send start event.
* export.c: Do not include <stdio.h>, <string.h> and <assert.h>.
(export_status_handler): Change return type to GpgmeError. Don't
check ctx->error.
* genkey.c: Do not include <stdio.h> and <assert.h>.
(genkey_status_handler): Change return type to GpgmeError. Don't
check ctx->error. Return errors directly.
* gpgme.c (_gpgme_release_result): Do not initialize ctx->error.
(_gpgme_op_event_cb): Function removed.
(_gpgme_op_event_cb_user): Likewise.
* import.c: Do not include <stdio.h>, <string.h> and <assert.h>.
(import_status_handler): Change return type to GpgmeError. Don't
check ctx->error.
* keylist.c (keylist_colon_handler, keylist_status_handler, finish_key):
Change return type to GpgmeError, return error directly.
* Makefile (libgpgme_la_SOURCES): Add wait-global.c,
wait-private.c and wait-user.c
* ops.h (test_and_allocate_result): Return error instead setting
ctx->error.
(_gpgme_data_inbound_handler, _gpgme_data_outbound_handler,
_gpgme_verify_status_handler, _gpgme_decrypt_status_handler,
_gpgme_sign_status_handler, _gpgme_encrypt_staus_handler,
_gpgme_passphrase_status_handler, _gpgme_progress_status_handler):
Change return type to GpgmeError.
(_gpgme_passphease_command_handler): Change return type to
GpgmeError and add new argument RESULT.
* op-support.c: Use new callback functions, and change private
data to ctx everywhere.
* passphrase.c (_gpgme_passphrase_status_handler): Change return
type to GpgmeError, return error directly.
(_gpgme_passphrase_command_handler): Change return type to
GpgmeError, add result argument. Return results accordingly.
* progress.c (_gpgme_progress_status_handler): Change return type
to GpgmeError, return errors directly.
* rungpg.c (status_handler): Change return type to GpgmeError.
Return error directly.
(close_notify_handler): Don't send done event.
(colon_line_handler): Change return type to GpgmeError, return
errors directly.
* rungpg.c (start): Send start event.
* sign.c (_gpgme_sign_status_handler): Change return type to
GpgmeError, return errors directly.
* trustlist.c (trustlist_status_handler): Change return type to
GpgmeError. Return 0.
(trustlist_colon_handler): Change return type GpgmeError. Return
errors directly.
* verify.c (add_notation): Change return type to GpgmeError,
return errors directly.
(_gpgme_verify_status_handler): Likewise.
* wait.h (struct fd_table): Remove lock member.
(struct wait_item_s): Moved here from wait.c.
(struct tag): New structure.
(_gpgme_wait_event_cb): Remove prototype.
(_gpgme_wait_private_event_cb, _gpgme_wait_global_event_cb,
_gpgme_wait_user_add_io_cb, _gpgme_wait_user_remove_io_cb,
_gpgme_wait_user_event_io_cb): New prototypes.
* wait.c: Don't include <stdio.h>.
(ftd_global, ctx_done_list, ctx_done_list_size,
ctx_done_list_length, ctx_done_list_lock, idle_function): Remove
global variable.
(gpgme_register_idle, do_select, _gpgme_wait_event_cb): Remove
function.
(gpgme_wait): Move to file wait-global.c.
(_gpgme_add_io_cb): Take ctx as private argument, initialize ctx
member in wait item and tag.
(_gpgme_remove_io_cb): Take ctx from tag. Don't use FDT lock.
(_gpgme_wait_one, _gpgme_wait_on_condition): Move to
wait-private.c.
(gpgme_fd_table_init): Don't initialize FDT->lock.
(gpgme_fd_table_deinit): Don't destroy FDT->lock.
(_gpgme_fd_table_put): Make static and rename to ...
(fd_table_put): ... this function. Don't use FDT->lock.
(struct wait_item_s): Move to wait.h.
* wait-global.c: New file.
* wait-private.c: New file.
* wait-user.c: New file.
2003-01-29 15:20:58 +00:00
|
|
|
|
/* gpgme.c - GnuPG Made Easy.
|
2002-12-04 16:28:34 +00:00
|
|
|
|
Copyright (C) 2000 Werner Koch (dd9jn)
|
2014-04-10 11:01:00 +00:00
|
|
|
|
Copyright (C) 2001, 2002, 2003, 2004, 2005, 2007, 2012,
|
2015-08-30 17:04:44 +00:00
|
|
|
|
2014, 2015 g10 Code GmbH
|
2002-12-04 16:28:34 +00:00
|
|
|
|
|
|
|
|
|
This file is part of GPGME.
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2002-12-04 16:28:34 +00:00
|
|
|
|
GPGME is free software; you can redistribute it and/or modify it
|
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* README: Refer to COPYING.LESSER and "each file" instead of
COPYING.
* COPYING.LESSER: New file.
* gpgme.spec.in (%doc): Add COPYING.LESSER.
* acinclude.m4, configure.ac, Makefile.am: Change license to LGPL
2.1 or later.
* TODO: Add copyright notice.
* README.CVS: Likewise.
assuan/
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* README.1st: Add copyright notice.
doc/
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* Makefile.am: Change license to LGPL.
(gpgme_TEXINFOS): Replace gpl.texi with lesser.texi.
* gpgme.texi: Change license to LGPL (also for documentation of
GPGME's license).
* lesser.texi: New file.
* gpl.texi: File removed.
gpgme/
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* putc_unlocked.c, funopen.c: I just claim copyright on these
files and change their license to LGPL, because they are totally
trivial wrapper functions.
* isascii.c: Change copyright notice to the one from ctype/ctype.h
in the GNU C Library (CVS Head 2004-10-10), where isascii is
defined as a macro doing exactly the same as the function in this
file.
* memrchr.c: Update from the GNU C Library (CVS Head 2001-07-06).
* stpcpy.c: Update from the GNU C Library (CVS Head 2004-10-10).
* ath.c, ath-compat.c, ath.h, ath-pth.c, ath-pth-compat.c,
ath-pthread.c, ath-pthread-compat.c, context.h, conversion.c,
data.c, data-compat.c, data-fd.c, data.h, data-mem.c,
data-stream.c, data-user.c, debug.c, debug.h, decrypt.c,
decrypt-verify.c, delete.c, edit.c, encrypt.c, encrypt-sign.c,
engine-backend.h, engine.c, engine-gpgsm.c, engine.h, error.c,
export.c, genkey.c, get-env.c, gpgme.c, gpgme.h, import.c, io.h,
key.c, keylist.c, mkstatus, Makefile.am, ops.h, op-support.c,
passphrase.c, posix-io.c, posix-sema.c, posix-util.c, progress.c,
rungpg.c, sema.h, sign.c, signers.c, trust-item.c, trustlist.c,
util.h, verify.c, version.c, w32-io.c, w32-sema.c, w32-util.c,
wait.c, wait-global.c, wait.h, wait-private.c, wait-user.c: Change
license to LGPL.
tests/
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* gpg/mkdemodirs: Add copyright notice.
* gpgsm/Makefile.am, gpgsm/t-support.h, gpgsm/t-decrypt.c,
gpgsm/t-encrypt.c, gpgsm/t-export.c, gpgsm/t-genkey.c,
gpgsm/t-import.c, gpgsm/t-keylist.c, gpgsm/t-sign.c,
gpgsm/t-verify.c, gpg/Makefile.am, gpg/t-decrypt.c,
gpg/t-decrypt-verify.c, gpg/t-edit.c, gpg/t-encrypt.c,
gpg/t-encrypt-sign.c, gpg/t-encrypt-sym.c, gpg/t-eventloop.c,
gpg/t-export.c, gpg/t-genkey.c, gpg/t-import.c, gpg/t-keylist.c,
gpg/t-keylist-sig.c, gpg/t-sign.c, gpg/t-signers.c,
gpg/t-support.h, gpg/t-thread1.c, gpg/t-trustlist.c,
gpg/t-verify.c, Makefile.am, t-data.c, t-engine-info.c,
t-version.c: Change license to LGPL.
2004-12-07 21:13:39 +00:00
|
|
|
|
under the terms of the GNU Lesser General Public License as
|
|
|
|
|
published by the Free Software Foundation; either version 2.1 of
|
|
|
|
|
the License, or (at your option) any later version.
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2002-12-04 16:28:34 +00:00
|
|
|
|
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
|
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* README: Refer to COPYING.LESSER and "each file" instead of
COPYING.
* COPYING.LESSER: New file.
* gpgme.spec.in (%doc): Add COPYING.LESSER.
* acinclude.m4, configure.ac, Makefile.am: Change license to LGPL
2.1 or later.
* TODO: Add copyright notice.
* README.CVS: Likewise.
assuan/
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* README.1st: Add copyright notice.
doc/
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* Makefile.am: Change license to LGPL.
(gpgme_TEXINFOS): Replace gpl.texi with lesser.texi.
* gpgme.texi: Change license to LGPL (also for documentation of
GPGME's license).
* lesser.texi: New file.
* gpl.texi: File removed.
gpgme/
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* putc_unlocked.c, funopen.c: I just claim copyright on these
files and change their license to LGPL, because they are totally
trivial wrapper functions.
* isascii.c: Change copyright notice to the one from ctype/ctype.h
in the GNU C Library (CVS Head 2004-10-10), where isascii is
defined as a macro doing exactly the same as the function in this
file.
* memrchr.c: Update from the GNU C Library (CVS Head 2001-07-06).
* stpcpy.c: Update from the GNU C Library (CVS Head 2004-10-10).
* ath.c, ath-compat.c, ath.h, ath-pth.c, ath-pth-compat.c,
ath-pthread.c, ath-pthread-compat.c, context.h, conversion.c,
data.c, data-compat.c, data-fd.c, data.h, data-mem.c,
data-stream.c, data-user.c, debug.c, debug.h, decrypt.c,
decrypt-verify.c, delete.c, edit.c, encrypt.c, encrypt-sign.c,
engine-backend.h, engine.c, engine-gpgsm.c, engine.h, error.c,
export.c, genkey.c, get-env.c, gpgme.c, gpgme.h, import.c, io.h,
key.c, keylist.c, mkstatus, Makefile.am, ops.h, op-support.c,
passphrase.c, posix-io.c, posix-sema.c, posix-util.c, progress.c,
rungpg.c, sema.h, sign.c, signers.c, trust-item.c, trustlist.c,
util.h, verify.c, version.c, w32-io.c, w32-sema.c, w32-util.c,
wait.c, wait-global.c, wait.h, wait-private.c, wait-user.c: Change
license to LGPL.
tests/
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* gpg/mkdemodirs: Add copyright notice.
* gpgsm/Makefile.am, gpgsm/t-support.h, gpgsm/t-decrypt.c,
gpgsm/t-encrypt.c, gpgsm/t-export.c, gpgsm/t-genkey.c,
gpgsm/t-import.c, gpgsm/t-keylist.c, gpgsm/t-sign.c,
gpgsm/t-verify.c, gpg/Makefile.am, gpg/t-decrypt.c,
gpg/t-decrypt-verify.c, gpg/t-edit.c, gpg/t-encrypt.c,
gpg/t-encrypt-sign.c, gpg/t-encrypt-sym.c, gpg/t-eventloop.c,
gpg/t-export.c, gpg/t-genkey.c, gpg/t-import.c, gpg/t-keylist.c,
gpg/t-keylist-sig.c, gpg/t-sign.c, gpg/t-signers.c,
gpg/t-support.h, gpg/t-thread1.c, gpg/t-trustlist.c,
gpg/t-verify.c, Makefile.am, t-data.c, t-engine-info.c,
t-version.c: Change license to LGPL.
2004-12-07 21:13:39 +00:00
|
|
|
|
Lesser General Public License for more details.
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* README: Refer to COPYING.LESSER and "each file" instead of
COPYING.
* COPYING.LESSER: New file.
* gpgme.spec.in (%doc): Add COPYING.LESSER.
* acinclude.m4, configure.ac, Makefile.am: Change license to LGPL
2.1 or later.
* TODO: Add copyright notice.
* README.CVS: Likewise.
assuan/
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* README.1st: Add copyright notice.
doc/
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* Makefile.am: Change license to LGPL.
(gpgme_TEXINFOS): Replace gpl.texi with lesser.texi.
* gpgme.texi: Change license to LGPL (also for documentation of
GPGME's license).
* lesser.texi: New file.
* gpl.texi: File removed.
gpgme/
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* putc_unlocked.c, funopen.c: I just claim copyright on these
files and change their license to LGPL, because they are totally
trivial wrapper functions.
* isascii.c: Change copyright notice to the one from ctype/ctype.h
in the GNU C Library (CVS Head 2004-10-10), where isascii is
defined as a macro doing exactly the same as the function in this
file.
* memrchr.c: Update from the GNU C Library (CVS Head 2001-07-06).
* stpcpy.c: Update from the GNU C Library (CVS Head 2004-10-10).
* ath.c, ath-compat.c, ath.h, ath-pth.c, ath-pth-compat.c,
ath-pthread.c, ath-pthread-compat.c, context.h, conversion.c,
data.c, data-compat.c, data-fd.c, data.h, data-mem.c,
data-stream.c, data-user.c, debug.c, debug.h, decrypt.c,
decrypt-verify.c, delete.c, edit.c, encrypt.c, encrypt-sign.c,
engine-backend.h, engine.c, engine-gpgsm.c, engine.h, error.c,
export.c, genkey.c, get-env.c, gpgme.c, gpgme.h, import.c, io.h,
key.c, keylist.c, mkstatus, Makefile.am, ops.h, op-support.c,
passphrase.c, posix-io.c, posix-sema.c, posix-util.c, progress.c,
rungpg.c, sema.h, sign.c, signers.c, trust-item.c, trustlist.c,
util.h, verify.c, version.c, w32-io.c, w32-sema.c, w32-util.c,
wait.c, wait-global.c, wait.h, wait-private.c, wait-user.c: Change
license to LGPL.
tests/
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* gpg/mkdemodirs: Add copyright notice.
* gpgsm/Makefile.am, gpgsm/t-support.h, gpgsm/t-decrypt.c,
gpgsm/t-encrypt.c, gpgsm/t-export.c, gpgsm/t-genkey.c,
gpgsm/t-import.c, gpgsm/t-keylist.c, gpgsm/t-sign.c,
gpgsm/t-verify.c, gpg/Makefile.am, gpg/t-decrypt.c,
gpg/t-decrypt-verify.c, gpg/t-edit.c, gpg/t-encrypt.c,
gpg/t-encrypt-sign.c, gpg/t-encrypt-sym.c, gpg/t-eventloop.c,
gpg/t-export.c, gpg/t-genkey.c, gpg/t-import.c, gpg/t-keylist.c,
gpg/t-keylist-sig.c, gpg/t-sign.c, gpg/t-signers.c,
gpg/t-support.h, gpg/t-thread1.c, gpg/t-trustlist.c,
gpg/t-verify.c, Makefile.am, t-data.c, t-engine-info.c,
t-version.c: Change license to LGPL.
2004-12-07 21:13:39 +00:00
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2014-04-10 11:01:00 +00:00
|
|
|
|
License along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
2002-12-04 16:28:34 +00:00
|
|
|
|
|
|
|
|
|
#if HAVE_CONFIG_H
|
2000-10-27 14:55:24 +00:00
|
|
|
|
#include <config.h>
|
2002-12-04 16:28:34 +00:00
|
|
|
|
#endif
|
2000-10-27 14:55:24 +00:00
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
2001-11-15 21:32:09 +00:00
|
|
|
|
#include <string.h>
|
2000-12-06 12:17:10 +00:00
|
|
|
|
#include <assert.h>
|
2003-06-05 23:20:29 +00:00
|
|
|
|
#include <errno.h>
|
2010-05-07 01:32:54 +00:00
|
|
|
|
#ifdef HAVE_LOCALE_H
|
2003-09-14 00:02:41 +00:00
|
|
|
|
#include <locale.h>
|
2010-05-07 01:32:54 +00:00
|
|
|
|
#endif
|
2000-10-27 14:55:24 +00:00
|
|
|
|
|
2000-11-07 13:32:38 +00:00
|
|
|
|
#include "util.h"
|
|
|
|
|
#include "context.h"
|
2000-11-09 16:35:35 +00:00
|
|
|
|
#include "ops.h"
|
2002-06-10 Marcus Brinkmann <marcus@g10code.de>
* engine-gpgsm.c (_gpgme_gpgsm_start): Move the code that sets the
close notification for the status fd to ...
(_gpgme_gpgsm_new): ... here.
* wait.h: Include "sema.h". Remove prototypes of
_gpgme_remove_proc_from_wait_queue and
_gpgme_register_pipe_handler. Add prototypes of
_gpgme_fd_table_init, _gpgme_fd_table_deinit, _gpgme_fd_table_put,
_gpgme_add_io_cb, _gpgme_remove_io_cb, _gpgme_wait_event_cb and
_gpgme_wait_one..
* wait.c: Remove global variables PROC_QUEUE, PROC_QUEUE_LOCK,
FD_TABLE_SIZE, FD_TABLE, FD_TABLE_LOCK. New global variables
FDT_GLOBAL, CTX_DONE_LIST, CTX_DONE_LIST_SIZE,
CTX_DONE_LIST_LENGTH and CTX_DONE_LIST_LOCK. Remove struct
proc_s. Replace struct wait_item_s.
(_gpgme_fd_table_init): New function.
(_gpgme_fd_table_deinit): Likewise.
(_gpgme_fd_table_put): Likewise.
(set_process_done): Remove function.
(do_select): Take argument FDT. Use that to decide which fds to
select on.
(_gpgme_remove_proc_from_wait_queue): Remove function.
(_gpgme_wait_event_cb): New function.
(_gpgme_wait_one): Likewise.
(_gpgme_register_pipe_hanldler): Remove function.
(_gpgme_add_io_cb): New function.
(_gpgme_remove_io_cb): Likewise.
(_gpgme_freeze_fd): Remove function.
(_gpgme_thaw_fd): Remove function.
* rungpg.c (struct fd_data_map_s): Add new member TAG.
(struct gpg_object_s): Likewise for STATUS and COLON. Add member
IDX to CMD. Add new member IO_CBS.
(close_notify_handler): New variables POSSIBLY_DONE and NOT_DONE.
For each I/O callback, check if it should be unregistered. If all
callbacks have been unregistered, trigger GPGME_EVENT_DONE.
Remove member RUNNING.
(_gpgme_gpg_new): Initialize new members.
(_gpgme_gpg_release): Check PID not RUNNING. Don't call
_gpgme_remove_proc_from_wait_queue. Close GPG->CMD.FD if set.
(build_argv): Store away the index instead the file descriptor for
CMD.
(_gpgme_gpg_add_io_cb): New function.
(_gpgme_gpg_spawn): Use _gpgme_gpg_add_io_cb to register IO
callbacks.
(gpg_status_handler): Change return type to void, remove PID
argument, close filedescriptor if EOF or error occurs.
(read_status): Use _gpgme_gpg_add_io_cb instead _gpgme_thaw_fd.
Use IO_CBS->remove instead _gpgme_freeze_fd.
(gpg_colon_line_handler): Change return type to void, remove PID
argument, close filedescriptor if EOF or error occurs.
(command_cb): Use IO_CBS->remove instead _gpgme_freeze_fd.
(_gpgme_gpg_set_io_cbs): New function.
* rungpg.h (_gpgme_gpg_set_io_cbs): Prototype for
_gpgme_gpg_set_io_cbs.
* gpgme.h (GpgmeIOCb): New type.
(GpgmeRegisterIOCb): Likewise.
(GpgmeRemoveIOCb): Likewise.
(GpgmeEventIO): Likewise.
(GpgmeEventIOCb): Likewise.
(struct GpgmeIOCbs): New structure to hold I/O callbacks.
(gpgme_set_op_io_cbs): New prototype.
(gpgme_get_op_io_cbs): Likewise.
* ops.h: New prototype for _gpgme_op_event_cb. Remove prototypes
for _gpgme_freeze_fd and _gpgme_thaw_fd. Remove PID argument from
_gpgme_data_inbound_handler and _gpgme_data_outbound_handler
prototype. Add prototype for _gpgme_op_reset.
Add synchronous argument to _gpgme_decrypt_start prototype.
* io.h: Beautification.
* gpgme.c: Include "wait.h".
(gpgme_new): Initialize FDT.
(gpgme_set_io_cbs): New function.
(gpgme_get_io_cbs): Likewise.
(_gpgme_op_event_cb): Likewise.
* data.c (_gpgme_data_inbound_handler): Change return type to
void. Drop PID argument. Close FD on error and EOF.
(write_mem_data): Don't close FD here ...
(write_cb_data): ... or here ...
(_gpgme_data_outbound_handler): ... but here. Change return type
to void. Drop PID argument.
* context.h: Include "wait.h".
(struct gpgme_context_s): New members FDT and IO_CBS.
* op-support.c: New file.
* Makefile.am (libgpgme_la_SOURCES): Add op-support.c.
* ops.h: Add prototype for _gpgme_op_reset().
* decrypt.c (_gpgme_decrypt_start): New argument SYNCHRONOUS. Use
_gpgme_op_reset.
(gpgme_op_decrypt_start): Add synchronous argument.
(gpgme_op_decrypt): Likewise. Use _gpgme_wait_one instead
gpgme_wait.
* delete.c (gpgme_op_delete_start): Rename to ...
(_gpgme_op_delete_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_delete_start): Just a wrapper around
_gpgme_op_delete_start now.
(gpgme_op_delete): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* encrypt.c: Include "wait.h".
(ggpgme_op_encrypt_start): Rename to ...
(_gpgme_op_encrypt_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_encrypt_start): Just a wrapper around
_gpgme_op_encrypt_start now.
(gpgme_op_encrypt): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* encrypt_sign.c (gpgme_op_encrypt_sign_start): Rename to ...
(_gpgme_op_encrypt_sign_start): ... this. New argument
SYNCHRONOUS. Use _gpgme_op_reset. Make function static.
(gpgme_op_encrypt_sign_start): Just a wrapper around
_gpgme_op_encrypt_sign_start now.
(gpgme_op_encrypt_sign): Add synchronous argument. Use
_gpgme_wait_one instead gpgme_wait.
* export.c (gpgme_op_export_start): Rename to ...
(_gpgme_op_export_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_export_start): Just a wrapper around
_gpgme_op_export_start now.
(gpgme_op_export): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* genkey.c (gpgme_op_genkey_start): Rename to ...
(_gpgme_op_genkey_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_genkey_start): Just a wrapper around
_gpgme_op_genkey_start now.
(gpgme_op_genkey): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* import.c (gpgme_op_import_start): Rename to ...
(_gpgme_op_import_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_import_start): Just a wrapper around
_gpgme_op_import_start now.
(gpgme_op_import): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* keylist.c (gpgme_op_keylist_start): Use _gpgme_op_reset.
(gpgme_op_keylist_ext_start): Likewise.
* sign.c (gpgme_op_sign_start): Rename to ...
(_gpgme_op_sign_start): ... this. New argument SYNCHRONOUS. Use
_gpgme_op_reset. Make function static.
(gpgme_op_sign_start): Just a wrapper around _gpgme_op_sign_start
now.
(gpgme_op_sign): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* trustlist.c (gpgme_op_trustlist_start): Use _gpgme_op_reset.
* verify.c (gpgme_op_verify_start): Rename to ...
(_gpgme_op_verify_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_verify_start): Just a wrapper around
_gpgme_op_verify_start now.
(gpgme_op_verify): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* engine-gpgsm.c (iocb_data_t): New type.
(struct gpgsm_object_s): New member status_cb. Replace input_fd
and input_data with input_cb. Replace output_fd and output_data
with output_cb. Replace message_fd and message_data with
message_cb. New member io_cbs.
(_gpgme_gpgsm_new): Initialize all new members (and drop the old
ones).
(close_notify_handler): New variable POSSIBLY_DONE. For each I/O
callback, check if it should be unregistered. If all callbacks
have been unregistered, trigger GPGME_EVENT_DONE.
(_gpgme_gpgsm_release): Remove variable PID. Use new variable
names to close the file descriptors.
(_gpgme_gpgsm_op_decrypt): Use new variable names,
(_gpgme_gpgsm_op_encrypt): Likewise.
(_gpgme_gpgsm_op_genkey): Likewise.
(_gpgme_gpgsm_op_import): Likewise.
(_gpgme_gpgsm_op_keylist): Likewise.
(_gpgme_gpgsm_op_keylist_ext): Likewise.
(_gpgme_gpgsm_op_sign): Likewise.
(_gpgme_gpgsm_op_verify): Likewise.
(gpgsm_status_handler): Drop argument PID. Change return type to
void. Close status pipe before returning because of EOF or error.
(_gpgme_gpgsm_add_io_cb): New function.
(_gpgme_gpgsm_start): Use _gpgme_gpgsm_add_io_cb to register
callback function.
(_gpgme_gpgsm_set_io_cbs): New function.
* engine-gpgsm.h: New prototype for _gpgme_gpgsm_set_io_cbs.
* engine.c (_gpgme_engine_set_io_cbs): New function.
* engine.h: New prototype for _gpgme_engine_set_io_cbs.
2002-06-10 14:13:55 +00:00
|
|
|
|
#include "wait.h"
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
#include "debug.h"
|
2009-06-09 16:01:02 +00:00
|
|
|
|
#include "priv-io.h"
|
2014-01-06 16:16:52 +00:00
|
|
|
|
#include "sys-util.h"
|
2016-10-25 15:27:49 +00:00
|
|
|
|
#include "mbox-util.h"
|
2002-02-25 18:31:07 +00:00
|
|
|
|
|
2003-09-14 00:02:41 +00:00
|
|
|
|
|
|
|
|
|
/* The default locale. */
|
|
|
|
|
DEFINE_STATIC_LOCK (def_lc_lock);
|
|
|
|
|
static char *def_lc_ctype;
|
|
|
|
|
static char *def_lc_messages;
|
|
|
|
|
|
2009-05-28 15:16:01 +00:00
|
|
|
|
|
|
|
|
|
gpgme_error_t _gpgme_selftest = GPG_ERR_NOT_OPERATIONAL;
|
|
|
|
|
|
2009-06-16 14:43:38 +00:00
|
|
|
|
/* Protects all reference counters in result structures. All other
|
2009-10-26 18:52:32 +00:00
|
|
|
|
accesses to a result structure are read only. */
|
2009-06-16 14:43:38 +00:00
|
|
|
|
DEFINE_STATIC_LOCK (result_ref_lock);
|
|
|
|
|
|
2012-09-25 13:38:26 +00:00
|
|
|
|
|
|
|
|
|
/* Set the global flag NAME to VALUE. Return 0 on success. Note that
|
2013-02-07 19:59:16 +00:00
|
|
|
|
this function does not use gpgme_error and thus a non-zero return
|
|
|
|
|
value merely means "error". Certain flags may be set before
|
2012-09-25 13:38:26 +00:00
|
|
|
|
gpgme_check_version is called. See the manual for a description of
|
|
|
|
|
supported flags. The caller must assure that this function is
|
|
|
|
|
called only by one thread at a time. */
|
|
|
|
|
int
|
|
|
|
|
gpgme_set_global_flag (const char *name, const char *value)
|
|
|
|
|
{
|
|
|
|
|
if (!name || !value)
|
|
|
|
|
return -1;
|
|
|
|
|
else if (!strcmp (name, "debug"))
|
|
|
|
|
return _gpgme_debug_set_debug_envvar (value);
|
2014-01-06 16:16:52 +00:00
|
|
|
|
else if (!strcmp (name, "disable-gpgconf"))
|
|
|
|
|
{
|
|
|
|
|
_gpgme_dirinfo_disable_gpgconf ();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2016-08-16 16:53:42 +00:00
|
|
|
|
else if (!strcmp (name, "require-gnupg"))
|
|
|
|
|
return _gpgme_set_engine_minimal_version (value);
|
2014-01-06 16:16:52 +00:00
|
|
|
|
else if (!strcmp (name, "gpgconf-name"))
|
|
|
|
|
return _gpgme_set_default_gpgconf_name (value);
|
|
|
|
|
else if (!strcmp (name, "gpg-name"))
|
|
|
|
|
return _gpgme_set_default_gpg_name (value);
|
2015-10-28 15:24:30 +00:00
|
|
|
|
else if (!strcmp (name, "w32-inst-dir"))
|
|
|
|
|
return _gpgme_set_override_inst_dir (value);
|
2012-09-25 13:38:26 +00:00
|
|
|
|
else
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-09-14 00:02:41 +00:00
|
|
|
|
|
2003-04-25 13:42:02 +00:00
|
|
|
|
/* Create a new context as an environment for GPGME crypto
|
|
|
|
|
operations. */
|
2003-05-18 20:45:24 +00:00
|
|
|
|
gpgme_error_t
|
|
|
|
|
gpgme_new (gpgme_ctx_t *r_ctx)
|
2000-10-27 17:46:09 +00:00
|
|
|
|
{
|
2014-01-07 12:32:08 +00:00
|
|
|
|
gpgme_error_t err;
|
2003-05-18 20:45:24 +00:00
|
|
|
|
gpgme_ctx_t ctx;
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
TRACE_BEG (DEBUG_CTX, "gpgme_new", r_ctx);
|
2000-10-27 17:46:09 +00:00
|
|
|
|
|
2009-05-28 15:16:01 +00:00
|
|
|
|
if (_gpgme_selftest)
|
2015-10-16 00:51:42 +00:00
|
|
|
|
return TRACE_ERR (_gpgme_selftest);
|
2009-05-28 15:16:01 +00:00
|
|
|
|
|
2011-05-26 14:01:26 +00:00
|
|
|
|
if (!r_ctx)
|
|
|
|
|
return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
|
|
|
|
|
|
2002-10-08 Marcus Brinkmann <marcus@g10code.de>
* util.h (_gpgme_malloc, _gpgme_realloc, _gpgme_calloc,
_gpgme_strdup, _gpgme_free): Remove prototypes.
(xtrymalloc, xtrycalloc, xtryrealloc, xtrystrdup, xfree): Remove
macros.
* util.c: File removed.
* Makefile.am (libgpgme_la_SOURCES): Remove util.h.
* conversion.c (_gpgme_decode_c_string): Use malloc instead of
xtrymalloc, realloc instead of xtryrealloc, calloc instead of
xtrycalloc, free instead of xfree.
(_gpgme_data_append_percentstring_for_xml): Likewise.
* data.c (_gpgme_data_new, _gpgme_data_release): Likewise.
* data-compat.c (gpgme_data_new_from_filepart): Likewise.
* data-mem.c (mem_write, mem_release, gpgme_data_new_from_mem,
_gpgme_data_get_as_string): Likewise.
* debug.c (debug_init): Likewise.
* decrypt.c (_gpgme_release_decrypt_result): Likewise.
* delete.c (_gpgme_release_delete_result): Likewise.
* edit.c (_gpgme_release_edit_result, _gpgme_op_edit_start):
Likewise.
* encrypt.c (_gpgme_release_encrypt_result): Likewise.
* engine.c (_gpgme_engine_get_info, _gpgme_engine_new,
_gpgme_engine_release): Likewise.
* engine-gpgsm.c (_gpgme_gpgsm_new, _gpgme_gpgsm_release,
_gpgme_gpgsm_op_decrypt, _gpgme_gpgsm_op_delete,
gpgsm_set_recipients, _gpgme_gpgsm_op_encrypt,
_gpgme_gpgsm_op_export, _gpgme_gpgsm_op_genkey,
_gpgme_gpgsm_op_import, _gpgme_gpgsm_op_keylist,
_gpgme_gpgsm_op_keylist_ext, _gpgme_gpgsm_op_sign,
_gpgme_gpgsm_op_verify, gpgsm_status_handler): Likewise.
* genkey.c (_gpgme_release_genkey_result): Likewise.
* gpgme.c (gpgme_new, gpgme_release): Likewise.
* import.c (_gpgme_release_import_result): Likewise.
* key.c (_gpgme_key_cache_init, _gpgme_key_cache_add, key_new,
add_subkey, gpgme_key_release, _gpgme_key_append_name): Likewise.
* keylist.c (_gpgme_release_keylist_result, keylist_colon_handler,
_gpgme_op_keylist_event_cb, gpgme_op_keylist_next): Likewise.
* ops.h (test_and_allocate_result): Likewise.
* passphrase.c (_gpgme_release_passphrase_result,
_gpgme_passphrase_status_handler,
_gpgme_passphrase_command_handler): Likewise.
* progress.c (_gpgme_progress_status_handler): Likewise.
* recipient.c (gpgme_recipients_new, gpgme_recipients_release,
gpgme_recipients_add_name_with_validity): Likewise.
* rungpg.c (_gpgme_gpg_new, _gpgme_gpg_release,
_gpgme_gpg_add_arg, _gpgme_gpg_add_data,
_gpgme_gpg_set_colon_line_handler, free_argv, free_fd_data_map,
build_argv, _gpgme_gpg_spawn, read_status, read_colon_line):
Likewise.
* sign.c (_gpgme_release_sign_result): Likewise.
* signers.c (_gpgme_signers_add): Likewise.
* trustlist.c (trust_item_new, trustlist_colon_handler,
_gpgme_op_trustlist_event_cb, gpgme_op_trustlist_next,
gpgme_trustitem_release): Likewise.
* verify.c (_gpgme_release_verify_result, finish_sig): Likewise.
* version.c (gpgme_get_engine_info, _gpgme_get_program_version):
Likewise.
* w32-io.c (create_reader, create_writer, destroy_reader,
destroy_writer, build_commandline, _gpgme_io_spawn): Likewise.
* w32-sema.c (critsect_init, _gpgme_sema_cs_destroy): Likewise.
* w32-util.c (read_w32_registry_string): Likewise.
* wait.c (_gpgme_fd_table_deinit, _gpgme_fd_table_put,
_gpgme_wait_event_cb, _gpgme_add_io_cb, _gpgme_remove_io_cb)
* data-compat.c: Include <stdlib.h>.
2002-10-09 01:08:21 +00:00
|
|
|
|
ctx = calloc (1, sizeof *ctx);
|
2002-01-15 19:58:41 +00:00
|
|
|
|
if (!ctx)
|
2013-02-06 16:35:40 +00:00
|
|
|
|
return TRACE_ERR (gpg_error_from_syserror ());
|
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* libgpgme.vers (GPGME_1.1): New version.
* engine-backend.h (struct engine_ops): Add argument FILE_NAME to
member get_version(). Add arguments FILE_NAME and HOME_DIR to
member new(). Change return type of get_file_name and get_version
to char *.
* engine-gpgsm.c (gpgsm_get_version): Change return type to char
pointer. Do not cache result.
(gpgsm_new): Add file_name and home_dir argument, and use them
instead of the defaults, if set.
* rungpg.c (struct engine_gpg): New member file_name.
(gpg_get_version): Change return type to char pointer, and do not
cache result.
(gpg_release): Free gpg->file_name.
(gpg_new): Take new arguments file_name and home_dir. Set the
--homedir argument if HOME_DIR is not NULL. Set gpg->file_name.
(start): Use gpg->file_name instead _gpgme_get_gpg_path, if set.
* engine.h (_gpgme_engine_info_copy, _gpgme_engine_info_release):
New prototypes.
(_gpgme_engine_new): Change first argument to gpgme_engine_info_t
info.
* engine.c: Include <assert.h>.
(gpgme_get_engine_info): Set *INFO within the lock. Move
ENGINE_INFO and ENGINE_INFO_LOCK to ....
(engine_info, engine_info_lock): ... here. New static variables.
(engine_get_version): Add file_name argument to
get_version invocation. Change return type to char pointer.
(gpgme_engine_check_version): Rewritten to free() the return value
of engine_get_version after using it.
(_gpgme_engine_info_release): New function.
(gpgme_get_engine_info): Rewritten.
(_gpgme_engine_info_copy): New function.
(_gpgme_set_engine_info): New function.
(gpgme_set_engine_info): New function.
(_gpgme_engine_new): Change first argument to gpgme_engine_info_t
info, and use that.
* gpgme.h (struct _gpgme_engine_info): Change type of file_name
and version to char * (remove the const). New member home_dir.
(gpgme_set_engine_info, gpgme_ctx_get_engine_info,
gpgme_ctx_set_engine_info): New prototypes.
* context.h (struct gpgme_context): New member engine_info.
* gpgme.c (gpgme_new): Allocate CTX->engine_info.
(gpgme_release): Deallocate CTX->engine_info.
(gpgme_ctx_get_engine_info, gpgme_ctx_set_engine_info): New
functions.
* op-support.c (_gpgme_op_reset): Look for correct engine info and
pass it to _gpgme_engine_new.
* version.c (gpgme_check_version): Adjust to
_gpgme_compare_versions returning an int.
(_gpgme_compare_versions): Return an int value, not a const char
pointer.
* ops.h (_gpgme_compare_versions): Same for prototype.
2004-12-07 18:25:54 +00:00
|
|
|
|
|
2008-06-27 16:07:33 +00:00
|
|
|
|
INIT_LOCK (ctx->lock);
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2014-01-07 12:32:08 +00:00
|
|
|
|
err = _gpgme_engine_info_copy (&ctx->engine_info);
|
|
|
|
|
if (!err && !ctx->engine_info)
|
|
|
|
|
err = gpg_error (GPG_ERR_NO_ENGINE);
|
|
|
|
|
if (err)
|
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* libgpgme.vers (GPGME_1.1): New version.
* engine-backend.h (struct engine_ops): Add argument FILE_NAME to
member get_version(). Add arguments FILE_NAME and HOME_DIR to
member new(). Change return type of get_file_name and get_version
to char *.
* engine-gpgsm.c (gpgsm_get_version): Change return type to char
pointer. Do not cache result.
(gpgsm_new): Add file_name and home_dir argument, and use them
instead of the defaults, if set.
* rungpg.c (struct engine_gpg): New member file_name.
(gpg_get_version): Change return type to char pointer, and do not
cache result.
(gpg_release): Free gpg->file_name.
(gpg_new): Take new arguments file_name and home_dir. Set the
--homedir argument if HOME_DIR is not NULL. Set gpg->file_name.
(start): Use gpg->file_name instead _gpgme_get_gpg_path, if set.
* engine.h (_gpgme_engine_info_copy, _gpgme_engine_info_release):
New prototypes.
(_gpgme_engine_new): Change first argument to gpgme_engine_info_t
info.
* engine.c: Include <assert.h>.
(gpgme_get_engine_info): Set *INFO within the lock. Move
ENGINE_INFO and ENGINE_INFO_LOCK to ....
(engine_info, engine_info_lock): ... here. New static variables.
(engine_get_version): Add file_name argument to
get_version invocation. Change return type to char pointer.
(gpgme_engine_check_version): Rewritten to free() the return value
of engine_get_version after using it.
(_gpgme_engine_info_release): New function.
(gpgme_get_engine_info): Rewritten.
(_gpgme_engine_info_copy): New function.
(_gpgme_set_engine_info): New function.
(gpgme_set_engine_info): New function.
(_gpgme_engine_new): Change first argument to gpgme_engine_info_t
info, and use that.
* gpgme.h (struct _gpgme_engine_info): Change type of file_name
and version to char * (remove the const). New member home_dir.
(gpgme_set_engine_info, gpgme_ctx_get_engine_info,
gpgme_ctx_set_engine_info): New prototypes.
* context.h (struct gpgme_context): New member engine_info.
* gpgme.c (gpgme_new): Allocate CTX->engine_info.
(gpgme_release): Deallocate CTX->engine_info.
(gpgme_ctx_get_engine_info, gpgme_ctx_set_engine_info): New
functions.
* op-support.c (_gpgme_op_reset): Look for correct engine info and
pass it to _gpgme_engine_new.
* version.c (gpgme_check_version): Adjust to
_gpgme_compare_versions returning an int.
(_gpgme_compare_versions): Return an int value, not a const char
pointer.
* ops.h (_gpgme_compare_versions): Same for prototype.
2004-12-07 18:25:54 +00:00
|
|
|
|
{
|
|
|
|
|
free (ctx);
|
2014-01-07 12:32:08 +00:00
|
|
|
|
return TRACE_ERR (err);
|
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* libgpgme.vers (GPGME_1.1): New version.
* engine-backend.h (struct engine_ops): Add argument FILE_NAME to
member get_version(). Add arguments FILE_NAME and HOME_DIR to
member new(). Change return type of get_file_name and get_version
to char *.
* engine-gpgsm.c (gpgsm_get_version): Change return type to char
pointer. Do not cache result.
(gpgsm_new): Add file_name and home_dir argument, and use them
instead of the defaults, if set.
* rungpg.c (struct engine_gpg): New member file_name.
(gpg_get_version): Change return type to char pointer, and do not
cache result.
(gpg_release): Free gpg->file_name.
(gpg_new): Take new arguments file_name and home_dir. Set the
--homedir argument if HOME_DIR is not NULL. Set gpg->file_name.
(start): Use gpg->file_name instead _gpgme_get_gpg_path, if set.
* engine.h (_gpgme_engine_info_copy, _gpgme_engine_info_release):
New prototypes.
(_gpgme_engine_new): Change first argument to gpgme_engine_info_t
info.
* engine.c: Include <assert.h>.
(gpgme_get_engine_info): Set *INFO within the lock. Move
ENGINE_INFO and ENGINE_INFO_LOCK to ....
(engine_info, engine_info_lock): ... here. New static variables.
(engine_get_version): Add file_name argument to
get_version invocation. Change return type to char pointer.
(gpgme_engine_check_version): Rewritten to free() the return value
of engine_get_version after using it.
(_gpgme_engine_info_release): New function.
(gpgme_get_engine_info): Rewritten.
(_gpgme_engine_info_copy): New function.
(_gpgme_set_engine_info): New function.
(gpgme_set_engine_info): New function.
(_gpgme_engine_new): Change first argument to gpgme_engine_info_t
info, and use that.
* gpgme.h (struct _gpgme_engine_info): Change type of file_name
and version to char * (remove the const). New member home_dir.
(gpgme_set_engine_info, gpgme_ctx_get_engine_info,
gpgme_ctx_set_engine_info): New prototypes.
* context.h (struct gpgme_context): New member engine_info.
* gpgme.c (gpgme_new): Allocate CTX->engine_info.
(gpgme_release): Deallocate CTX->engine_info.
(gpgme_ctx_get_engine_info, gpgme_ctx_set_engine_info): New
functions.
* op-support.c (_gpgme_op_reset): Look for correct engine info and
pass it to _gpgme_engine_new.
* version.c (gpgme_check_version): Adjust to
_gpgme_compare_versions returning an int.
(_gpgme_compare_versions): Return an int value, not a const char
pointer.
* ops.h (_gpgme_compare_versions): Same for prototype.
2004-12-07 18:25:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-02-06 00:08:47 +00:00
|
|
|
|
ctx->keylist_mode = GPGME_KEYLIST_MODE_LOCAL;
|
2005-05-17 12:26:58 +00:00
|
|
|
|
ctx->include_certs = GPGME_INCLUDE_CERTS_DEFAULT;
|
2003-04-25 13:42:02 +00:00
|
|
|
|
ctx->protocol = GPGME_PROTOCOL_OpenPGP;
|
2009-11-10 14:54:39 +00:00
|
|
|
|
ctx->sub_protocol = GPGME_PROTOCOL_DEFAULT;
|
2002-06-10 Marcus Brinkmann <marcus@g10code.de>
* engine-gpgsm.c (_gpgme_gpgsm_start): Move the code that sets the
close notification for the status fd to ...
(_gpgme_gpgsm_new): ... here.
* wait.h: Include "sema.h". Remove prototypes of
_gpgme_remove_proc_from_wait_queue and
_gpgme_register_pipe_handler. Add prototypes of
_gpgme_fd_table_init, _gpgme_fd_table_deinit, _gpgme_fd_table_put,
_gpgme_add_io_cb, _gpgme_remove_io_cb, _gpgme_wait_event_cb and
_gpgme_wait_one..
* wait.c: Remove global variables PROC_QUEUE, PROC_QUEUE_LOCK,
FD_TABLE_SIZE, FD_TABLE, FD_TABLE_LOCK. New global variables
FDT_GLOBAL, CTX_DONE_LIST, CTX_DONE_LIST_SIZE,
CTX_DONE_LIST_LENGTH and CTX_DONE_LIST_LOCK. Remove struct
proc_s. Replace struct wait_item_s.
(_gpgme_fd_table_init): New function.
(_gpgme_fd_table_deinit): Likewise.
(_gpgme_fd_table_put): Likewise.
(set_process_done): Remove function.
(do_select): Take argument FDT. Use that to decide which fds to
select on.
(_gpgme_remove_proc_from_wait_queue): Remove function.
(_gpgme_wait_event_cb): New function.
(_gpgme_wait_one): Likewise.
(_gpgme_register_pipe_hanldler): Remove function.
(_gpgme_add_io_cb): New function.
(_gpgme_remove_io_cb): Likewise.
(_gpgme_freeze_fd): Remove function.
(_gpgme_thaw_fd): Remove function.
* rungpg.c (struct fd_data_map_s): Add new member TAG.
(struct gpg_object_s): Likewise for STATUS and COLON. Add member
IDX to CMD. Add new member IO_CBS.
(close_notify_handler): New variables POSSIBLY_DONE and NOT_DONE.
For each I/O callback, check if it should be unregistered. If all
callbacks have been unregistered, trigger GPGME_EVENT_DONE.
Remove member RUNNING.
(_gpgme_gpg_new): Initialize new members.
(_gpgme_gpg_release): Check PID not RUNNING. Don't call
_gpgme_remove_proc_from_wait_queue. Close GPG->CMD.FD if set.
(build_argv): Store away the index instead the file descriptor for
CMD.
(_gpgme_gpg_add_io_cb): New function.
(_gpgme_gpg_spawn): Use _gpgme_gpg_add_io_cb to register IO
callbacks.
(gpg_status_handler): Change return type to void, remove PID
argument, close filedescriptor if EOF or error occurs.
(read_status): Use _gpgme_gpg_add_io_cb instead _gpgme_thaw_fd.
Use IO_CBS->remove instead _gpgme_freeze_fd.
(gpg_colon_line_handler): Change return type to void, remove PID
argument, close filedescriptor if EOF or error occurs.
(command_cb): Use IO_CBS->remove instead _gpgme_freeze_fd.
(_gpgme_gpg_set_io_cbs): New function.
* rungpg.h (_gpgme_gpg_set_io_cbs): Prototype for
_gpgme_gpg_set_io_cbs.
* gpgme.h (GpgmeIOCb): New type.
(GpgmeRegisterIOCb): Likewise.
(GpgmeRemoveIOCb): Likewise.
(GpgmeEventIO): Likewise.
(GpgmeEventIOCb): Likewise.
(struct GpgmeIOCbs): New structure to hold I/O callbacks.
(gpgme_set_op_io_cbs): New prototype.
(gpgme_get_op_io_cbs): Likewise.
* ops.h: New prototype for _gpgme_op_event_cb. Remove prototypes
for _gpgme_freeze_fd and _gpgme_thaw_fd. Remove PID argument from
_gpgme_data_inbound_handler and _gpgme_data_outbound_handler
prototype. Add prototype for _gpgme_op_reset.
Add synchronous argument to _gpgme_decrypt_start prototype.
* io.h: Beautification.
* gpgme.c: Include "wait.h".
(gpgme_new): Initialize FDT.
(gpgme_set_io_cbs): New function.
(gpgme_get_io_cbs): Likewise.
(_gpgme_op_event_cb): Likewise.
* data.c (_gpgme_data_inbound_handler): Change return type to
void. Drop PID argument. Close FD on error and EOF.
(write_mem_data): Don't close FD here ...
(write_cb_data): ... or here ...
(_gpgme_data_outbound_handler): ... but here. Change return type
to void. Drop PID argument.
* context.h: Include "wait.h".
(struct gpgme_context_s): New members FDT and IO_CBS.
* op-support.c: New file.
* Makefile.am (libgpgme_la_SOURCES): Add op-support.c.
* ops.h: Add prototype for _gpgme_op_reset().
* decrypt.c (_gpgme_decrypt_start): New argument SYNCHRONOUS. Use
_gpgme_op_reset.
(gpgme_op_decrypt_start): Add synchronous argument.
(gpgme_op_decrypt): Likewise. Use _gpgme_wait_one instead
gpgme_wait.
* delete.c (gpgme_op_delete_start): Rename to ...
(_gpgme_op_delete_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_delete_start): Just a wrapper around
_gpgme_op_delete_start now.
(gpgme_op_delete): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* encrypt.c: Include "wait.h".
(ggpgme_op_encrypt_start): Rename to ...
(_gpgme_op_encrypt_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_encrypt_start): Just a wrapper around
_gpgme_op_encrypt_start now.
(gpgme_op_encrypt): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* encrypt_sign.c (gpgme_op_encrypt_sign_start): Rename to ...
(_gpgme_op_encrypt_sign_start): ... this. New argument
SYNCHRONOUS. Use _gpgme_op_reset. Make function static.
(gpgme_op_encrypt_sign_start): Just a wrapper around
_gpgme_op_encrypt_sign_start now.
(gpgme_op_encrypt_sign): Add synchronous argument. Use
_gpgme_wait_one instead gpgme_wait.
* export.c (gpgme_op_export_start): Rename to ...
(_gpgme_op_export_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_export_start): Just a wrapper around
_gpgme_op_export_start now.
(gpgme_op_export): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* genkey.c (gpgme_op_genkey_start): Rename to ...
(_gpgme_op_genkey_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_genkey_start): Just a wrapper around
_gpgme_op_genkey_start now.
(gpgme_op_genkey): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* import.c (gpgme_op_import_start): Rename to ...
(_gpgme_op_import_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_import_start): Just a wrapper around
_gpgme_op_import_start now.
(gpgme_op_import): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* keylist.c (gpgme_op_keylist_start): Use _gpgme_op_reset.
(gpgme_op_keylist_ext_start): Likewise.
* sign.c (gpgme_op_sign_start): Rename to ...
(_gpgme_op_sign_start): ... this. New argument SYNCHRONOUS. Use
_gpgme_op_reset. Make function static.
(gpgme_op_sign_start): Just a wrapper around _gpgme_op_sign_start
now.
(gpgme_op_sign): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* trustlist.c (gpgme_op_trustlist_start): Use _gpgme_op_reset.
* verify.c (gpgme_op_verify_start): Rename to ...
(_gpgme_op_verify_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_verify_start): Just a wrapper around
_gpgme_op_verify_start now.
(gpgme_op_verify): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* engine-gpgsm.c (iocb_data_t): New type.
(struct gpgsm_object_s): New member status_cb. Replace input_fd
and input_data with input_cb. Replace output_fd and output_data
with output_cb. Replace message_fd and message_data with
message_cb. New member io_cbs.
(_gpgme_gpgsm_new): Initialize all new members (and drop the old
ones).
(close_notify_handler): New variable POSSIBLY_DONE. For each I/O
callback, check if it should be unregistered. If all callbacks
have been unregistered, trigger GPGME_EVENT_DONE.
(_gpgme_gpgsm_release): Remove variable PID. Use new variable
names to close the file descriptors.
(_gpgme_gpgsm_op_decrypt): Use new variable names,
(_gpgme_gpgsm_op_encrypt): Likewise.
(_gpgme_gpgsm_op_genkey): Likewise.
(_gpgme_gpgsm_op_import): Likewise.
(_gpgme_gpgsm_op_keylist): Likewise.
(_gpgme_gpgsm_op_keylist_ext): Likewise.
(_gpgme_gpgsm_op_sign): Likewise.
(_gpgme_gpgsm_op_verify): Likewise.
(gpgsm_status_handler): Drop argument PID. Change return type to
void. Close status pipe before returning because of EOF or error.
(_gpgme_gpgsm_add_io_cb): New function.
(_gpgme_gpgsm_start): Use _gpgme_gpgsm_add_io_cb to register
callback function.
(_gpgme_gpgsm_set_io_cbs): New function.
* engine-gpgsm.h: New prototype for _gpgme_gpgsm_set_io_cbs.
* engine.c (_gpgme_engine_set_io_cbs): New function.
* engine.h: New prototype for _gpgme_engine_set_io_cbs.
2002-06-10 14:13:55 +00:00
|
|
|
|
_gpgme_fd_table_init (&ctx->fdt);
|
2003-09-14 00:02:41 +00:00
|
|
|
|
|
|
|
|
|
LOCK (def_lc_lock);
|
|
|
|
|
if (def_lc_ctype)
|
|
|
|
|
{
|
|
|
|
|
ctx->lc_ctype = strdup (def_lc_ctype);
|
|
|
|
|
if (!ctx->lc_ctype)
|
|
|
|
|
{
|
2013-02-06 16:35:40 +00:00
|
|
|
|
int saved_err = gpg_error_from_syserror ();
|
2003-09-14 00:02:41 +00:00
|
|
|
|
UNLOCK (def_lc_lock);
|
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* libgpgme.vers (GPGME_1.1): New version.
* engine-backend.h (struct engine_ops): Add argument FILE_NAME to
member get_version(). Add arguments FILE_NAME and HOME_DIR to
member new(). Change return type of get_file_name and get_version
to char *.
* engine-gpgsm.c (gpgsm_get_version): Change return type to char
pointer. Do not cache result.
(gpgsm_new): Add file_name and home_dir argument, and use them
instead of the defaults, if set.
* rungpg.c (struct engine_gpg): New member file_name.
(gpg_get_version): Change return type to char pointer, and do not
cache result.
(gpg_release): Free gpg->file_name.
(gpg_new): Take new arguments file_name and home_dir. Set the
--homedir argument if HOME_DIR is not NULL. Set gpg->file_name.
(start): Use gpg->file_name instead _gpgme_get_gpg_path, if set.
* engine.h (_gpgme_engine_info_copy, _gpgme_engine_info_release):
New prototypes.
(_gpgme_engine_new): Change first argument to gpgme_engine_info_t
info.
* engine.c: Include <assert.h>.
(gpgme_get_engine_info): Set *INFO within the lock. Move
ENGINE_INFO and ENGINE_INFO_LOCK to ....
(engine_info, engine_info_lock): ... here. New static variables.
(engine_get_version): Add file_name argument to
get_version invocation. Change return type to char pointer.
(gpgme_engine_check_version): Rewritten to free() the return value
of engine_get_version after using it.
(_gpgme_engine_info_release): New function.
(gpgme_get_engine_info): Rewritten.
(_gpgme_engine_info_copy): New function.
(_gpgme_set_engine_info): New function.
(gpgme_set_engine_info): New function.
(_gpgme_engine_new): Change first argument to gpgme_engine_info_t
info, and use that.
* gpgme.h (struct _gpgme_engine_info): Change type of file_name
and version to char * (remove the const). New member home_dir.
(gpgme_set_engine_info, gpgme_ctx_get_engine_info,
gpgme_ctx_set_engine_info): New prototypes.
* context.h (struct gpgme_context): New member engine_info.
* gpgme.c (gpgme_new): Allocate CTX->engine_info.
(gpgme_release): Deallocate CTX->engine_info.
(gpgme_ctx_get_engine_info, gpgme_ctx_set_engine_info): New
functions.
* op-support.c (_gpgme_op_reset): Look for correct engine info and
pass it to _gpgme_engine_new.
* version.c (gpgme_check_version): Adjust to
_gpgme_compare_versions returning an int.
(_gpgme_compare_versions): Return an int value, not a const char
pointer.
* ops.h (_gpgme_compare_versions): Same for prototype.
2004-12-07 18:25:54 +00:00
|
|
|
|
_gpgme_engine_info_release (ctx->engine_info);
|
2003-09-14 00:02:41 +00:00
|
|
|
|
free (ctx);
|
2013-02-06 16:35:40 +00:00
|
|
|
|
return TRACE_ERR (saved_err);
|
2003-09-14 00:02:41 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
def_lc_ctype = NULL;
|
|
|
|
|
|
|
|
|
|
if (def_lc_messages)
|
|
|
|
|
{
|
|
|
|
|
ctx->lc_messages = strdup (def_lc_messages);
|
|
|
|
|
if (!ctx->lc_messages)
|
|
|
|
|
{
|
2013-02-06 16:35:40 +00:00
|
|
|
|
int saved_err = gpg_error_from_syserror ();
|
2003-09-14 00:02:41 +00:00
|
|
|
|
UNLOCK (def_lc_lock);
|
|
|
|
|
if (ctx->lc_ctype)
|
|
|
|
|
free (ctx->lc_ctype);
|
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* libgpgme.vers (GPGME_1.1): New version.
* engine-backend.h (struct engine_ops): Add argument FILE_NAME to
member get_version(). Add arguments FILE_NAME and HOME_DIR to
member new(). Change return type of get_file_name and get_version
to char *.
* engine-gpgsm.c (gpgsm_get_version): Change return type to char
pointer. Do not cache result.
(gpgsm_new): Add file_name and home_dir argument, and use them
instead of the defaults, if set.
* rungpg.c (struct engine_gpg): New member file_name.
(gpg_get_version): Change return type to char pointer, and do not
cache result.
(gpg_release): Free gpg->file_name.
(gpg_new): Take new arguments file_name and home_dir. Set the
--homedir argument if HOME_DIR is not NULL. Set gpg->file_name.
(start): Use gpg->file_name instead _gpgme_get_gpg_path, if set.
* engine.h (_gpgme_engine_info_copy, _gpgme_engine_info_release):
New prototypes.
(_gpgme_engine_new): Change first argument to gpgme_engine_info_t
info.
* engine.c: Include <assert.h>.
(gpgme_get_engine_info): Set *INFO within the lock. Move
ENGINE_INFO and ENGINE_INFO_LOCK to ....
(engine_info, engine_info_lock): ... here. New static variables.
(engine_get_version): Add file_name argument to
get_version invocation. Change return type to char pointer.
(gpgme_engine_check_version): Rewritten to free() the return value
of engine_get_version after using it.
(_gpgme_engine_info_release): New function.
(gpgme_get_engine_info): Rewritten.
(_gpgme_engine_info_copy): New function.
(_gpgme_set_engine_info): New function.
(gpgme_set_engine_info): New function.
(_gpgme_engine_new): Change first argument to gpgme_engine_info_t
info, and use that.
* gpgme.h (struct _gpgme_engine_info): Change type of file_name
and version to char * (remove the const). New member home_dir.
(gpgme_set_engine_info, gpgme_ctx_get_engine_info,
gpgme_ctx_set_engine_info): New prototypes.
* context.h (struct gpgme_context): New member engine_info.
* gpgme.c (gpgme_new): Allocate CTX->engine_info.
(gpgme_release): Deallocate CTX->engine_info.
(gpgme_ctx_get_engine_info, gpgme_ctx_set_engine_info): New
functions.
* op-support.c (_gpgme_op_reset): Look for correct engine info and
pass it to _gpgme_engine_new.
* version.c (gpgme_check_version): Adjust to
_gpgme_compare_versions returning an int.
(_gpgme_compare_versions): Return an int value, not a const char
pointer.
* ops.h (_gpgme_compare_versions): Same for prototype.
2004-12-07 18:25:54 +00:00
|
|
|
|
_gpgme_engine_info_release (ctx->engine_info);
|
2003-09-14 00:02:41 +00:00
|
|
|
|
free (ctx);
|
2013-02-06 16:35:40 +00:00
|
|
|
|
return TRACE_ERR (saved_err);
|
2003-09-14 00:02:41 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
def_lc_messages = NULL;
|
|
|
|
|
UNLOCK (def_lc_lock);
|
|
|
|
|
|
2002-01-15 19:58:41 +00:00
|
|
|
|
*r_ctx = ctx;
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
|
|
|
|
|
return TRACE_SUC1 ("ctx=%p", ctx);
|
2000-11-07 13:32:38 +00:00
|
|
|
|
}
|
2000-10-27 17:46:09 +00:00
|
|
|
|
|
2002-02-25 18:31:07 +00:00
|
|
|
|
|
2004-02-24 23:08:48 +00:00
|
|
|
|
gpgme_error_t
|
2009-10-26 18:52:32 +00:00
|
|
|
|
_gpgme_cancel_with_err (gpgme_ctx_t ctx, gpg_error_t ctx_err,
|
|
|
|
|
gpg_error_t op_err)
|
2004-02-24 23:08:48 +00:00
|
|
|
|
{
|
|
|
|
|
gpgme_error_t err;
|
2009-10-26 18:52:32 +00:00
|
|
|
|
struct gpgme_io_event_done_data data;
|
2004-02-24 23:08:48 +00:00
|
|
|
|
|
2009-10-26 18:52:32 +00:00
|
|
|
|
TRACE_BEG2 (DEBUG_CTX, "_gpgme_cancel_with_err", ctx, "ctx_err=%i, op_err=%i",
|
|
|
|
|
ctx_err, op_err);
|
2004-02-24 23:08:48 +00:00
|
|
|
|
|
2009-10-26 18:52:32 +00:00
|
|
|
|
if (ctx_err)
|
|
|
|
|
{
|
|
|
|
|
err = _gpgme_engine_cancel (ctx->engine);
|
|
|
|
|
if (err)
|
|
|
|
|
return TRACE_ERR (err);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
err = _gpgme_engine_cancel_op (ctx->engine);
|
|
|
|
|
if (err)
|
|
|
|
|
return TRACE_ERR (err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
data.err = ctx_err;
|
|
|
|
|
data.op_err = op_err;
|
|
|
|
|
|
|
|
|
|
_gpgme_engine_io_event (ctx->engine, GPGME_EVENT_DONE, &data);
|
2004-02-24 23:08:48 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
return TRACE_ERR (0);
|
2004-02-24 23:08:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-06-27 16:07:33 +00:00
|
|
|
|
|
2008-08-11 17:23:45 +00:00
|
|
|
|
/* Cancel a pending asynchronous operation. */
|
|
|
|
|
gpgme_error_t
|
|
|
|
|
gpgme_cancel (gpgme_ctx_t ctx)
|
|
|
|
|
{
|
2009-10-26 18:52:32 +00:00
|
|
|
|
gpg_error_t err;
|
|
|
|
|
|
|
|
|
|
TRACE_BEG (DEBUG_CTX, "gpgme_cancel", ctx);
|
|
|
|
|
|
2011-05-26 14:01:26 +00:00
|
|
|
|
if (!ctx)
|
|
|
|
|
return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
|
|
|
|
|
|
2009-10-26 18:52:32 +00:00
|
|
|
|
err = _gpgme_cancel_with_err (ctx, gpg_error (GPG_ERR_CANCELED), 0);
|
|
|
|
|
|
|
|
|
|
return TRACE_ERR (err);
|
2008-08-11 17:23:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-06-27 16:07:33 +00:00
|
|
|
|
/* Cancel a pending operation asynchronously. */
|
|
|
|
|
gpgme_error_t
|
|
|
|
|
gpgme_cancel_async (gpgme_ctx_t ctx)
|
|
|
|
|
{
|
|
|
|
|
TRACE_BEG (DEBUG_CTX, "gpgme_cancel_async", ctx);
|
|
|
|
|
|
2011-05-26 14:01:26 +00:00
|
|
|
|
if (!ctx)
|
|
|
|
|
return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
|
|
|
|
|
|
2008-06-27 16:07:33 +00:00
|
|
|
|
LOCK (ctx->lock);
|
|
|
|
|
ctx->canceled = 1;
|
|
|
|
|
UNLOCK (ctx->lock);
|
|
|
|
|
|
|
|
|
|
return TRACE_ERR (0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-05-29 03:21:02 +00:00
|
|
|
|
/* Release all resources associated with the given context. */
|
2000-11-07 13:32:38 +00:00
|
|
|
|
void
|
2003-05-18 20:45:24 +00:00
|
|
|
|
gpgme_release (gpgme_ctx_t ctx)
|
2000-11-07 13:32:38 +00:00
|
|
|
|
{
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
TRACE (DEBUG_CTX, "gpgme_release", ctx);
|
|
|
|
|
|
2011-05-26 14:01:26 +00:00
|
|
|
|
if (!ctx)
|
|
|
|
|
return;
|
|
|
|
|
|
2002-02-27 20:59:20 +00:00
|
|
|
|
_gpgme_engine_release (ctx->engine);
|
2014-05-08 18:39:15 +00:00
|
|
|
|
ctx->engine = NULL;
|
2002-06-10 Marcus Brinkmann <marcus@g10code.de>
* engine-gpgsm.c (_gpgme_gpgsm_start): Move the code that sets the
close notification for the status fd to ...
(_gpgme_gpgsm_new): ... here.
* wait.h: Include "sema.h". Remove prototypes of
_gpgme_remove_proc_from_wait_queue and
_gpgme_register_pipe_handler. Add prototypes of
_gpgme_fd_table_init, _gpgme_fd_table_deinit, _gpgme_fd_table_put,
_gpgme_add_io_cb, _gpgme_remove_io_cb, _gpgme_wait_event_cb and
_gpgme_wait_one..
* wait.c: Remove global variables PROC_QUEUE, PROC_QUEUE_LOCK,
FD_TABLE_SIZE, FD_TABLE, FD_TABLE_LOCK. New global variables
FDT_GLOBAL, CTX_DONE_LIST, CTX_DONE_LIST_SIZE,
CTX_DONE_LIST_LENGTH and CTX_DONE_LIST_LOCK. Remove struct
proc_s. Replace struct wait_item_s.
(_gpgme_fd_table_init): New function.
(_gpgme_fd_table_deinit): Likewise.
(_gpgme_fd_table_put): Likewise.
(set_process_done): Remove function.
(do_select): Take argument FDT. Use that to decide which fds to
select on.
(_gpgme_remove_proc_from_wait_queue): Remove function.
(_gpgme_wait_event_cb): New function.
(_gpgme_wait_one): Likewise.
(_gpgme_register_pipe_hanldler): Remove function.
(_gpgme_add_io_cb): New function.
(_gpgme_remove_io_cb): Likewise.
(_gpgme_freeze_fd): Remove function.
(_gpgme_thaw_fd): Remove function.
* rungpg.c (struct fd_data_map_s): Add new member TAG.
(struct gpg_object_s): Likewise for STATUS and COLON. Add member
IDX to CMD. Add new member IO_CBS.
(close_notify_handler): New variables POSSIBLY_DONE and NOT_DONE.
For each I/O callback, check if it should be unregistered. If all
callbacks have been unregistered, trigger GPGME_EVENT_DONE.
Remove member RUNNING.
(_gpgme_gpg_new): Initialize new members.
(_gpgme_gpg_release): Check PID not RUNNING. Don't call
_gpgme_remove_proc_from_wait_queue. Close GPG->CMD.FD if set.
(build_argv): Store away the index instead the file descriptor for
CMD.
(_gpgme_gpg_add_io_cb): New function.
(_gpgme_gpg_spawn): Use _gpgme_gpg_add_io_cb to register IO
callbacks.
(gpg_status_handler): Change return type to void, remove PID
argument, close filedescriptor if EOF or error occurs.
(read_status): Use _gpgme_gpg_add_io_cb instead _gpgme_thaw_fd.
Use IO_CBS->remove instead _gpgme_freeze_fd.
(gpg_colon_line_handler): Change return type to void, remove PID
argument, close filedescriptor if EOF or error occurs.
(command_cb): Use IO_CBS->remove instead _gpgme_freeze_fd.
(_gpgme_gpg_set_io_cbs): New function.
* rungpg.h (_gpgme_gpg_set_io_cbs): Prototype for
_gpgme_gpg_set_io_cbs.
* gpgme.h (GpgmeIOCb): New type.
(GpgmeRegisterIOCb): Likewise.
(GpgmeRemoveIOCb): Likewise.
(GpgmeEventIO): Likewise.
(GpgmeEventIOCb): Likewise.
(struct GpgmeIOCbs): New structure to hold I/O callbacks.
(gpgme_set_op_io_cbs): New prototype.
(gpgme_get_op_io_cbs): Likewise.
* ops.h: New prototype for _gpgme_op_event_cb. Remove prototypes
for _gpgme_freeze_fd and _gpgme_thaw_fd. Remove PID argument from
_gpgme_data_inbound_handler and _gpgme_data_outbound_handler
prototype. Add prototype for _gpgme_op_reset.
Add synchronous argument to _gpgme_decrypt_start prototype.
* io.h: Beautification.
* gpgme.c: Include "wait.h".
(gpgme_new): Initialize FDT.
(gpgme_set_io_cbs): New function.
(gpgme_get_io_cbs): Likewise.
(_gpgme_op_event_cb): Likewise.
* data.c (_gpgme_data_inbound_handler): Change return type to
void. Drop PID argument. Close FD on error and EOF.
(write_mem_data): Don't close FD here ...
(write_cb_data): ... or here ...
(_gpgme_data_outbound_handler): ... but here. Change return type
to void. Drop PID argument.
* context.h: Include "wait.h".
(struct gpgme_context_s): New members FDT and IO_CBS.
* op-support.c: New file.
* Makefile.am (libgpgme_la_SOURCES): Add op-support.c.
* ops.h: Add prototype for _gpgme_op_reset().
* decrypt.c (_gpgme_decrypt_start): New argument SYNCHRONOUS. Use
_gpgme_op_reset.
(gpgme_op_decrypt_start): Add synchronous argument.
(gpgme_op_decrypt): Likewise. Use _gpgme_wait_one instead
gpgme_wait.
* delete.c (gpgme_op_delete_start): Rename to ...
(_gpgme_op_delete_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_delete_start): Just a wrapper around
_gpgme_op_delete_start now.
(gpgme_op_delete): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* encrypt.c: Include "wait.h".
(ggpgme_op_encrypt_start): Rename to ...
(_gpgme_op_encrypt_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_encrypt_start): Just a wrapper around
_gpgme_op_encrypt_start now.
(gpgme_op_encrypt): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* encrypt_sign.c (gpgme_op_encrypt_sign_start): Rename to ...
(_gpgme_op_encrypt_sign_start): ... this. New argument
SYNCHRONOUS. Use _gpgme_op_reset. Make function static.
(gpgme_op_encrypt_sign_start): Just a wrapper around
_gpgme_op_encrypt_sign_start now.
(gpgme_op_encrypt_sign): Add synchronous argument. Use
_gpgme_wait_one instead gpgme_wait.
* export.c (gpgme_op_export_start): Rename to ...
(_gpgme_op_export_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_export_start): Just a wrapper around
_gpgme_op_export_start now.
(gpgme_op_export): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* genkey.c (gpgme_op_genkey_start): Rename to ...
(_gpgme_op_genkey_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_genkey_start): Just a wrapper around
_gpgme_op_genkey_start now.
(gpgme_op_genkey): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* import.c (gpgme_op_import_start): Rename to ...
(_gpgme_op_import_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_import_start): Just a wrapper around
_gpgme_op_import_start now.
(gpgme_op_import): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* keylist.c (gpgme_op_keylist_start): Use _gpgme_op_reset.
(gpgme_op_keylist_ext_start): Likewise.
* sign.c (gpgme_op_sign_start): Rename to ...
(_gpgme_op_sign_start): ... this. New argument SYNCHRONOUS. Use
_gpgme_op_reset. Make function static.
(gpgme_op_sign_start): Just a wrapper around _gpgme_op_sign_start
now.
(gpgme_op_sign): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* trustlist.c (gpgme_op_trustlist_start): Use _gpgme_op_reset.
* verify.c (gpgme_op_verify_start): Rename to ...
(_gpgme_op_verify_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_verify_start): Just a wrapper around
_gpgme_op_verify_start now.
(gpgme_op_verify): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* engine-gpgsm.c (iocb_data_t): New type.
(struct gpgsm_object_s): New member status_cb. Replace input_fd
and input_data with input_cb. Replace output_fd and output_data
with output_cb. Replace message_fd and message_data with
message_cb. New member io_cbs.
(_gpgme_gpgsm_new): Initialize all new members (and drop the old
ones).
(close_notify_handler): New variable POSSIBLY_DONE. For each I/O
callback, check if it should be unregistered. If all callbacks
have been unregistered, trigger GPGME_EVENT_DONE.
(_gpgme_gpgsm_release): Remove variable PID. Use new variable
names to close the file descriptors.
(_gpgme_gpgsm_op_decrypt): Use new variable names,
(_gpgme_gpgsm_op_encrypt): Likewise.
(_gpgme_gpgsm_op_genkey): Likewise.
(_gpgme_gpgsm_op_import): Likewise.
(_gpgme_gpgsm_op_keylist): Likewise.
(_gpgme_gpgsm_op_keylist_ext): Likewise.
(_gpgme_gpgsm_op_sign): Likewise.
(_gpgme_gpgsm_op_verify): Likewise.
(gpgsm_status_handler): Drop argument PID. Change return type to
void. Close status pipe before returning because of EOF or error.
(_gpgme_gpgsm_add_io_cb): New function.
(_gpgme_gpgsm_start): Use _gpgme_gpgsm_add_io_cb to register
callback function.
(_gpgme_gpgsm_set_io_cbs): New function.
* engine-gpgsm.h: New prototype for _gpgme_gpgsm_set_io_cbs.
* engine.c (_gpgme_engine_set_io_cbs): New function.
* engine.h: New prototype for _gpgme_engine_set_io_cbs.
2002-06-10 14:13:55 +00:00
|
|
|
|
_gpgme_fd_table_deinit (&ctx->fdt);
|
2002-01-15 19:58:41 +00:00
|
|
|
|
_gpgme_release_result (ctx);
|
2009-10-30 14:21:08 +00:00
|
|
|
|
_gpgme_signers_clear (ctx);
|
|
|
|
|
_gpgme_sig_notation_clear (ctx);
|
2016-10-25 15:27:49 +00:00
|
|
|
|
free (ctx->sender);
|
|
|
|
|
free (ctx->signers);
|
|
|
|
|
free (ctx->lc_ctype);
|
|
|
|
|
free (ctx->lc_messages);
|
2016-11-15 09:29:48 +00:00
|
|
|
|
free (ctx->override_session_key);
|
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* libgpgme.vers (GPGME_1.1): New version.
* engine-backend.h (struct engine_ops): Add argument FILE_NAME to
member get_version(). Add arguments FILE_NAME and HOME_DIR to
member new(). Change return type of get_file_name and get_version
to char *.
* engine-gpgsm.c (gpgsm_get_version): Change return type to char
pointer. Do not cache result.
(gpgsm_new): Add file_name and home_dir argument, and use them
instead of the defaults, if set.
* rungpg.c (struct engine_gpg): New member file_name.
(gpg_get_version): Change return type to char pointer, and do not
cache result.
(gpg_release): Free gpg->file_name.
(gpg_new): Take new arguments file_name and home_dir. Set the
--homedir argument if HOME_DIR is not NULL. Set gpg->file_name.
(start): Use gpg->file_name instead _gpgme_get_gpg_path, if set.
* engine.h (_gpgme_engine_info_copy, _gpgme_engine_info_release):
New prototypes.
(_gpgme_engine_new): Change first argument to gpgme_engine_info_t
info.
* engine.c: Include <assert.h>.
(gpgme_get_engine_info): Set *INFO within the lock. Move
ENGINE_INFO and ENGINE_INFO_LOCK to ....
(engine_info, engine_info_lock): ... here. New static variables.
(engine_get_version): Add file_name argument to
get_version invocation. Change return type to char pointer.
(gpgme_engine_check_version): Rewritten to free() the return value
of engine_get_version after using it.
(_gpgme_engine_info_release): New function.
(gpgme_get_engine_info): Rewritten.
(_gpgme_engine_info_copy): New function.
(_gpgme_set_engine_info): New function.
(gpgme_set_engine_info): New function.
(_gpgme_engine_new): Change first argument to gpgme_engine_info_t
info, and use that.
* gpgme.h (struct _gpgme_engine_info): Change type of file_name
and version to char * (remove the const). New member home_dir.
(gpgme_set_engine_info, gpgme_ctx_get_engine_info,
gpgme_ctx_set_engine_info): New prototypes.
* context.h (struct gpgme_context): New member engine_info.
* gpgme.c (gpgme_new): Allocate CTX->engine_info.
(gpgme_release): Deallocate CTX->engine_info.
(gpgme_ctx_get_engine_info, gpgme_ctx_set_engine_info): New
functions.
* op-support.c (_gpgme_op_reset): Look for correct engine info and
pass it to _gpgme_engine_new.
* version.c (gpgme_check_version): Adjust to
_gpgme_compare_versions returning an int.
(_gpgme_compare_versions): Return an int value, not a const char
pointer.
* ops.h (_gpgme_compare_versions): Same for prototype.
2004-12-07 18:25:54 +00:00
|
|
|
|
_gpgme_engine_info_release (ctx->engine_info);
|
2014-05-08 18:39:15 +00:00
|
|
|
|
ctx->engine_info = NULL;
|
2008-06-27 16:07:33 +00:00
|
|
|
|
DESTROY_LOCK (ctx->lock);
|
2002-10-08 Marcus Brinkmann <marcus@g10code.de>
* util.h (_gpgme_malloc, _gpgme_realloc, _gpgme_calloc,
_gpgme_strdup, _gpgme_free): Remove prototypes.
(xtrymalloc, xtrycalloc, xtryrealloc, xtrystrdup, xfree): Remove
macros.
* util.c: File removed.
* Makefile.am (libgpgme_la_SOURCES): Remove util.h.
* conversion.c (_gpgme_decode_c_string): Use malloc instead of
xtrymalloc, realloc instead of xtryrealloc, calloc instead of
xtrycalloc, free instead of xfree.
(_gpgme_data_append_percentstring_for_xml): Likewise.
* data.c (_gpgme_data_new, _gpgme_data_release): Likewise.
* data-compat.c (gpgme_data_new_from_filepart): Likewise.
* data-mem.c (mem_write, mem_release, gpgme_data_new_from_mem,
_gpgme_data_get_as_string): Likewise.
* debug.c (debug_init): Likewise.
* decrypt.c (_gpgme_release_decrypt_result): Likewise.
* delete.c (_gpgme_release_delete_result): Likewise.
* edit.c (_gpgme_release_edit_result, _gpgme_op_edit_start):
Likewise.
* encrypt.c (_gpgme_release_encrypt_result): Likewise.
* engine.c (_gpgme_engine_get_info, _gpgme_engine_new,
_gpgme_engine_release): Likewise.
* engine-gpgsm.c (_gpgme_gpgsm_new, _gpgme_gpgsm_release,
_gpgme_gpgsm_op_decrypt, _gpgme_gpgsm_op_delete,
gpgsm_set_recipients, _gpgme_gpgsm_op_encrypt,
_gpgme_gpgsm_op_export, _gpgme_gpgsm_op_genkey,
_gpgme_gpgsm_op_import, _gpgme_gpgsm_op_keylist,
_gpgme_gpgsm_op_keylist_ext, _gpgme_gpgsm_op_sign,
_gpgme_gpgsm_op_verify, gpgsm_status_handler): Likewise.
* genkey.c (_gpgme_release_genkey_result): Likewise.
* gpgme.c (gpgme_new, gpgme_release): Likewise.
* import.c (_gpgme_release_import_result): Likewise.
* key.c (_gpgme_key_cache_init, _gpgme_key_cache_add, key_new,
add_subkey, gpgme_key_release, _gpgme_key_append_name): Likewise.
* keylist.c (_gpgme_release_keylist_result, keylist_colon_handler,
_gpgme_op_keylist_event_cb, gpgme_op_keylist_next): Likewise.
* ops.h (test_and_allocate_result): Likewise.
* passphrase.c (_gpgme_release_passphrase_result,
_gpgme_passphrase_status_handler,
_gpgme_passphrase_command_handler): Likewise.
* progress.c (_gpgme_progress_status_handler): Likewise.
* recipient.c (gpgme_recipients_new, gpgme_recipients_release,
gpgme_recipients_add_name_with_validity): Likewise.
* rungpg.c (_gpgme_gpg_new, _gpgme_gpg_release,
_gpgme_gpg_add_arg, _gpgme_gpg_add_data,
_gpgme_gpg_set_colon_line_handler, free_argv, free_fd_data_map,
build_argv, _gpgme_gpg_spawn, read_status, read_colon_line):
Likewise.
* sign.c (_gpgme_release_sign_result): Likewise.
* signers.c (_gpgme_signers_add): Likewise.
* trustlist.c (trust_item_new, trustlist_colon_handler,
_gpgme_op_trustlist_event_cb, gpgme_op_trustlist_next,
gpgme_trustitem_release): Likewise.
* verify.c (_gpgme_release_verify_result, finish_sig): Likewise.
* version.c (gpgme_get_engine_info, _gpgme_get_program_version):
Likewise.
* w32-io.c (create_reader, create_writer, destroy_reader,
destroy_writer, build_commandline, _gpgme_io_spawn): Likewise.
* w32-sema.c (critsect_init, _gpgme_sema_cs_destroy): Likewise.
* w32-util.c (read_w32_registry_string): Likewise.
* wait.c (_gpgme_fd_table_deinit, _gpgme_fd_table_put,
_gpgme_wait_event_cb, _gpgme_add_io_cb, _gpgme_remove_io_cb)
* data-compat.c: Include <stdlib.h>.
2002-10-09 01:08:21 +00:00
|
|
|
|
free (ctx);
|
2000-10-27 17:46:09 +00:00
|
|
|
|
}
|
2000-10-27 14:55:24 +00:00
|
|
|
|
|
2003-05-29 03:21:02 +00:00
|
|
|
|
|
2009-06-15 17:05:47 +00:00
|
|
|
|
void
|
|
|
|
|
gpgme_result_ref (void *result)
|
|
|
|
|
{
|
2009-06-16 14:43:38 +00:00
|
|
|
|
struct ctx_op_data *data;
|
2009-06-15 17:05:47 +00:00
|
|
|
|
|
|
|
|
|
if (! result)
|
|
|
|
|
return;
|
|
|
|
|
|
2010-11-02 16:27:46 +00:00
|
|
|
|
data = (void*)((char*)result - sizeof (struct ctx_op_data));
|
2009-06-16 14:43:38 +00:00
|
|
|
|
|
2009-06-18 12:38:55 +00:00
|
|
|
|
assert (data->magic == CTX_OP_DATA_MAGIC);
|
|
|
|
|
|
2009-06-16 14:43:38 +00:00
|
|
|
|
LOCK (result_ref_lock);
|
2009-06-15 17:05:47 +00:00
|
|
|
|
data->references++;
|
2009-06-16 14:43:38 +00:00
|
|
|
|
UNLOCK (result_ref_lock);
|
2009-06-15 17:05:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
gpgme_result_unref (void *result)
|
|
|
|
|
{
|
2009-06-16 14:43:38 +00:00
|
|
|
|
struct ctx_op_data *data;
|
2009-06-15 17:05:47 +00:00
|
|
|
|
|
|
|
|
|
if (! result)
|
|
|
|
|
return;
|
|
|
|
|
|
2010-11-02 16:27:46 +00:00
|
|
|
|
data = (void*)((char*)result - sizeof (struct ctx_op_data));
|
2009-06-16 14:43:38 +00:00
|
|
|
|
|
2009-06-18 12:38:55 +00:00
|
|
|
|
assert (data->magic == CTX_OP_DATA_MAGIC);
|
|
|
|
|
|
2009-06-16 14:43:38 +00:00
|
|
|
|
LOCK (result_ref_lock);
|
|
|
|
|
if (--data->references)
|
2009-06-15 17:05:47 +00:00
|
|
|
|
{
|
2009-06-16 14:43:38 +00:00
|
|
|
|
UNLOCK (result_ref_lock);
|
|
|
|
|
return;
|
2009-06-15 17:05:47 +00:00
|
|
|
|
}
|
2009-06-17 13:42:52 +00:00
|
|
|
|
UNLOCK (result_ref_lock);
|
2009-06-16 14:43:38 +00:00
|
|
|
|
|
|
|
|
|
if (data->cleanup)
|
|
|
|
|
(*data->cleanup) (data->hook);
|
|
|
|
|
free (data);
|
2009-06-15 17:05:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-11-09 16:35:35 +00:00
|
|
|
|
void
|
2003-05-18 20:45:24 +00:00
|
|
|
|
_gpgme_release_result (gpgme_ctx_t ctx)
|
2000-11-09 16:35:35 +00:00
|
|
|
|
{
|
2003-01-30 Marcus Brinkmann <marcus@g10code.de>
* engine-gpgsm.c (status_handler): Do not close status fd at end
of function.
* ops.h (_gpgme_op_data_lookup): Add prototype.
* op-support.c: Include <stdlib.h>.
(_gpgme_op_data_lookup): New function.
* decrypt.c (_gpgme_release_decrypt_result): Function removed.
(struct decrypt_result_s): Rename to ...
(struct decrypt_resul): ... this.
(DecryptResult): New type.
(_gpgme_decrypt_status_handler): Don't use
test_and_allocate_result, but use _gpgme_op_data_lookup to
retrieve result data object.
* sign.c (_gpgme_release_sign_result): Function removed.
(release_sign_result): New function.
(struct sign_result_s): Rename to ...
(struct sign_result): ... this.
(SignResult): New type.
(_gpgme_sign_status_handler): Don't use
test_and_allocate_result, but use _gpgme_op_data_lookup to
retrieve result data object.
* encrypt.c (struct encrypt_result_s): Rename to ...
(struct encrypt_result): ... this.
(_gpgme_release_encrypt_result): Function removed.
(release_encrypt_result): New function.
(_gpgme_encrypt_status_handler): Don't use
test_and_allocate_result, but use _gpgme_op_data_lookup to
retrieve result data object.
* verify.c (struct verify_result_s): Rename to ...
(struct verify_result): ... this. Remove member next.
(VerifyResult): New type.
(_gpgme_release_verify_result): Function removed.
(release_verify_result): New function.
(finish_sig): Change first argument to type VerifyResult. Diddle
the type of the op_data structure.
(add_notation): Change first argument to type VerifyResult.
(_gpgme_verify_status_handler): Don't use
test_and_allocate_result, but use _gpgme_op_data_lookup to
retrieve result data object.
* passphrase.c (struct passphrase_result_s): Rename to ...
(struct passphrase_result): ... this. Remove member next.
(PassphraseResult): New type.
(_gpgme_release_passphrase_result): Function removed.
(release_passphrase_result): New function.
(_gpgme_passphrase_status_handler): Don't use
test_and_allocate_result, but use _gpgme_op_data_lookup to
retrieve result data object.
(_gpgme_passphrase_command_handler): Likewise.
* keylist.c (struct keylist_result_s): Rename to ...
(struct keylist_result): ... this. Remove member next.
(KeylistResult): New type.
(_gpgme_release_keylist_result): Function removed.
(release_keylist_result): New function.
(keylist_status_handler): Don't use
test_and_allocate_result, but use _gpgme_op_data_lookup to
retrieve result data object.
* edit.c (struct edit_result_s): Rename to ...
(struct edit_result): ... this. Remove member next.
(EditResult): New type.
(_gpgme_release_edit_result): Function removed.
(release_edit_result): New function.
(edit_status_handler): Don't use
test_and_allocate_result, but use _gpgme_op_data_lookup to
retrieve result data object.
(command_handler): Likewise.
* types.h (DecryptResult, SignResult, EncryptResult,
PassphraseResult, ImportResult, DeleteResult, GenKeyResult,
KeylistResult, EditResult): Types removed.
* ops.h: Don't include "types.h", but "gpgme.h" and "context.h".
(test_and_allocate_result): Remove macro.
(_gpgme_release_decrypt_result): Remove prototype.
(_gpgme_decrypt_result): Remove prototype.
(_gpgme_release_sign_result): Remove prototype.
(_gpgme_release_encrypt_result): Remove prototype.
(_gpgme_release_passphrase_result): Remove prototype.
(_gpgme_release_import_result): Remove prototype.
(_gpgme_release_delete_result): Remove prototype.
(_gpgme_release_genkey_result): Remove prototype.
(_gpgme_release_keylist_result): Remove prototype.
(_gpgme_release_edit_result): Remove prototype.
(_gpgme_release_verify_result): Remove prototype.
* gpgme.c (_gpgme_release_result): Rewritten.
* context.h (enum ctx_op_data_type): New enum.
(struct ctx_op_data): New structure.
(struct gpgme_context_s): Replace the member result with a member
op_data.
(fail_on_pending_request): Remove macro.
* op-support.c (_gpgme_op_reset): Expand macro
fail_on_pending_request.
* util.h: Don't include "types.h" or "debug.h", but include "gpgme.h".
2003-01-30 22:40:05 +00:00
|
|
|
|
struct ctx_op_data *data = ctx->op_data;
|
|
|
|
|
|
|
|
|
|
while (data)
|
|
|
|
|
{
|
|
|
|
|
struct ctx_op_data *next_data = data->next;
|
2009-06-15 17:05:47 +00:00
|
|
|
|
data->next = NULL;
|
|
|
|
|
gpgme_result_unref (data->hook);
|
2003-01-30 Marcus Brinkmann <marcus@g10code.de>
* engine-gpgsm.c (status_handler): Do not close status fd at end
of function.
* ops.h (_gpgme_op_data_lookup): Add prototype.
* op-support.c: Include <stdlib.h>.
(_gpgme_op_data_lookup): New function.
* decrypt.c (_gpgme_release_decrypt_result): Function removed.
(struct decrypt_result_s): Rename to ...
(struct decrypt_resul): ... this.
(DecryptResult): New type.
(_gpgme_decrypt_status_handler): Don't use
test_and_allocate_result, but use _gpgme_op_data_lookup to
retrieve result data object.
* sign.c (_gpgme_release_sign_result): Function removed.
(release_sign_result): New function.
(struct sign_result_s): Rename to ...
(struct sign_result): ... this.
(SignResult): New type.
(_gpgme_sign_status_handler): Don't use
test_and_allocate_result, but use _gpgme_op_data_lookup to
retrieve result data object.
* encrypt.c (struct encrypt_result_s): Rename to ...
(struct encrypt_result): ... this.
(_gpgme_release_encrypt_result): Function removed.
(release_encrypt_result): New function.
(_gpgme_encrypt_status_handler): Don't use
test_and_allocate_result, but use _gpgme_op_data_lookup to
retrieve result data object.
* verify.c (struct verify_result_s): Rename to ...
(struct verify_result): ... this. Remove member next.
(VerifyResult): New type.
(_gpgme_release_verify_result): Function removed.
(release_verify_result): New function.
(finish_sig): Change first argument to type VerifyResult. Diddle
the type of the op_data structure.
(add_notation): Change first argument to type VerifyResult.
(_gpgme_verify_status_handler): Don't use
test_and_allocate_result, but use _gpgme_op_data_lookup to
retrieve result data object.
* passphrase.c (struct passphrase_result_s): Rename to ...
(struct passphrase_result): ... this. Remove member next.
(PassphraseResult): New type.
(_gpgme_release_passphrase_result): Function removed.
(release_passphrase_result): New function.
(_gpgme_passphrase_status_handler): Don't use
test_and_allocate_result, but use _gpgme_op_data_lookup to
retrieve result data object.
(_gpgme_passphrase_command_handler): Likewise.
* keylist.c (struct keylist_result_s): Rename to ...
(struct keylist_result): ... this. Remove member next.
(KeylistResult): New type.
(_gpgme_release_keylist_result): Function removed.
(release_keylist_result): New function.
(keylist_status_handler): Don't use
test_and_allocate_result, but use _gpgme_op_data_lookup to
retrieve result data object.
* edit.c (struct edit_result_s): Rename to ...
(struct edit_result): ... this. Remove member next.
(EditResult): New type.
(_gpgme_release_edit_result): Function removed.
(release_edit_result): New function.
(edit_status_handler): Don't use
test_and_allocate_result, but use _gpgme_op_data_lookup to
retrieve result data object.
(command_handler): Likewise.
* types.h (DecryptResult, SignResult, EncryptResult,
PassphraseResult, ImportResult, DeleteResult, GenKeyResult,
KeylistResult, EditResult): Types removed.
* ops.h: Don't include "types.h", but "gpgme.h" and "context.h".
(test_and_allocate_result): Remove macro.
(_gpgme_release_decrypt_result): Remove prototype.
(_gpgme_decrypt_result): Remove prototype.
(_gpgme_release_sign_result): Remove prototype.
(_gpgme_release_encrypt_result): Remove prototype.
(_gpgme_release_passphrase_result): Remove prototype.
(_gpgme_release_import_result): Remove prototype.
(_gpgme_release_delete_result): Remove prototype.
(_gpgme_release_genkey_result): Remove prototype.
(_gpgme_release_keylist_result): Remove prototype.
(_gpgme_release_edit_result): Remove prototype.
(_gpgme_release_verify_result): Remove prototype.
* gpgme.c (_gpgme_release_result): Rewritten.
* context.h (enum ctx_op_data_type): New enum.
(struct ctx_op_data): New structure.
(struct gpgme_context_s): Replace the member result with a member
op_data.
(fail_on_pending_request): Remove macro.
* op-support.c (_gpgme_op_reset): Expand macro
fail_on_pending_request.
* util.h: Don't include "types.h" or "debug.h", but include "gpgme.h".
2003-01-30 22:40:05 +00:00
|
|
|
|
data = next_data;
|
|
|
|
|
}
|
|
|
|
|
ctx->op_data = NULL;
|
2001-08-28 11:11:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-01-15 19:58:41 +00:00
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
|
gpgme_error_t
|
|
|
|
|
gpgme_set_protocol (gpgme_ctx_t ctx, gpgme_protocol_t protocol)
|
2001-10-15 12:19:14 +00:00
|
|
|
|
{
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
TRACE_BEG2 (DEBUG_CTX, "gpgme_set_protocol", ctx, "protocol=%i (%s)",
|
|
|
|
|
protocol, gpgme_get_protocol_name (protocol)
|
2009-11-10 Marcus Brinkmann <marcus@g10code.de>
* configure.ac: Activate UIServer if FD passing is enabled and
Assuan is available.
m4/
2009-11-10 Marcus Brinkmann <marcus@g10code.de>
* libassuan.m4: Fix LIBASSUAN_VERSION.
src/
2009-11-10 Marcus Brinkmann <marcus@g10code.de>
* Makefile.am (uiserver_components): New variable.
(main_sources): Add it.
* ops.h, key.c (_gpgme_key_append_name): Take CONVERT argument,
implement it. Adjust callers.
(gpgme_key_from_uid): New function.
* gpgme.h.in (gpgme_protocol_t): Add GPGME_PROTOCOL_DEFAULT.
(gpgme_encrypt_flags_t): Add GPGME_ENCRYPT_PREPARE,
GPGME_ENCRYPT_EXPECT_SIGN.
(gpgme_set_sub_protocol, gpgme_key_from_uid): New functions.
* libgpgme.vers, gpgme.def: Add new functions.
* gpgme.c (gpgme_set_protocol): Add UIServer protocol.
(gpgme_set_sub_protocol): New function.
(gpgme_get_protocol_name): Add UIServer and default protocol.
* assuan-support.c: Return correct error values, implement
socketpair for POSIX.
* priv-io.h, posix-io.c, w32-io.c, w32-glib-io.c,
w32-qt-io.cpp (_gpgme_io_spawn): Add ATFORK and ATFORKVALUE
arguments. Implement it for POSIX. Adjust all callers.
* engine.h, engine-backend.h (_gpgme_engine_set_protocol)
(_gpgme_engine_op_decrypt_verify): New prototypes. Adjust all
users.
* engine.c (engine_ops, gpgme_get_engine_info): Add UIServer
engine.
(_gpgme_engine_set_protocol, _gpgme_engine_op_decrypt_verify): New
function.
* decrypt-verify.c (decrypt_verify_start): Call
_gpgme_engine_op_decrypt_verify.
* util.h, posix-util.c,
w32-util.c (_gpgme_get_uiserver_socket_path): New function.
* engine-gpgsm.c (gpgsm_set_fd): Fix _gpgme_io_pipe invocation.
* gpgme-tool.c: Some support for UIServer protocol.
* engine-uiserver.c: New file.
2009-11-10 09:07:19 +00:00
|
|
|
|
? gpgme_get_protocol_name (protocol) : "invalid");
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
|
2009-01-26 10:21:10 +00:00
|
|
|
|
if (protocol != GPGME_PROTOCOL_OpenPGP
|
|
|
|
|
&& protocol != GPGME_PROTOCOL_CMS
|
2009-10-30 14:21:08 +00:00
|
|
|
|
&& protocol != GPGME_PROTOCOL_GPGCONF
|
2009-10-22 16:44:07 +00:00
|
|
|
|
&& protocol != GPGME_PROTOCOL_ASSUAN
|
2009-11-10 Marcus Brinkmann <marcus@g10code.de>
* configure.ac: Activate UIServer if FD passing is enabled and
Assuan is available.
m4/
2009-11-10 Marcus Brinkmann <marcus@g10code.de>
* libassuan.m4: Fix LIBASSUAN_VERSION.
src/
2009-11-10 Marcus Brinkmann <marcus@g10code.de>
* Makefile.am (uiserver_components): New variable.
(main_sources): Add it.
* ops.h, key.c (_gpgme_key_append_name): Take CONVERT argument,
implement it. Adjust callers.
(gpgme_key_from_uid): New function.
* gpgme.h.in (gpgme_protocol_t): Add GPGME_PROTOCOL_DEFAULT.
(gpgme_encrypt_flags_t): Add GPGME_ENCRYPT_PREPARE,
GPGME_ENCRYPT_EXPECT_SIGN.
(gpgme_set_sub_protocol, gpgme_key_from_uid): New functions.
* libgpgme.vers, gpgme.def: Add new functions.
* gpgme.c (gpgme_set_protocol): Add UIServer protocol.
(gpgme_set_sub_protocol): New function.
(gpgme_get_protocol_name): Add UIServer and default protocol.
* assuan-support.c: Return correct error values, implement
socketpair for POSIX.
* priv-io.h, posix-io.c, w32-io.c, w32-glib-io.c,
w32-qt-io.cpp (_gpgme_io_spawn): Add ATFORK and ATFORKVALUE
arguments. Implement it for POSIX. Adjust all callers.
* engine.h, engine-backend.h (_gpgme_engine_set_protocol)
(_gpgme_engine_op_decrypt_verify): New prototypes. Adjust all
users.
* engine.c (engine_ops, gpgme_get_engine_info): Add UIServer
engine.
(_gpgme_engine_set_protocol, _gpgme_engine_op_decrypt_verify): New
function.
* decrypt-verify.c (decrypt_verify_start): Call
_gpgme_engine_op_decrypt_verify.
* util.h, posix-util.c,
w32-util.c (_gpgme_get_uiserver_socket_path): New function.
* engine-gpgsm.c (gpgsm_set_fd): Fix _gpgme_io_pipe invocation.
* gpgme-tool.c: Some support for UIServer protocol.
* engine-uiserver.c: New file.
2009-11-10 09:07:19 +00:00
|
|
|
|
&& protocol != GPGME_PROTOCOL_G13
|
2014-04-10 11:01:00 +00:00
|
|
|
|
&& protocol != GPGME_PROTOCOL_UISERVER
|
|
|
|
|
&& protocol != GPGME_PROTOCOL_SPAWN)
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
|
2002-02-27 20:59:20 +00:00
|
|
|
|
|
2011-05-26 14:01:26 +00:00
|
|
|
|
if (!ctx)
|
|
|
|
|
return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
|
|
|
|
|
|
2006-12-17 21:12:40 +00:00
|
|
|
|
if (ctx->protocol != protocol)
|
|
|
|
|
{
|
|
|
|
|
/* Shut down the engine when switching protocols. */
|
|
|
|
|
if (ctx->engine)
|
|
|
|
|
{
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
TRACE_LOG1 ("releasing ctx->engine=%p", ctx->engine);
|
2006-12-17 21:12:40 +00:00
|
|
|
|
_gpgme_engine_release (ctx->engine);
|
|
|
|
|
ctx->engine = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ctx->protocol = protocol;
|
|
|
|
|
}
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
return TRACE_ERR (0);
|
2001-10-15 12:19:14 +00:00
|
|
|
|
}
|
2001-08-28 11:11:10 +00:00
|
|
|
|
|
2003-04-25 13:42:02 +00:00
|
|
|
|
|
2003-05-18 20:45:24 +00:00
|
|
|
|
gpgme_protocol_t
|
|
|
|
|
gpgme_get_protocol (gpgme_ctx_t ctx)
|
2002-05-03 18:20:06 +00:00
|
|
|
|
{
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
TRACE2 (DEBUG_CTX, "gpgme_get_protocol", ctx,
|
|
|
|
|
"ctx->protocol=%i (%s)", ctx->protocol,
|
|
|
|
|
gpgme_get_protocol_name (ctx->protocol)
|
2009-11-10 Marcus Brinkmann <marcus@g10code.de>
* configure.ac: Activate UIServer if FD passing is enabled and
Assuan is available.
m4/
2009-11-10 Marcus Brinkmann <marcus@g10code.de>
* libassuan.m4: Fix LIBASSUAN_VERSION.
src/
2009-11-10 Marcus Brinkmann <marcus@g10code.de>
* Makefile.am (uiserver_components): New variable.
(main_sources): Add it.
* ops.h, key.c (_gpgme_key_append_name): Take CONVERT argument,
implement it. Adjust callers.
(gpgme_key_from_uid): New function.
* gpgme.h.in (gpgme_protocol_t): Add GPGME_PROTOCOL_DEFAULT.
(gpgme_encrypt_flags_t): Add GPGME_ENCRYPT_PREPARE,
GPGME_ENCRYPT_EXPECT_SIGN.
(gpgme_set_sub_protocol, gpgme_key_from_uid): New functions.
* libgpgme.vers, gpgme.def: Add new functions.
* gpgme.c (gpgme_set_protocol): Add UIServer protocol.
(gpgme_set_sub_protocol): New function.
(gpgme_get_protocol_name): Add UIServer and default protocol.
* assuan-support.c: Return correct error values, implement
socketpair for POSIX.
* priv-io.h, posix-io.c, w32-io.c, w32-glib-io.c,
w32-qt-io.cpp (_gpgme_io_spawn): Add ATFORK and ATFORKVALUE
arguments. Implement it for POSIX. Adjust all callers.
* engine.h, engine-backend.h (_gpgme_engine_set_protocol)
(_gpgme_engine_op_decrypt_verify): New prototypes. Adjust all
users.
* engine.c (engine_ops, gpgme_get_engine_info): Add UIServer
engine.
(_gpgme_engine_set_protocol, _gpgme_engine_op_decrypt_verify): New
function.
* decrypt-verify.c (decrypt_verify_start): Call
_gpgme_engine_op_decrypt_verify.
* util.h, posix-util.c,
w32-util.c (_gpgme_get_uiserver_socket_path): New function.
* engine-gpgsm.c (gpgsm_set_fd): Fix _gpgme_io_pipe invocation.
* gpgme-tool.c: Some support for UIServer protocol.
* engine-uiserver.c: New file.
2009-11-10 09:07:19 +00:00
|
|
|
|
? gpgme_get_protocol_name (ctx->protocol) : "invalid");
|
2011-05-26 14:01:26 +00:00
|
|
|
|
|
2003-04-25 13:42:02 +00:00
|
|
|
|
return ctx->protocol;
|
2002-05-03 18:20:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-01-15 19:58:41 +00:00
|
|
|
|
|
2009-11-10 Marcus Brinkmann <marcus@g10code.de>
* configure.ac: Activate UIServer if FD passing is enabled and
Assuan is available.
m4/
2009-11-10 Marcus Brinkmann <marcus@g10code.de>
* libassuan.m4: Fix LIBASSUAN_VERSION.
src/
2009-11-10 Marcus Brinkmann <marcus@g10code.de>
* Makefile.am (uiserver_components): New variable.
(main_sources): Add it.
* ops.h, key.c (_gpgme_key_append_name): Take CONVERT argument,
implement it. Adjust callers.
(gpgme_key_from_uid): New function.
* gpgme.h.in (gpgme_protocol_t): Add GPGME_PROTOCOL_DEFAULT.
(gpgme_encrypt_flags_t): Add GPGME_ENCRYPT_PREPARE,
GPGME_ENCRYPT_EXPECT_SIGN.
(gpgme_set_sub_protocol, gpgme_key_from_uid): New functions.
* libgpgme.vers, gpgme.def: Add new functions.
* gpgme.c (gpgme_set_protocol): Add UIServer protocol.
(gpgme_set_sub_protocol): New function.
(gpgme_get_protocol_name): Add UIServer and default protocol.
* assuan-support.c: Return correct error values, implement
socketpair for POSIX.
* priv-io.h, posix-io.c, w32-io.c, w32-glib-io.c,
w32-qt-io.cpp (_gpgme_io_spawn): Add ATFORK and ATFORKVALUE
arguments. Implement it for POSIX. Adjust all callers.
* engine.h, engine-backend.h (_gpgme_engine_set_protocol)
(_gpgme_engine_op_decrypt_verify): New prototypes. Adjust all
users.
* engine.c (engine_ops, gpgme_get_engine_info): Add UIServer
engine.
(_gpgme_engine_set_protocol, _gpgme_engine_op_decrypt_verify): New
function.
* decrypt-verify.c (decrypt_verify_start): Call
_gpgme_engine_op_decrypt_verify.
* util.h, posix-util.c,
w32-util.c (_gpgme_get_uiserver_socket_path): New function.
* engine-gpgsm.c (gpgsm_set_fd): Fix _gpgme_io_pipe invocation.
* gpgme-tool.c: Some support for UIServer protocol.
* engine-uiserver.c: New file.
2009-11-10 09:07:19 +00:00
|
|
|
|
gpgme_error_t
|
|
|
|
|
gpgme_set_sub_protocol (gpgme_ctx_t ctx, gpgme_protocol_t protocol)
|
|
|
|
|
{
|
2009-11-10 14:49:35 +00:00
|
|
|
|
TRACE2 (DEBUG_CTX, "gpgme_set_sub_protocol", ctx, "protocol=%i (%s)",
|
|
|
|
|
protocol, gpgme_get_protocol_name (protocol)
|
|
|
|
|
? gpgme_get_protocol_name (protocol) : "invalid");
|
2011-05-26 14:01:26 +00:00
|
|
|
|
|
|
|
|
|
if (!ctx)
|
|
|
|
|
return gpg_error (GPG_ERR_INV_VALUE);
|
|
|
|
|
|
2009-11-10 14:49:35 +00:00
|
|
|
|
ctx->sub_protocol = protocol;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2009-11-10 Marcus Brinkmann <marcus@g10code.de>
* configure.ac: Activate UIServer if FD passing is enabled and
Assuan is available.
m4/
2009-11-10 Marcus Brinkmann <marcus@g10code.de>
* libassuan.m4: Fix LIBASSUAN_VERSION.
src/
2009-11-10 Marcus Brinkmann <marcus@g10code.de>
* Makefile.am (uiserver_components): New variable.
(main_sources): Add it.
* ops.h, key.c (_gpgme_key_append_name): Take CONVERT argument,
implement it. Adjust callers.
(gpgme_key_from_uid): New function.
* gpgme.h.in (gpgme_protocol_t): Add GPGME_PROTOCOL_DEFAULT.
(gpgme_encrypt_flags_t): Add GPGME_ENCRYPT_PREPARE,
GPGME_ENCRYPT_EXPECT_SIGN.
(gpgme_set_sub_protocol, gpgme_key_from_uid): New functions.
* libgpgme.vers, gpgme.def: Add new functions.
* gpgme.c (gpgme_set_protocol): Add UIServer protocol.
(gpgme_set_sub_protocol): New function.
(gpgme_get_protocol_name): Add UIServer and default protocol.
* assuan-support.c: Return correct error values, implement
socketpair for POSIX.
* priv-io.h, posix-io.c, w32-io.c, w32-glib-io.c,
w32-qt-io.cpp (_gpgme_io_spawn): Add ATFORK and ATFORKVALUE
arguments. Implement it for POSIX. Adjust all callers.
* engine.h, engine-backend.h (_gpgme_engine_set_protocol)
(_gpgme_engine_op_decrypt_verify): New prototypes. Adjust all
users.
* engine.c (engine_ops, gpgme_get_engine_info): Add UIServer
engine.
(_gpgme_engine_set_protocol, _gpgme_engine_op_decrypt_verify): New
function.
* decrypt-verify.c (decrypt_verify_start): Call
_gpgme_engine_op_decrypt_verify.
* util.h, posix-util.c,
w32-util.c (_gpgme_get_uiserver_socket_path): New function.
* engine-gpgsm.c (gpgsm_set_fd): Fix _gpgme_io_pipe invocation.
* gpgme-tool.c: Some support for UIServer protocol.
* engine-uiserver.c: New file.
2009-11-10 09:07:19 +00:00
|
|
|
|
|
2009-11-10 14:49:35 +00:00
|
|
|
|
|
2014-03-11 12:54:21 +00:00
|
|
|
|
gpgme_protocol_t
|
2009-11-10 14:49:35 +00:00
|
|
|
|
gpgme_get_sub_protocol (gpgme_ctx_t ctx)
|
|
|
|
|
{
|
|
|
|
|
TRACE2 (DEBUG_CTX, "gpgme_get_sub_protocol", ctx,
|
|
|
|
|
"ctx->sub_protocol=%i (%s)", ctx->sub_protocol,
|
|
|
|
|
gpgme_get_protocol_name (ctx->sub_protocol)
|
|
|
|
|
? gpgme_get_protocol_name (ctx->sub_protocol) : "invalid");
|
2011-05-26 14:01:26 +00:00
|
|
|
|
|
2009-11-10 14:49:35 +00:00
|
|
|
|
return ctx->sub_protocol;
|
2009-11-10 Marcus Brinkmann <marcus@g10code.de>
* configure.ac: Activate UIServer if FD passing is enabled and
Assuan is available.
m4/
2009-11-10 Marcus Brinkmann <marcus@g10code.de>
* libassuan.m4: Fix LIBASSUAN_VERSION.
src/
2009-11-10 Marcus Brinkmann <marcus@g10code.de>
* Makefile.am (uiserver_components): New variable.
(main_sources): Add it.
* ops.h, key.c (_gpgme_key_append_name): Take CONVERT argument,
implement it. Adjust callers.
(gpgme_key_from_uid): New function.
* gpgme.h.in (gpgme_protocol_t): Add GPGME_PROTOCOL_DEFAULT.
(gpgme_encrypt_flags_t): Add GPGME_ENCRYPT_PREPARE,
GPGME_ENCRYPT_EXPECT_SIGN.
(gpgme_set_sub_protocol, gpgme_key_from_uid): New functions.
* libgpgme.vers, gpgme.def: Add new functions.
* gpgme.c (gpgme_set_protocol): Add UIServer protocol.
(gpgme_set_sub_protocol): New function.
(gpgme_get_protocol_name): Add UIServer and default protocol.
* assuan-support.c: Return correct error values, implement
socketpair for POSIX.
* priv-io.h, posix-io.c, w32-io.c, w32-glib-io.c,
w32-qt-io.cpp (_gpgme_io_spawn): Add ATFORK and ATFORKVALUE
arguments. Implement it for POSIX. Adjust all callers.
* engine.h, engine-backend.h (_gpgme_engine_set_protocol)
(_gpgme_engine_op_decrypt_verify): New prototypes. Adjust all
users.
* engine.c (engine_ops, gpgme_get_engine_info): Add UIServer
engine.
(_gpgme_engine_set_protocol, _gpgme_engine_op_decrypt_verify): New
function.
* decrypt-verify.c (decrypt_verify_start): Call
_gpgme_engine_op_decrypt_verify.
* util.h, posix-util.c,
w32-util.c (_gpgme_get_uiserver_socket_path): New function.
* engine-gpgsm.c (gpgsm_set_fd): Fix _gpgme_io_pipe invocation.
* gpgme-tool.c: Some support for UIServer protocol.
* engine-uiserver.c: New file.
2009-11-10 09:07:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-01-30 11:54:23 +00:00
|
|
|
|
const char *
|
2003-05-18 20:45:24 +00:00
|
|
|
|
gpgme_get_protocol_name (gpgme_protocol_t protocol)
|
2003-01-30 11:54:23 +00:00
|
|
|
|
{
|
|
|
|
|
switch (protocol)
|
|
|
|
|
{
|
|
|
|
|
case GPGME_PROTOCOL_OpenPGP:
|
|
|
|
|
return "OpenPGP";
|
|
|
|
|
|
|
|
|
|
case GPGME_PROTOCOL_CMS:
|
|
|
|
|
return "CMS";
|
|
|
|
|
|
2009-10-30 14:21:08 +00:00
|
|
|
|
case GPGME_PROTOCOL_GPGCONF:
|
|
|
|
|
return "GPGCONF";
|
|
|
|
|
|
2009-01-26 10:21:10 +00:00
|
|
|
|
case GPGME_PROTOCOL_ASSUAN:
|
|
|
|
|
return "Assuan";
|
|
|
|
|
|
2009-10-22 16:44:07 +00:00
|
|
|
|
case GPGME_PROTOCOL_G13:
|
|
|
|
|
return "G13";
|
|
|
|
|
|
2009-11-10 Marcus Brinkmann <marcus@g10code.de>
* configure.ac: Activate UIServer if FD passing is enabled and
Assuan is available.
m4/
2009-11-10 Marcus Brinkmann <marcus@g10code.de>
* libassuan.m4: Fix LIBASSUAN_VERSION.
src/
2009-11-10 Marcus Brinkmann <marcus@g10code.de>
* Makefile.am (uiserver_components): New variable.
(main_sources): Add it.
* ops.h, key.c (_gpgme_key_append_name): Take CONVERT argument,
implement it. Adjust callers.
(gpgme_key_from_uid): New function.
* gpgme.h.in (gpgme_protocol_t): Add GPGME_PROTOCOL_DEFAULT.
(gpgme_encrypt_flags_t): Add GPGME_ENCRYPT_PREPARE,
GPGME_ENCRYPT_EXPECT_SIGN.
(gpgme_set_sub_protocol, gpgme_key_from_uid): New functions.
* libgpgme.vers, gpgme.def: Add new functions.
* gpgme.c (gpgme_set_protocol): Add UIServer protocol.
(gpgme_set_sub_protocol): New function.
(gpgme_get_protocol_name): Add UIServer and default protocol.
* assuan-support.c: Return correct error values, implement
socketpair for POSIX.
* priv-io.h, posix-io.c, w32-io.c, w32-glib-io.c,
w32-qt-io.cpp (_gpgme_io_spawn): Add ATFORK and ATFORKVALUE
arguments. Implement it for POSIX. Adjust all callers.
* engine.h, engine-backend.h (_gpgme_engine_set_protocol)
(_gpgme_engine_op_decrypt_verify): New prototypes. Adjust all
users.
* engine.c (engine_ops, gpgme_get_engine_info): Add UIServer
engine.
(_gpgme_engine_set_protocol, _gpgme_engine_op_decrypt_verify): New
function.
* decrypt-verify.c (decrypt_verify_start): Call
_gpgme_engine_op_decrypt_verify.
* util.h, posix-util.c,
w32-util.c (_gpgme_get_uiserver_socket_path): New function.
* engine-gpgsm.c (gpgsm_set_fd): Fix _gpgme_io_pipe invocation.
* gpgme-tool.c: Some support for UIServer protocol.
* engine-uiserver.c: New file.
2009-11-10 09:07:19 +00:00
|
|
|
|
case GPGME_PROTOCOL_UISERVER:
|
|
|
|
|
return "UIServer";
|
|
|
|
|
|
2014-04-10 11:01:00 +00:00
|
|
|
|
case GPGME_PROTOCOL_SPAWN:
|
|
|
|
|
return "Spawn";
|
|
|
|
|
|
2009-11-10 Marcus Brinkmann <marcus@g10code.de>
* configure.ac: Activate UIServer if FD passing is enabled and
Assuan is available.
m4/
2009-11-10 Marcus Brinkmann <marcus@g10code.de>
* libassuan.m4: Fix LIBASSUAN_VERSION.
src/
2009-11-10 Marcus Brinkmann <marcus@g10code.de>
* Makefile.am (uiserver_components): New variable.
(main_sources): Add it.
* ops.h, key.c (_gpgme_key_append_name): Take CONVERT argument,
implement it. Adjust callers.
(gpgme_key_from_uid): New function.
* gpgme.h.in (gpgme_protocol_t): Add GPGME_PROTOCOL_DEFAULT.
(gpgme_encrypt_flags_t): Add GPGME_ENCRYPT_PREPARE,
GPGME_ENCRYPT_EXPECT_SIGN.
(gpgme_set_sub_protocol, gpgme_key_from_uid): New functions.
* libgpgme.vers, gpgme.def: Add new functions.
* gpgme.c (gpgme_set_protocol): Add UIServer protocol.
(gpgme_set_sub_protocol): New function.
(gpgme_get_protocol_name): Add UIServer and default protocol.
* assuan-support.c: Return correct error values, implement
socketpair for POSIX.
* priv-io.h, posix-io.c, w32-io.c, w32-glib-io.c,
w32-qt-io.cpp (_gpgme_io_spawn): Add ATFORK and ATFORKVALUE
arguments. Implement it for POSIX. Adjust all callers.
* engine.h, engine-backend.h (_gpgme_engine_set_protocol)
(_gpgme_engine_op_decrypt_verify): New prototypes. Adjust all
users.
* engine.c (engine_ops, gpgme_get_engine_info): Add UIServer
engine.
(_gpgme_engine_set_protocol, _gpgme_engine_op_decrypt_verify): New
function.
* decrypt-verify.c (decrypt_verify_start): Call
_gpgme_engine_op_decrypt_verify.
* util.h, posix-util.c,
w32-util.c (_gpgme_get_uiserver_socket_path): New function.
* engine-gpgsm.c (gpgsm_set_fd): Fix _gpgme_io_pipe invocation.
* gpgme-tool.c: Some support for UIServer protocol.
* engine-uiserver.c: New file.
2009-11-10 09:07:19 +00:00
|
|
|
|
case GPGME_PROTOCOL_DEFAULT:
|
|
|
|
|
return "default";
|
|
|
|
|
|
2007-09-27 12:17:24 +00:00
|
|
|
|
case GPGME_PROTOCOL_UNKNOWN:
|
|
|
|
|
return "unknown";
|
|
|
|
|
|
2003-01-30 11:54:23 +00:00
|
|
|
|
default:
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-25 15:27:49 +00:00
|
|
|
|
|
|
|
|
|
/* Store the sender's address in the context. ADDRESS is addr-spec of
|
|
|
|
|
* mailbox but my also be a complete mailbox, in which case this
|
|
|
|
|
* function extracts the addr-spec from it. Returns 0 on success or
|
|
|
|
|
* an error code if no valid addr-spec could be extracted from
|
|
|
|
|
* ADDRESS. */
|
|
|
|
|
gpgme_error_t
|
|
|
|
|
gpgme_set_sender (gpgme_ctx_t ctx, const char *address)
|
|
|
|
|
{
|
|
|
|
|
char *p = NULL;
|
|
|
|
|
|
|
|
|
|
TRACE_BEG1 (DEBUG_CTX, "gpgme_set_sender", ctx, "sender='%s'",
|
|
|
|
|
address?address:"(null)");
|
|
|
|
|
|
|
|
|
|
if (!ctx || (address && !(p = _gpgme_mailbox_from_userid (address))))
|
|
|
|
|
return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
|
|
|
|
|
|
|
|
|
|
free (ctx->sender);
|
|
|
|
|
ctx->sender = p;
|
|
|
|
|
return TRACE_ERR (0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Return the sender's address (addr-spec part) from the context or
|
|
|
|
|
* NULL if none was set. The returned value is valid as long as the
|
|
|
|
|
* CTX is valid and gpgme_set_sender has not been used. */
|
|
|
|
|
const char *
|
|
|
|
|
gpgme_get_sender (gpgme_ctx_t ctx)
|
|
|
|
|
{
|
|
|
|
|
TRACE1 (DEBUG_CTX, "gpgme_get_sender", ctx, "sender='%s'",
|
|
|
|
|
ctx?ctx->sender:"");
|
|
|
|
|
|
|
|
|
|
return ctx->sender;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-05-29 03:21:02 +00:00
|
|
|
|
/* Enable or disable the use of an ascii armor for all output. */
|
2000-11-16 14:53:52 +00:00
|
|
|
|
void
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
gpgme_set_armor (gpgme_ctx_t ctx, int use_armor)
|
2000-11-16 14:53:52 +00:00
|
|
|
|
{
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
TRACE2 (DEBUG_CTX, "gpgme_set_armor", ctx, "use_armor=%i (%s)",
|
|
|
|
|
use_armor, use_armor ? "yes" : "no");
|
2011-05-26 14:01:26 +00:00
|
|
|
|
|
|
|
|
|
if (!ctx)
|
|
|
|
|
return;
|
|
|
|
|
|
2016-11-10 23:47:48 +00:00
|
|
|
|
ctx->use_armor = !!use_armor;
|
2000-11-16 14:53:52 +00:00
|
|
|
|
}
|
2000-11-07 13:32:38 +00:00
|
|
|
|
|
2001-07-31 15:21:58 +00:00
|
|
|
|
|
2003-05-29 03:21:02 +00:00
|
|
|
|
/* Return the state of the armor flag. */
|
2002-02-27 20:59:20 +00:00
|
|
|
|
int
|
2003-05-18 20:45:24 +00:00
|
|
|
|
gpgme_get_armor (gpgme_ctx_t ctx)
|
2001-07-31 15:21:58 +00:00
|
|
|
|
{
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
TRACE2 (DEBUG_CTX, "gpgme_get_armor", ctx, "ctx->use_armor=%i (%s)",
|
|
|
|
|
ctx->use_armor, ctx->use_armor ? "yes" : "no");
|
2003-05-29 03:21:02 +00:00
|
|
|
|
return ctx->use_armor;
|
2001-07-31 15:21:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2016-11-15 08:24:17 +00:00
|
|
|
|
/* Set the flag NAME for CTX to VALUE. The supported flags are:
|
|
|
|
|
*
|
|
|
|
|
* - full-status :: With a value of "1" the status callback set by
|
|
|
|
|
* gpgme_set_status_cb returns all status lines
|
|
|
|
|
* except for PROGRESS lines. With the default of
|
|
|
|
|
* "0" the status callback is only called in certain
|
|
|
|
|
* situations.
|
|
|
|
|
*/
|
|
|
|
|
gpgme_error_t
|
|
|
|
|
gpgme_set_ctx_flag (gpgme_ctx_t ctx, const char *name, const char *value)
|
|
|
|
|
{
|
|
|
|
|
gpgme_error_t err = 0;
|
|
|
|
|
int abool;
|
|
|
|
|
|
|
|
|
|
TRACE2 (DEBUG_CTX, "gpgme_set_ctx_flag", ctx,
|
|
|
|
|
"name='%s' value='%s'",
|
|
|
|
|
name? name:"(null)", value?value:"(null)");
|
|
|
|
|
|
|
|
|
|
abool = (value && *value)? !!atoi (value) : 0;
|
|
|
|
|
|
|
|
|
|
if (!ctx || !name || !value)
|
|
|
|
|
err = gpg_error (GPG_ERR_INV_VALUE);
|
|
|
|
|
else if (!strcmp (name, "full-status"))
|
|
|
|
|
{
|
|
|
|
|
ctx->full_status = abool;
|
|
|
|
|
}
|
|
|
|
|
else if (!strcmp (name, "raw-description"))
|
|
|
|
|
{
|
|
|
|
|
ctx->raw_description = abool;
|
|
|
|
|
}
|
2016-11-15 09:29:48 +00:00
|
|
|
|
else if (!strcmp (name, "export-session-key"))
|
|
|
|
|
{
|
|
|
|
|
ctx->export_session_keys = abool;
|
|
|
|
|
}
|
|
|
|
|
else if (!strcmp (name, "override-session-key"))
|
|
|
|
|
{
|
|
|
|
|
free (ctx->override_session_key);
|
|
|
|
|
ctx->override_session_key = strdup (value);
|
|
|
|
|
if (!ctx->override_session_key)
|
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
|
}
|
2016-11-15 08:24:17 +00:00
|
|
|
|
else
|
|
|
|
|
err = gpg_error (GPG_ERR_UNKNOWN_NAME);
|
|
|
|
|
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Get the context flag named NAME. See gpgme_set_ctx_flag for a list
|
|
|
|
|
* of valid names. If the NAME is unknown NULL is returned. For a
|
|
|
|
|
* boolean flag an empty string is returned for False and the string
|
|
|
|
|
* "1" for True; thus either atoi or a simple string test can be
|
2016-11-15 09:29:48 +00:00
|
|
|
|
* used. */
|
2016-11-15 08:24:17 +00:00
|
|
|
|
const char *
|
|
|
|
|
gpgme_get_ctx_flag (gpgme_ctx_t ctx, const char *name)
|
|
|
|
|
{
|
|
|
|
|
if (!ctx || !name)
|
|
|
|
|
return NULL;
|
|
|
|
|
else if (!strcmp (name, "full-status"))
|
|
|
|
|
{
|
|
|
|
|
return ctx->full_status? "1":"";
|
|
|
|
|
}
|
|
|
|
|
else if (!strcmp (name, "raw-description"))
|
|
|
|
|
{
|
|
|
|
|
return ctx->raw_description? "1":"";
|
|
|
|
|
}
|
2016-11-15 09:29:48 +00:00
|
|
|
|
else if (!strcmp (name, "export-session-key"))
|
|
|
|
|
{
|
|
|
|
|
return ctx->export_session_keys? "1":"";
|
|
|
|
|
}
|
|
|
|
|
else if (!strcmp (name, "override-session-key"))
|
|
|
|
|
{
|
|
|
|
|
return ctx->override_session_key? ctx->override_session_key : "";
|
|
|
|
|
}
|
2016-11-15 08:24:17 +00:00
|
|
|
|
else
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-05-29 03:21:02 +00:00
|
|
|
|
/* Enable or disable the use of the special textmode. Textmode is for
|
|
|
|
|
example used for the RFC2015 signatures; note that the updated RFC
|
|
|
|
|
3156 mandates that the MUA does some preparations so that textmode
|
|
|
|
|
is not needed anymore. */
|
2000-11-16 14:53:52 +00:00
|
|
|
|
void
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
gpgme_set_textmode (gpgme_ctx_t ctx, int use_textmode)
|
2000-11-16 14:53:52 +00:00
|
|
|
|
{
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
TRACE2 (DEBUG_CTX, "gpgme_set_textmode", ctx, "use_textmode=%i (%s)",
|
|
|
|
|
use_textmode, use_textmode ? "yes" : "no");
|
2011-05-26 14:01:26 +00:00
|
|
|
|
|
|
|
|
|
if (!ctx)
|
|
|
|
|
return;
|
|
|
|
|
|
2016-11-10 23:47:48 +00:00
|
|
|
|
ctx->use_textmode = !!use_textmode;
|
2000-11-16 14:53:52 +00:00
|
|
|
|
}
|
2000-11-07 13:32:38 +00:00
|
|
|
|
|
2003-05-29 03:21:02 +00:00
|
|
|
|
/* Return the state of the textmode flag. */
|
2002-02-27 20:59:20 +00:00
|
|
|
|
int
|
2003-05-18 20:45:24 +00:00
|
|
|
|
gpgme_get_textmode (gpgme_ctx_t ctx)
|
2001-07-31 15:21:58 +00:00
|
|
|
|
{
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
TRACE2 (DEBUG_CTX, "gpgme_get_textmode", ctx, "ctx->use_textmode=%i (%s)",
|
|
|
|
|
ctx->use_textmode, ctx->use_textmode ? "yes" : "no");
|
2003-05-29 03:21:02 +00:00
|
|
|
|
return ctx->use_textmode;
|
2001-07-31 15:21:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2015-07-02 08:19:04 +00:00
|
|
|
|
/* Enable offline mode for this context. In offline mode dirmngr
|
|
|
|
|
will be disabled. */
|
|
|
|
|
void
|
|
|
|
|
gpgme_set_offline (gpgme_ctx_t ctx, int offline)
|
|
|
|
|
{
|
|
|
|
|
TRACE2 (DEBUG_CTX, "gpgme_set_offline", ctx, "offline=%i (%s)",
|
|
|
|
|
offline, offline ? "yes" : "no");
|
|
|
|
|
|
|
|
|
|
if (!ctx)
|
|
|
|
|
return;
|
|
|
|
|
|
2016-11-10 23:47:48 +00:00
|
|
|
|
ctx->offline = !!offline;
|
2015-07-02 08:19:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return the state of the offline flag. */
|
|
|
|
|
int
|
|
|
|
|
gpgme_get_offline (gpgme_ctx_t ctx)
|
|
|
|
|
{
|
|
|
|
|
TRACE2 (DEBUG_CTX, "gpgme_get_offline", ctx, "ctx->offline=%i (%s)",
|
|
|
|
|
ctx->offline, ctx->offline ? "yes" : "no");
|
|
|
|
|
return ctx->offline;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-05-29 03:21:02 +00:00
|
|
|
|
/* Set the number of certifications to include in an S/MIME message.
|
2005-04-28 16:11:34 +00:00
|
|
|
|
The default is GPGME_INCLUDE_CERTS_DEFAULT. -1 means all certs,
|
|
|
|
|
and -2 means all certs except the root cert. */
|
2002-02-25 18:31:07 +00:00
|
|
|
|
void
|
2003-05-18 20:45:24 +00:00
|
|
|
|
gpgme_set_include_certs (gpgme_ctx_t ctx, int nr_of_certs)
|
2002-02-25 18:31:07 +00:00
|
|
|
|
{
|
2011-05-26 14:01:26 +00:00
|
|
|
|
if (!ctx)
|
|
|
|
|
return;
|
|
|
|
|
|
2005-04-28 16:11:34 +00:00
|
|
|
|
if (nr_of_certs == GPGME_INCLUDE_CERTS_DEFAULT)
|
|
|
|
|
ctx->include_certs = GPGME_INCLUDE_CERTS_DEFAULT;
|
|
|
|
|
else if (nr_of_certs < -2)
|
2002-02-25 18:31:07 +00:00
|
|
|
|
ctx->include_certs = -2;
|
|
|
|
|
else
|
|
|
|
|
ctx->include_certs = nr_of_certs;
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
|
|
|
|
|
TRACE2 (DEBUG_CTX, "gpgme_set_include_certs", ctx, "nr_of_certs=%i%s",
|
|
|
|
|
nr_of_certs, nr_of_certs == ctx->include_certs ? "" : " (-2)");
|
2002-02-25 18:31:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-05-29 03:21:02 +00:00
|
|
|
|
/* Get the number of certifications to include in an S/MIME
|
|
|
|
|
message. */
|
2002-02-25 18:31:07 +00:00
|
|
|
|
int
|
2003-05-18 20:45:24 +00:00
|
|
|
|
gpgme_get_include_certs (gpgme_ctx_t ctx)
|
2002-02-25 18:31:07 +00:00
|
|
|
|
{
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
TRACE1 (DEBUG_CTX, "gpgme_get_include_certs", ctx, "ctx->include_certs=%i",
|
|
|
|
|
ctx->include_certs);
|
2002-02-25 18:31:07 +00:00
|
|
|
|
return ctx->include_certs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-05-29 03:21:02 +00:00
|
|
|
|
/* This function changes the default behaviour of the keylisting
|
|
|
|
|
functions. MODE is a bitwise-OR of the GPGME_KEYLIST_* flags. The
|
|
|
|
|
default mode is GPGME_KEYLIST_MODE_LOCAL. */
|
2003-05-18 20:45:24 +00:00
|
|
|
|
gpgme_error_t
|
2003-05-29 03:21:02 +00:00
|
|
|
|
gpgme_set_keylist_mode (gpgme_ctx_t ctx, gpgme_keylist_mode_t mode)
|
2001-01-08 20:40:25 +00:00
|
|
|
|
{
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
TRACE1 (DEBUG_CTX, "gpgme_set_keylist_mode", ctx, "keylist_mode=0x%x",
|
|
|
|
|
mode);
|
|
|
|
|
|
2011-05-26 14:01:26 +00:00
|
|
|
|
if (!ctx)
|
|
|
|
|
return gpg_error (GPG_ERR_INV_VALUE);
|
|
|
|
|
|
2002-01-15 19:58:41 +00:00
|
|
|
|
ctx->keylist_mode = mode;
|
2002-02-06 00:08:47 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-29 03:21:02 +00:00
|
|
|
|
/* This function returns the default behaviour of the keylisting
|
|
|
|
|
functions. */
|
|
|
|
|
gpgme_keylist_mode_t
|
2003-05-18 20:45:24 +00:00
|
|
|
|
gpgme_get_keylist_mode (gpgme_ctx_t ctx)
|
2002-02-06 00:08:47 +00:00
|
|
|
|
{
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
TRACE1 (DEBUG_CTX, "gpgme_get_keylist_mode", ctx,
|
|
|
|
|
"ctx->keylist_mode=0x%x", ctx->keylist_mode);
|
2002-02-06 00:08:47 +00:00
|
|
|
|
return ctx->keylist_mode;
|
2001-01-08 20:40:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2013-02-07 19:59:16 +00:00
|
|
|
|
/* Set the pinentry mode for CTX to MODE. */
|
|
|
|
|
gpgme_error_t
|
2014-02-12 19:36:08 +00:00
|
|
|
|
gpgme_set_pinentry_mode (gpgme_ctx_t ctx, gpgme_pinentry_mode_t mode)
|
2013-02-07 19:59:16 +00:00
|
|
|
|
{
|
|
|
|
|
TRACE1 (DEBUG_CTX, "gpgme_set_pinentry_mode", ctx, "pinentry_mode=%u",
|
|
|
|
|
(unsigned int)mode);
|
|
|
|
|
|
|
|
|
|
if (!ctx)
|
|
|
|
|
return gpg_error (GPG_ERR_INV_VALUE);
|
|
|
|
|
|
|
|
|
|
switch (mode)
|
|
|
|
|
{
|
|
|
|
|
case GPGME_PINENTRY_MODE_DEFAULT:
|
|
|
|
|
case GPGME_PINENTRY_MODE_ASK:
|
|
|
|
|
case GPGME_PINENTRY_MODE_CANCEL:
|
|
|
|
|
case GPGME_PINENTRY_MODE_ERROR:
|
|
|
|
|
case GPGME_PINENTRY_MODE_LOOPBACK:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return gpg_error (GPG_ERR_INV_VALUE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ctx->pinentry_mode = mode;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2013-02-12 09:42:54 +00:00
|
|
|
|
/* Get the pinentry mode of CTX. */
|
|
|
|
|
gpgme_pinentry_mode_t
|
|
|
|
|
gpgme_get_pinentry_mode (gpgme_ctx_t ctx)
|
|
|
|
|
{
|
|
|
|
|
TRACE1 (DEBUG_CTX, "gpgme_get_pinentry_mode", ctx,
|
|
|
|
|
"ctx->pinentry_mode=%u", (unsigned int)ctx->pinentry_mode);
|
|
|
|
|
return ctx->pinentry_mode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-05-29 03:21:02 +00:00
|
|
|
|
/* This function sets a callback function to be used to pass a
|
|
|
|
|
passphrase to gpg. */
|
2000-11-20 20:17:36 +00:00
|
|
|
|
void
|
2003-05-18 21:08:43 +00:00
|
|
|
|
gpgme_set_passphrase_cb (gpgme_ctx_t ctx, gpgme_passphrase_cb_t cb,
|
|
|
|
|
void *cb_value)
|
2000-11-20 20:17:36 +00:00
|
|
|
|
{
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
TRACE2 (DEBUG_CTX, "gpgme_set_passphrase_cb", ctx,
|
|
|
|
|
"passphrase_cb=%p/%p", cb, cb_value);
|
2011-05-26 14:01:26 +00:00
|
|
|
|
|
|
|
|
|
if (!ctx)
|
|
|
|
|
return;
|
|
|
|
|
|
2003-05-29 03:21:02 +00:00
|
|
|
|
ctx->passphrase_cb = cb;
|
|
|
|
|
ctx->passphrase_cb_value = cb_value;
|
2000-11-20 20:17:36 +00:00
|
|
|
|
}
|
2000-12-06 12:17:10 +00:00
|
|
|
|
|
2002-04-22 21:58:26 +00:00
|
|
|
|
|
2003-05-29 03:21:02 +00:00
|
|
|
|
/* This function returns the callback function to be used to pass a
|
|
|
|
|
passphrase to the crypto engine. */
|
2002-04-22 21:58:26 +00:00
|
|
|
|
void
|
2003-05-18 21:08:43 +00:00
|
|
|
|
gpgme_get_passphrase_cb (gpgme_ctx_t ctx, gpgme_passphrase_cb_t *r_cb,
|
|
|
|
|
void **r_cb_value)
|
2002-04-22 21:58:26 +00:00
|
|
|
|
{
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
TRACE2 (DEBUG_CTX, "gpgme_get_passphrase_cb", ctx,
|
|
|
|
|
"ctx->passphrase_cb=%p/%p",
|
|
|
|
|
ctx->passphrase_cb, ctx->passphrase_cb_value);
|
2003-05-29 03:21:02 +00:00
|
|
|
|
if (r_cb)
|
|
|
|
|
*r_cb = ctx->passphrase_cb;
|
|
|
|
|
if (r_cb_value)
|
|
|
|
|
*r_cb_value = ctx->passphrase_cb_value;
|
2002-04-22 21:58:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-05-29 03:21:02 +00:00
|
|
|
|
/* This function sets a callback function to be used as a progress
|
|
|
|
|
indicator. */
|
2000-12-19 10:07:32 +00:00
|
|
|
|
void
|
2003-05-18 20:45:24 +00:00
|
|
|
|
gpgme_set_progress_cb (gpgme_ctx_t ctx, gpgme_progress_cb_t cb, void *cb_value)
|
2000-12-19 10:07:32 +00:00
|
|
|
|
{
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
TRACE2 (DEBUG_CTX, "gpgme_set_progress_cb", ctx, "progress_cb=%p/%p",
|
|
|
|
|
cb, cb_value);
|
2011-05-26 14:01:26 +00:00
|
|
|
|
|
|
|
|
|
if (!ctx)
|
|
|
|
|
return;
|
|
|
|
|
|
2003-05-29 03:21:02 +00:00
|
|
|
|
ctx->progress_cb = cb;
|
|
|
|
|
ctx->progress_cb_value = cb_value;
|
2000-12-19 10:07:32 +00:00
|
|
|
|
}
|
2002-04-22 21:58:26 +00:00
|
|
|
|
|
|
|
|
|
|
2003-05-29 03:21:02 +00:00
|
|
|
|
/* This function returns the callback function to be used as a
|
|
|
|
|
progress indicator. */
|
2002-04-22 21:58:26 +00:00
|
|
|
|
void
|
2003-05-18 21:08:43 +00:00
|
|
|
|
gpgme_get_progress_cb (gpgme_ctx_t ctx, gpgme_progress_cb_t *r_cb,
|
|
|
|
|
void **r_cb_value)
|
2002-04-22 21:58:26 +00:00
|
|
|
|
{
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
TRACE2 (DEBUG_CTX, "gpgme_get_progress_cb", ctx, "ctx->progress_cb=%p/%p",
|
|
|
|
|
ctx->progress_cb, ctx->progress_cb_value);
|
2003-05-29 03:21:02 +00:00
|
|
|
|
if (r_cb)
|
|
|
|
|
*r_cb = ctx->progress_cb;
|
|
|
|
|
if (r_cb_value)
|
|
|
|
|
*r_cb_value = ctx->progress_cb_value;
|
2002-04-22 21:58:26 +00:00
|
|
|
|
}
|
2002-06-10 Marcus Brinkmann <marcus@g10code.de>
* engine-gpgsm.c (_gpgme_gpgsm_start): Move the code that sets the
close notification for the status fd to ...
(_gpgme_gpgsm_new): ... here.
* wait.h: Include "sema.h". Remove prototypes of
_gpgme_remove_proc_from_wait_queue and
_gpgme_register_pipe_handler. Add prototypes of
_gpgme_fd_table_init, _gpgme_fd_table_deinit, _gpgme_fd_table_put,
_gpgme_add_io_cb, _gpgme_remove_io_cb, _gpgme_wait_event_cb and
_gpgme_wait_one..
* wait.c: Remove global variables PROC_QUEUE, PROC_QUEUE_LOCK,
FD_TABLE_SIZE, FD_TABLE, FD_TABLE_LOCK. New global variables
FDT_GLOBAL, CTX_DONE_LIST, CTX_DONE_LIST_SIZE,
CTX_DONE_LIST_LENGTH and CTX_DONE_LIST_LOCK. Remove struct
proc_s. Replace struct wait_item_s.
(_gpgme_fd_table_init): New function.
(_gpgme_fd_table_deinit): Likewise.
(_gpgme_fd_table_put): Likewise.
(set_process_done): Remove function.
(do_select): Take argument FDT. Use that to decide which fds to
select on.
(_gpgme_remove_proc_from_wait_queue): Remove function.
(_gpgme_wait_event_cb): New function.
(_gpgme_wait_one): Likewise.
(_gpgme_register_pipe_hanldler): Remove function.
(_gpgme_add_io_cb): New function.
(_gpgme_remove_io_cb): Likewise.
(_gpgme_freeze_fd): Remove function.
(_gpgme_thaw_fd): Remove function.
* rungpg.c (struct fd_data_map_s): Add new member TAG.
(struct gpg_object_s): Likewise for STATUS and COLON. Add member
IDX to CMD. Add new member IO_CBS.
(close_notify_handler): New variables POSSIBLY_DONE and NOT_DONE.
For each I/O callback, check if it should be unregistered. If all
callbacks have been unregistered, trigger GPGME_EVENT_DONE.
Remove member RUNNING.
(_gpgme_gpg_new): Initialize new members.
(_gpgme_gpg_release): Check PID not RUNNING. Don't call
_gpgme_remove_proc_from_wait_queue. Close GPG->CMD.FD if set.
(build_argv): Store away the index instead the file descriptor for
CMD.
(_gpgme_gpg_add_io_cb): New function.
(_gpgme_gpg_spawn): Use _gpgme_gpg_add_io_cb to register IO
callbacks.
(gpg_status_handler): Change return type to void, remove PID
argument, close filedescriptor if EOF or error occurs.
(read_status): Use _gpgme_gpg_add_io_cb instead _gpgme_thaw_fd.
Use IO_CBS->remove instead _gpgme_freeze_fd.
(gpg_colon_line_handler): Change return type to void, remove PID
argument, close filedescriptor if EOF or error occurs.
(command_cb): Use IO_CBS->remove instead _gpgme_freeze_fd.
(_gpgme_gpg_set_io_cbs): New function.
* rungpg.h (_gpgme_gpg_set_io_cbs): Prototype for
_gpgme_gpg_set_io_cbs.
* gpgme.h (GpgmeIOCb): New type.
(GpgmeRegisterIOCb): Likewise.
(GpgmeRemoveIOCb): Likewise.
(GpgmeEventIO): Likewise.
(GpgmeEventIOCb): Likewise.
(struct GpgmeIOCbs): New structure to hold I/O callbacks.
(gpgme_set_op_io_cbs): New prototype.
(gpgme_get_op_io_cbs): Likewise.
* ops.h: New prototype for _gpgme_op_event_cb. Remove prototypes
for _gpgme_freeze_fd and _gpgme_thaw_fd. Remove PID argument from
_gpgme_data_inbound_handler and _gpgme_data_outbound_handler
prototype. Add prototype for _gpgme_op_reset.
Add synchronous argument to _gpgme_decrypt_start prototype.
* io.h: Beautification.
* gpgme.c: Include "wait.h".
(gpgme_new): Initialize FDT.
(gpgme_set_io_cbs): New function.
(gpgme_get_io_cbs): Likewise.
(_gpgme_op_event_cb): Likewise.
* data.c (_gpgme_data_inbound_handler): Change return type to
void. Drop PID argument. Close FD on error and EOF.
(write_mem_data): Don't close FD here ...
(write_cb_data): ... or here ...
(_gpgme_data_outbound_handler): ... but here. Change return type
to void. Drop PID argument.
* context.h: Include "wait.h".
(struct gpgme_context_s): New members FDT and IO_CBS.
* op-support.c: New file.
* Makefile.am (libgpgme_la_SOURCES): Add op-support.c.
* ops.h: Add prototype for _gpgme_op_reset().
* decrypt.c (_gpgme_decrypt_start): New argument SYNCHRONOUS. Use
_gpgme_op_reset.
(gpgme_op_decrypt_start): Add synchronous argument.
(gpgme_op_decrypt): Likewise. Use _gpgme_wait_one instead
gpgme_wait.
* delete.c (gpgme_op_delete_start): Rename to ...
(_gpgme_op_delete_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_delete_start): Just a wrapper around
_gpgme_op_delete_start now.
(gpgme_op_delete): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* encrypt.c: Include "wait.h".
(ggpgme_op_encrypt_start): Rename to ...
(_gpgme_op_encrypt_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_encrypt_start): Just a wrapper around
_gpgme_op_encrypt_start now.
(gpgme_op_encrypt): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* encrypt_sign.c (gpgme_op_encrypt_sign_start): Rename to ...
(_gpgme_op_encrypt_sign_start): ... this. New argument
SYNCHRONOUS. Use _gpgme_op_reset. Make function static.
(gpgme_op_encrypt_sign_start): Just a wrapper around
_gpgme_op_encrypt_sign_start now.
(gpgme_op_encrypt_sign): Add synchronous argument. Use
_gpgme_wait_one instead gpgme_wait.
* export.c (gpgme_op_export_start): Rename to ...
(_gpgme_op_export_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_export_start): Just a wrapper around
_gpgme_op_export_start now.
(gpgme_op_export): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* genkey.c (gpgme_op_genkey_start): Rename to ...
(_gpgme_op_genkey_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_genkey_start): Just a wrapper around
_gpgme_op_genkey_start now.
(gpgme_op_genkey): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* import.c (gpgme_op_import_start): Rename to ...
(_gpgme_op_import_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_import_start): Just a wrapper around
_gpgme_op_import_start now.
(gpgme_op_import): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* keylist.c (gpgme_op_keylist_start): Use _gpgme_op_reset.
(gpgme_op_keylist_ext_start): Likewise.
* sign.c (gpgme_op_sign_start): Rename to ...
(_gpgme_op_sign_start): ... this. New argument SYNCHRONOUS. Use
_gpgme_op_reset. Make function static.
(gpgme_op_sign_start): Just a wrapper around _gpgme_op_sign_start
now.
(gpgme_op_sign): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* trustlist.c (gpgme_op_trustlist_start): Use _gpgme_op_reset.
* verify.c (gpgme_op_verify_start): Rename to ...
(_gpgme_op_verify_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_verify_start): Just a wrapper around
_gpgme_op_verify_start now.
(gpgme_op_verify): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* engine-gpgsm.c (iocb_data_t): New type.
(struct gpgsm_object_s): New member status_cb. Replace input_fd
and input_data with input_cb. Replace output_fd and output_data
with output_cb. Replace message_fd and message_data with
message_cb. New member io_cbs.
(_gpgme_gpgsm_new): Initialize all new members (and drop the old
ones).
(close_notify_handler): New variable POSSIBLY_DONE. For each I/O
callback, check if it should be unregistered. If all callbacks
have been unregistered, trigger GPGME_EVENT_DONE.
(_gpgme_gpgsm_release): Remove variable PID. Use new variable
names to close the file descriptors.
(_gpgme_gpgsm_op_decrypt): Use new variable names,
(_gpgme_gpgsm_op_encrypt): Likewise.
(_gpgme_gpgsm_op_genkey): Likewise.
(_gpgme_gpgsm_op_import): Likewise.
(_gpgme_gpgsm_op_keylist): Likewise.
(_gpgme_gpgsm_op_keylist_ext): Likewise.
(_gpgme_gpgsm_op_sign): Likewise.
(_gpgme_gpgsm_op_verify): Likewise.
(gpgsm_status_handler): Drop argument PID. Change return type to
void. Close status pipe before returning because of EOF or error.
(_gpgme_gpgsm_add_io_cb): New function.
(_gpgme_gpgsm_start): Use _gpgme_gpgsm_add_io_cb to register
callback function.
(_gpgme_gpgsm_set_io_cbs): New function.
* engine-gpgsm.h: New prototype for _gpgme_gpgsm_set_io_cbs.
* engine.c (_gpgme_engine_set_io_cbs): New function.
* engine.h: New prototype for _gpgme_engine_set_io_cbs.
2002-06-10 14:13:55 +00:00
|
|
|
|
|
|
|
|
|
|
2015-04-17 00:23:38 +00:00
|
|
|
|
/* This function sets a callback function to be used as a status
|
|
|
|
|
message forwarder. */
|
|
|
|
|
void
|
|
|
|
|
gpgme_set_status_cb (gpgme_ctx_t ctx, gpgme_status_cb_t cb, void *cb_value)
|
|
|
|
|
{
|
|
|
|
|
TRACE2 (DEBUG_CTX, "gpgme_set_status_cb", ctx, "status_cb=%p/%p",
|
|
|
|
|
cb, cb_value);
|
|
|
|
|
|
|
|
|
|
if (!ctx)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
ctx->status_cb = cb;
|
|
|
|
|
ctx->status_cb_value = cb_value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* This function returns the callback function to be used as a
|
|
|
|
|
status message forwarder. */
|
|
|
|
|
void
|
|
|
|
|
gpgme_get_status_cb (gpgme_ctx_t ctx, gpgme_status_cb_t *r_cb,
|
|
|
|
|
void **r_cb_value)
|
|
|
|
|
{
|
|
|
|
|
TRACE2 (DEBUG_CTX, "gpgme_get_status_cb", ctx, "ctx->status_cb=%p/%p",
|
2015-08-15 20:58:04 +00:00
|
|
|
|
ctx ? ctx->status_cb : NULL, ctx ? ctx->status_cb_value : NULL);
|
|
|
|
|
|
|
|
|
|
if (r_cb)
|
|
|
|
|
*r_cb = NULL;
|
|
|
|
|
|
|
|
|
|
if (r_cb_value)
|
|
|
|
|
*r_cb_value = NULL;
|
|
|
|
|
|
|
|
|
|
if (!ctx || !ctx->status_cb)
|
|
|
|
|
return;
|
|
|
|
|
|
2015-04-17 00:23:38 +00:00
|
|
|
|
if (r_cb)
|
|
|
|
|
*r_cb = ctx->status_cb;
|
|
|
|
|
if (r_cb_value)
|
|
|
|
|
*r_cb_value = ctx->status_cb_value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-05-29 03:21:02 +00:00
|
|
|
|
/* Set the I/O callback functions for CTX to IO_CBS. */
|
2002-06-10 Marcus Brinkmann <marcus@g10code.de>
* engine-gpgsm.c (_gpgme_gpgsm_start): Move the code that sets the
close notification for the status fd to ...
(_gpgme_gpgsm_new): ... here.
* wait.h: Include "sema.h". Remove prototypes of
_gpgme_remove_proc_from_wait_queue and
_gpgme_register_pipe_handler. Add prototypes of
_gpgme_fd_table_init, _gpgme_fd_table_deinit, _gpgme_fd_table_put,
_gpgme_add_io_cb, _gpgme_remove_io_cb, _gpgme_wait_event_cb and
_gpgme_wait_one..
* wait.c: Remove global variables PROC_QUEUE, PROC_QUEUE_LOCK,
FD_TABLE_SIZE, FD_TABLE, FD_TABLE_LOCK. New global variables
FDT_GLOBAL, CTX_DONE_LIST, CTX_DONE_LIST_SIZE,
CTX_DONE_LIST_LENGTH and CTX_DONE_LIST_LOCK. Remove struct
proc_s. Replace struct wait_item_s.
(_gpgme_fd_table_init): New function.
(_gpgme_fd_table_deinit): Likewise.
(_gpgme_fd_table_put): Likewise.
(set_process_done): Remove function.
(do_select): Take argument FDT. Use that to decide which fds to
select on.
(_gpgme_remove_proc_from_wait_queue): Remove function.
(_gpgme_wait_event_cb): New function.
(_gpgme_wait_one): Likewise.
(_gpgme_register_pipe_hanldler): Remove function.
(_gpgme_add_io_cb): New function.
(_gpgme_remove_io_cb): Likewise.
(_gpgme_freeze_fd): Remove function.
(_gpgme_thaw_fd): Remove function.
* rungpg.c (struct fd_data_map_s): Add new member TAG.
(struct gpg_object_s): Likewise for STATUS and COLON. Add member
IDX to CMD. Add new member IO_CBS.
(close_notify_handler): New variables POSSIBLY_DONE and NOT_DONE.
For each I/O callback, check if it should be unregistered. If all
callbacks have been unregistered, trigger GPGME_EVENT_DONE.
Remove member RUNNING.
(_gpgme_gpg_new): Initialize new members.
(_gpgme_gpg_release): Check PID not RUNNING. Don't call
_gpgme_remove_proc_from_wait_queue. Close GPG->CMD.FD if set.
(build_argv): Store away the index instead the file descriptor for
CMD.
(_gpgme_gpg_add_io_cb): New function.
(_gpgme_gpg_spawn): Use _gpgme_gpg_add_io_cb to register IO
callbacks.
(gpg_status_handler): Change return type to void, remove PID
argument, close filedescriptor if EOF or error occurs.
(read_status): Use _gpgme_gpg_add_io_cb instead _gpgme_thaw_fd.
Use IO_CBS->remove instead _gpgme_freeze_fd.
(gpg_colon_line_handler): Change return type to void, remove PID
argument, close filedescriptor if EOF or error occurs.
(command_cb): Use IO_CBS->remove instead _gpgme_freeze_fd.
(_gpgme_gpg_set_io_cbs): New function.
* rungpg.h (_gpgme_gpg_set_io_cbs): Prototype for
_gpgme_gpg_set_io_cbs.
* gpgme.h (GpgmeIOCb): New type.
(GpgmeRegisterIOCb): Likewise.
(GpgmeRemoveIOCb): Likewise.
(GpgmeEventIO): Likewise.
(GpgmeEventIOCb): Likewise.
(struct GpgmeIOCbs): New structure to hold I/O callbacks.
(gpgme_set_op_io_cbs): New prototype.
(gpgme_get_op_io_cbs): Likewise.
* ops.h: New prototype for _gpgme_op_event_cb. Remove prototypes
for _gpgme_freeze_fd and _gpgme_thaw_fd. Remove PID argument from
_gpgme_data_inbound_handler and _gpgme_data_outbound_handler
prototype. Add prototype for _gpgme_op_reset.
Add synchronous argument to _gpgme_decrypt_start prototype.
* io.h: Beautification.
* gpgme.c: Include "wait.h".
(gpgme_new): Initialize FDT.
(gpgme_set_io_cbs): New function.
(gpgme_get_io_cbs): Likewise.
(_gpgme_op_event_cb): Likewise.
* data.c (_gpgme_data_inbound_handler): Change return type to
void. Drop PID argument. Close FD on error and EOF.
(write_mem_data): Don't close FD here ...
(write_cb_data): ... or here ...
(_gpgme_data_outbound_handler): ... but here. Change return type
to void. Drop PID argument.
* context.h: Include "wait.h".
(struct gpgme_context_s): New members FDT and IO_CBS.
* op-support.c: New file.
* Makefile.am (libgpgme_la_SOURCES): Add op-support.c.
* ops.h: Add prototype for _gpgme_op_reset().
* decrypt.c (_gpgme_decrypt_start): New argument SYNCHRONOUS. Use
_gpgme_op_reset.
(gpgme_op_decrypt_start): Add synchronous argument.
(gpgme_op_decrypt): Likewise. Use _gpgme_wait_one instead
gpgme_wait.
* delete.c (gpgme_op_delete_start): Rename to ...
(_gpgme_op_delete_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_delete_start): Just a wrapper around
_gpgme_op_delete_start now.
(gpgme_op_delete): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* encrypt.c: Include "wait.h".
(ggpgme_op_encrypt_start): Rename to ...
(_gpgme_op_encrypt_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_encrypt_start): Just a wrapper around
_gpgme_op_encrypt_start now.
(gpgme_op_encrypt): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* encrypt_sign.c (gpgme_op_encrypt_sign_start): Rename to ...
(_gpgme_op_encrypt_sign_start): ... this. New argument
SYNCHRONOUS. Use _gpgme_op_reset. Make function static.
(gpgme_op_encrypt_sign_start): Just a wrapper around
_gpgme_op_encrypt_sign_start now.
(gpgme_op_encrypt_sign): Add synchronous argument. Use
_gpgme_wait_one instead gpgme_wait.
* export.c (gpgme_op_export_start): Rename to ...
(_gpgme_op_export_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_export_start): Just a wrapper around
_gpgme_op_export_start now.
(gpgme_op_export): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* genkey.c (gpgme_op_genkey_start): Rename to ...
(_gpgme_op_genkey_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_genkey_start): Just a wrapper around
_gpgme_op_genkey_start now.
(gpgme_op_genkey): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* import.c (gpgme_op_import_start): Rename to ...
(_gpgme_op_import_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_import_start): Just a wrapper around
_gpgme_op_import_start now.
(gpgme_op_import): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* keylist.c (gpgme_op_keylist_start): Use _gpgme_op_reset.
(gpgme_op_keylist_ext_start): Likewise.
* sign.c (gpgme_op_sign_start): Rename to ...
(_gpgme_op_sign_start): ... this. New argument SYNCHRONOUS. Use
_gpgme_op_reset. Make function static.
(gpgme_op_sign_start): Just a wrapper around _gpgme_op_sign_start
now.
(gpgme_op_sign): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* trustlist.c (gpgme_op_trustlist_start): Use _gpgme_op_reset.
* verify.c (gpgme_op_verify_start): Rename to ...
(_gpgme_op_verify_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_verify_start): Just a wrapper around
_gpgme_op_verify_start now.
(gpgme_op_verify): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* engine-gpgsm.c (iocb_data_t): New type.
(struct gpgsm_object_s): New member status_cb. Replace input_fd
and input_data with input_cb. Replace output_fd and output_data
with output_cb. Replace message_fd and message_data with
message_cb. New member io_cbs.
(_gpgme_gpgsm_new): Initialize all new members (and drop the old
ones).
(close_notify_handler): New variable POSSIBLY_DONE. For each I/O
callback, check if it should be unregistered. If all callbacks
have been unregistered, trigger GPGME_EVENT_DONE.
(_gpgme_gpgsm_release): Remove variable PID. Use new variable
names to close the file descriptors.
(_gpgme_gpgsm_op_decrypt): Use new variable names,
(_gpgme_gpgsm_op_encrypt): Likewise.
(_gpgme_gpgsm_op_genkey): Likewise.
(_gpgme_gpgsm_op_import): Likewise.
(_gpgme_gpgsm_op_keylist): Likewise.
(_gpgme_gpgsm_op_keylist_ext): Likewise.
(_gpgme_gpgsm_op_sign): Likewise.
(_gpgme_gpgsm_op_verify): Likewise.
(gpgsm_status_handler): Drop argument PID. Change return type to
void. Close status pipe before returning because of EOF or error.
(_gpgme_gpgsm_add_io_cb): New function.
(_gpgme_gpgsm_start): Use _gpgme_gpgsm_add_io_cb to register
callback function.
(_gpgme_gpgsm_set_io_cbs): New function.
* engine-gpgsm.h: New prototype for _gpgme_gpgsm_set_io_cbs.
* engine.c (_gpgme_engine_set_io_cbs): New function.
* engine.h: New prototype for _gpgme_engine_set_io_cbs.
2002-06-10 14:13:55 +00:00
|
|
|
|
void
|
2003-05-18 20:45:24 +00:00
|
|
|
|
gpgme_set_io_cbs (gpgme_ctx_t ctx, gpgme_io_cbs_t io_cbs)
|
2002-06-10 Marcus Brinkmann <marcus@g10code.de>
* engine-gpgsm.c (_gpgme_gpgsm_start): Move the code that sets the
close notification for the status fd to ...
(_gpgme_gpgsm_new): ... here.
* wait.h: Include "sema.h". Remove prototypes of
_gpgme_remove_proc_from_wait_queue and
_gpgme_register_pipe_handler. Add prototypes of
_gpgme_fd_table_init, _gpgme_fd_table_deinit, _gpgme_fd_table_put,
_gpgme_add_io_cb, _gpgme_remove_io_cb, _gpgme_wait_event_cb and
_gpgme_wait_one..
* wait.c: Remove global variables PROC_QUEUE, PROC_QUEUE_LOCK,
FD_TABLE_SIZE, FD_TABLE, FD_TABLE_LOCK. New global variables
FDT_GLOBAL, CTX_DONE_LIST, CTX_DONE_LIST_SIZE,
CTX_DONE_LIST_LENGTH and CTX_DONE_LIST_LOCK. Remove struct
proc_s. Replace struct wait_item_s.
(_gpgme_fd_table_init): New function.
(_gpgme_fd_table_deinit): Likewise.
(_gpgme_fd_table_put): Likewise.
(set_process_done): Remove function.
(do_select): Take argument FDT. Use that to decide which fds to
select on.
(_gpgme_remove_proc_from_wait_queue): Remove function.
(_gpgme_wait_event_cb): New function.
(_gpgme_wait_one): Likewise.
(_gpgme_register_pipe_hanldler): Remove function.
(_gpgme_add_io_cb): New function.
(_gpgme_remove_io_cb): Likewise.
(_gpgme_freeze_fd): Remove function.
(_gpgme_thaw_fd): Remove function.
* rungpg.c (struct fd_data_map_s): Add new member TAG.
(struct gpg_object_s): Likewise for STATUS and COLON. Add member
IDX to CMD. Add new member IO_CBS.
(close_notify_handler): New variables POSSIBLY_DONE and NOT_DONE.
For each I/O callback, check if it should be unregistered. If all
callbacks have been unregistered, trigger GPGME_EVENT_DONE.
Remove member RUNNING.
(_gpgme_gpg_new): Initialize new members.
(_gpgme_gpg_release): Check PID not RUNNING. Don't call
_gpgme_remove_proc_from_wait_queue. Close GPG->CMD.FD if set.
(build_argv): Store away the index instead the file descriptor for
CMD.
(_gpgme_gpg_add_io_cb): New function.
(_gpgme_gpg_spawn): Use _gpgme_gpg_add_io_cb to register IO
callbacks.
(gpg_status_handler): Change return type to void, remove PID
argument, close filedescriptor if EOF or error occurs.
(read_status): Use _gpgme_gpg_add_io_cb instead _gpgme_thaw_fd.
Use IO_CBS->remove instead _gpgme_freeze_fd.
(gpg_colon_line_handler): Change return type to void, remove PID
argument, close filedescriptor if EOF or error occurs.
(command_cb): Use IO_CBS->remove instead _gpgme_freeze_fd.
(_gpgme_gpg_set_io_cbs): New function.
* rungpg.h (_gpgme_gpg_set_io_cbs): Prototype for
_gpgme_gpg_set_io_cbs.
* gpgme.h (GpgmeIOCb): New type.
(GpgmeRegisterIOCb): Likewise.
(GpgmeRemoveIOCb): Likewise.
(GpgmeEventIO): Likewise.
(GpgmeEventIOCb): Likewise.
(struct GpgmeIOCbs): New structure to hold I/O callbacks.
(gpgme_set_op_io_cbs): New prototype.
(gpgme_get_op_io_cbs): Likewise.
* ops.h: New prototype for _gpgme_op_event_cb. Remove prototypes
for _gpgme_freeze_fd and _gpgme_thaw_fd. Remove PID argument from
_gpgme_data_inbound_handler and _gpgme_data_outbound_handler
prototype. Add prototype for _gpgme_op_reset.
Add synchronous argument to _gpgme_decrypt_start prototype.
* io.h: Beautification.
* gpgme.c: Include "wait.h".
(gpgme_new): Initialize FDT.
(gpgme_set_io_cbs): New function.
(gpgme_get_io_cbs): Likewise.
(_gpgme_op_event_cb): Likewise.
* data.c (_gpgme_data_inbound_handler): Change return type to
void. Drop PID argument. Close FD on error and EOF.
(write_mem_data): Don't close FD here ...
(write_cb_data): ... or here ...
(_gpgme_data_outbound_handler): ... but here. Change return type
to void. Drop PID argument.
* context.h: Include "wait.h".
(struct gpgme_context_s): New members FDT and IO_CBS.
* op-support.c: New file.
* Makefile.am (libgpgme_la_SOURCES): Add op-support.c.
* ops.h: Add prototype for _gpgme_op_reset().
* decrypt.c (_gpgme_decrypt_start): New argument SYNCHRONOUS. Use
_gpgme_op_reset.
(gpgme_op_decrypt_start): Add synchronous argument.
(gpgme_op_decrypt): Likewise. Use _gpgme_wait_one instead
gpgme_wait.
* delete.c (gpgme_op_delete_start): Rename to ...
(_gpgme_op_delete_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_delete_start): Just a wrapper around
_gpgme_op_delete_start now.
(gpgme_op_delete): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* encrypt.c: Include "wait.h".
(ggpgme_op_encrypt_start): Rename to ...
(_gpgme_op_encrypt_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_encrypt_start): Just a wrapper around
_gpgme_op_encrypt_start now.
(gpgme_op_encrypt): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* encrypt_sign.c (gpgme_op_encrypt_sign_start): Rename to ...
(_gpgme_op_encrypt_sign_start): ... this. New argument
SYNCHRONOUS. Use _gpgme_op_reset. Make function static.
(gpgme_op_encrypt_sign_start): Just a wrapper around
_gpgme_op_encrypt_sign_start now.
(gpgme_op_encrypt_sign): Add synchronous argument. Use
_gpgme_wait_one instead gpgme_wait.
* export.c (gpgme_op_export_start): Rename to ...
(_gpgme_op_export_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_export_start): Just a wrapper around
_gpgme_op_export_start now.
(gpgme_op_export): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* genkey.c (gpgme_op_genkey_start): Rename to ...
(_gpgme_op_genkey_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_genkey_start): Just a wrapper around
_gpgme_op_genkey_start now.
(gpgme_op_genkey): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* import.c (gpgme_op_import_start): Rename to ...
(_gpgme_op_import_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_import_start): Just a wrapper around
_gpgme_op_import_start now.
(gpgme_op_import): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* keylist.c (gpgme_op_keylist_start): Use _gpgme_op_reset.
(gpgme_op_keylist_ext_start): Likewise.
* sign.c (gpgme_op_sign_start): Rename to ...
(_gpgme_op_sign_start): ... this. New argument SYNCHRONOUS. Use
_gpgme_op_reset. Make function static.
(gpgme_op_sign_start): Just a wrapper around _gpgme_op_sign_start
now.
(gpgme_op_sign): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* trustlist.c (gpgme_op_trustlist_start): Use _gpgme_op_reset.
* verify.c (gpgme_op_verify_start): Rename to ...
(_gpgme_op_verify_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_verify_start): Just a wrapper around
_gpgme_op_verify_start now.
(gpgme_op_verify): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* engine-gpgsm.c (iocb_data_t): New type.
(struct gpgsm_object_s): New member status_cb. Replace input_fd
and input_data with input_cb. Replace output_fd and output_data
with output_cb. Replace message_fd and message_data with
message_cb. New member io_cbs.
(_gpgme_gpgsm_new): Initialize all new members (and drop the old
ones).
(close_notify_handler): New variable POSSIBLY_DONE. For each I/O
callback, check if it should be unregistered. If all callbacks
have been unregistered, trigger GPGME_EVENT_DONE.
(_gpgme_gpgsm_release): Remove variable PID. Use new variable
names to close the file descriptors.
(_gpgme_gpgsm_op_decrypt): Use new variable names,
(_gpgme_gpgsm_op_encrypt): Likewise.
(_gpgme_gpgsm_op_genkey): Likewise.
(_gpgme_gpgsm_op_import): Likewise.
(_gpgme_gpgsm_op_keylist): Likewise.
(_gpgme_gpgsm_op_keylist_ext): Likewise.
(_gpgme_gpgsm_op_sign): Likewise.
(_gpgme_gpgsm_op_verify): Likewise.
(gpgsm_status_handler): Drop argument PID. Change return type to
void. Close status pipe before returning because of EOF or error.
(_gpgme_gpgsm_add_io_cb): New function.
(_gpgme_gpgsm_start): Use _gpgme_gpgsm_add_io_cb to register
callback function.
(_gpgme_gpgsm_set_io_cbs): New function.
* engine-gpgsm.h: New prototype for _gpgme_gpgsm_set_io_cbs.
* engine.c (_gpgme_engine_set_io_cbs): New function.
* engine.h: New prototype for _gpgme_engine_set_io_cbs.
2002-06-10 14:13:55 +00:00
|
|
|
|
{
|
2011-05-26 14:01:26 +00:00
|
|
|
|
if (!ctx)
|
|
|
|
|
return;
|
|
|
|
|
|
2002-07-03 01:57:03 +00:00
|
|
|
|
if (io_cbs)
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
{
|
|
|
|
|
TRACE6 (DEBUG_CTX, "gpgme_set_io_cbs", ctx,
|
|
|
|
|
"io_cbs=%p (add=%p/%p, remove=%p, event=%p/%p",
|
|
|
|
|
io_cbs, io_cbs->add, io_cbs->add_priv, io_cbs->remove,
|
|
|
|
|
io_cbs->event, io_cbs->event_priv);
|
|
|
|
|
ctx->io_cbs = *io_cbs;
|
|
|
|
|
}
|
2002-06-10 Marcus Brinkmann <marcus@g10code.de>
* engine-gpgsm.c (_gpgme_gpgsm_start): Move the code that sets the
close notification for the status fd to ...
(_gpgme_gpgsm_new): ... here.
* wait.h: Include "sema.h". Remove prototypes of
_gpgme_remove_proc_from_wait_queue and
_gpgme_register_pipe_handler. Add prototypes of
_gpgme_fd_table_init, _gpgme_fd_table_deinit, _gpgme_fd_table_put,
_gpgme_add_io_cb, _gpgme_remove_io_cb, _gpgme_wait_event_cb and
_gpgme_wait_one..
* wait.c: Remove global variables PROC_QUEUE, PROC_QUEUE_LOCK,
FD_TABLE_SIZE, FD_TABLE, FD_TABLE_LOCK. New global variables
FDT_GLOBAL, CTX_DONE_LIST, CTX_DONE_LIST_SIZE,
CTX_DONE_LIST_LENGTH and CTX_DONE_LIST_LOCK. Remove struct
proc_s. Replace struct wait_item_s.
(_gpgme_fd_table_init): New function.
(_gpgme_fd_table_deinit): Likewise.
(_gpgme_fd_table_put): Likewise.
(set_process_done): Remove function.
(do_select): Take argument FDT. Use that to decide which fds to
select on.
(_gpgme_remove_proc_from_wait_queue): Remove function.
(_gpgme_wait_event_cb): New function.
(_gpgme_wait_one): Likewise.
(_gpgme_register_pipe_hanldler): Remove function.
(_gpgme_add_io_cb): New function.
(_gpgme_remove_io_cb): Likewise.
(_gpgme_freeze_fd): Remove function.
(_gpgme_thaw_fd): Remove function.
* rungpg.c (struct fd_data_map_s): Add new member TAG.
(struct gpg_object_s): Likewise for STATUS and COLON. Add member
IDX to CMD. Add new member IO_CBS.
(close_notify_handler): New variables POSSIBLY_DONE and NOT_DONE.
For each I/O callback, check if it should be unregistered. If all
callbacks have been unregistered, trigger GPGME_EVENT_DONE.
Remove member RUNNING.
(_gpgme_gpg_new): Initialize new members.
(_gpgme_gpg_release): Check PID not RUNNING. Don't call
_gpgme_remove_proc_from_wait_queue. Close GPG->CMD.FD if set.
(build_argv): Store away the index instead the file descriptor for
CMD.
(_gpgme_gpg_add_io_cb): New function.
(_gpgme_gpg_spawn): Use _gpgme_gpg_add_io_cb to register IO
callbacks.
(gpg_status_handler): Change return type to void, remove PID
argument, close filedescriptor if EOF or error occurs.
(read_status): Use _gpgme_gpg_add_io_cb instead _gpgme_thaw_fd.
Use IO_CBS->remove instead _gpgme_freeze_fd.
(gpg_colon_line_handler): Change return type to void, remove PID
argument, close filedescriptor if EOF or error occurs.
(command_cb): Use IO_CBS->remove instead _gpgme_freeze_fd.
(_gpgme_gpg_set_io_cbs): New function.
* rungpg.h (_gpgme_gpg_set_io_cbs): Prototype for
_gpgme_gpg_set_io_cbs.
* gpgme.h (GpgmeIOCb): New type.
(GpgmeRegisterIOCb): Likewise.
(GpgmeRemoveIOCb): Likewise.
(GpgmeEventIO): Likewise.
(GpgmeEventIOCb): Likewise.
(struct GpgmeIOCbs): New structure to hold I/O callbacks.
(gpgme_set_op_io_cbs): New prototype.
(gpgme_get_op_io_cbs): Likewise.
* ops.h: New prototype for _gpgme_op_event_cb. Remove prototypes
for _gpgme_freeze_fd and _gpgme_thaw_fd. Remove PID argument from
_gpgme_data_inbound_handler and _gpgme_data_outbound_handler
prototype. Add prototype for _gpgme_op_reset.
Add synchronous argument to _gpgme_decrypt_start prototype.
* io.h: Beautification.
* gpgme.c: Include "wait.h".
(gpgme_new): Initialize FDT.
(gpgme_set_io_cbs): New function.
(gpgme_get_io_cbs): Likewise.
(_gpgme_op_event_cb): Likewise.
* data.c (_gpgme_data_inbound_handler): Change return type to
void. Drop PID argument. Close FD on error and EOF.
(write_mem_data): Don't close FD here ...
(write_cb_data): ... or here ...
(_gpgme_data_outbound_handler): ... but here. Change return type
to void. Drop PID argument.
* context.h: Include "wait.h".
(struct gpgme_context_s): New members FDT and IO_CBS.
* op-support.c: New file.
* Makefile.am (libgpgme_la_SOURCES): Add op-support.c.
* ops.h: Add prototype for _gpgme_op_reset().
* decrypt.c (_gpgme_decrypt_start): New argument SYNCHRONOUS. Use
_gpgme_op_reset.
(gpgme_op_decrypt_start): Add synchronous argument.
(gpgme_op_decrypt): Likewise. Use _gpgme_wait_one instead
gpgme_wait.
* delete.c (gpgme_op_delete_start): Rename to ...
(_gpgme_op_delete_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_delete_start): Just a wrapper around
_gpgme_op_delete_start now.
(gpgme_op_delete): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* encrypt.c: Include "wait.h".
(ggpgme_op_encrypt_start): Rename to ...
(_gpgme_op_encrypt_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_encrypt_start): Just a wrapper around
_gpgme_op_encrypt_start now.
(gpgme_op_encrypt): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* encrypt_sign.c (gpgme_op_encrypt_sign_start): Rename to ...
(_gpgme_op_encrypt_sign_start): ... this. New argument
SYNCHRONOUS. Use _gpgme_op_reset. Make function static.
(gpgme_op_encrypt_sign_start): Just a wrapper around
_gpgme_op_encrypt_sign_start now.
(gpgme_op_encrypt_sign): Add synchronous argument. Use
_gpgme_wait_one instead gpgme_wait.
* export.c (gpgme_op_export_start): Rename to ...
(_gpgme_op_export_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_export_start): Just a wrapper around
_gpgme_op_export_start now.
(gpgme_op_export): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* genkey.c (gpgme_op_genkey_start): Rename to ...
(_gpgme_op_genkey_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_genkey_start): Just a wrapper around
_gpgme_op_genkey_start now.
(gpgme_op_genkey): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* import.c (gpgme_op_import_start): Rename to ...
(_gpgme_op_import_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_import_start): Just a wrapper around
_gpgme_op_import_start now.
(gpgme_op_import): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* keylist.c (gpgme_op_keylist_start): Use _gpgme_op_reset.
(gpgme_op_keylist_ext_start): Likewise.
* sign.c (gpgme_op_sign_start): Rename to ...
(_gpgme_op_sign_start): ... this. New argument SYNCHRONOUS. Use
_gpgme_op_reset. Make function static.
(gpgme_op_sign_start): Just a wrapper around _gpgme_op_sign_start
now.
(gpgme_op_sign): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* trustlist.c (gpgme_op_trustlist_start): Use _gpgme_op_reset.
* verify.c (gpgme_op_verify_start): Rename to ...
(_gpgme_op_verify_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_verify_start): Just a wrapper around
_gpgme_op_verify_start now.
(gpgme_op_verify): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* engine-gpgsm.c (iocb_data_t): New type.
(struct gpgsm_object_s): New member status_cb. Replace input_fd
and input_data with input_cb. Replace output_fd and output_data
with output_cb. Replace message_fd and message_data with
message_cb. New member io_cbs.
(_gpgme_gpgsm_new): Initialize all new members (and drop the old
ones).
(close_notify_handler): New variable POSSIBLY_DONE. For each I/O
callback, check if it should be unregistered. If all callbacks
have been unregistered, trigger GPGME_EVENT_DONE.
(_gpgme_gpgsm_release): Remove variable PID. Use new variable
names to close the file descriptors.
(_gpgme_gpgsm_op_decrypt): Use new variable names,
(_gpgme_gpgsm_op_encrypt): Likewise.
(_gpgme_gpgsm_op_genkey): Likewise.
(_gpgme_gpgsm_op_import): Likewise.
(_gpgme_gpgsm_op_keylist): Likewise.
(_gpgme_gpgsm_op_keylist_ext): Likewise.
(_gpgme_gpgsm_op_sign): Likewise.
(_gpgme_gpgsm_op_verify): Likewise.
(gpgsm_status_handler): Drop argument PID. Change return type to
void. Close status pipe before returning because of EOF or error.
(_gpgme_gpgsm_add_io_cb): New function.
(_gpgme_gpgsm_start): Use _gpgme_gpgsm_add_io_cb to register
callback function.
(_gpgme_gpgsm_set_io_cbs): New function.
* engine-gpgsm.h: New prototype for _gpgme_gpgsm_set_io_cbs.
* engine.c (_gpgme_engine_set_io_cbs): New function.
* engine.h: New prototype for _gpgme_engine_set_io_cbs.
2002-06-10 14:13:55 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
TRACE1 (DEBUG_CTX, "gpgme_set_io_cbs", ctx,
|
|
|
|
|
"io_cbs=%p (default)", io_cbs);
|
2002-06-10 Marcus Brinkmann <marcus@g10code.de>
* engine-gpgsm.c (_gpgme_gpgsm_start): Move the code that sets the
close notification for the status fd to ...
(_gpgme_gpgsm_new): ... here.
* wait.h: Include "sema.h". Remove prototypes of
_gpgme_remove_proc_from_wait_queue and
_gpgme_register_pipe_handler. Add prototypes of
_gpgme_fd_table_init, _gpgme_fd_table_deinit, _gpgme_fd_table_put,
_gpgme_add_io_cb, _gpgme_remove_io_cb, _gpgme_wait_event_cb and
_gpgme_wait_one..
* wait.c: Remove global variables PROC_QUEUE, PROC_QUEUE_LOCK,
FD_TABLE_SIZE, FD_TABLE, FD_TABLE_LOCK. New global variables
FDT_GLOBAL, CTX_DONE_LIST, CTX_DONE_LIST_SIZE,
CTX_DONE_LIST_LENGTH and CTX_DONE_LIST_LOCK. Remove struct
proc_s. Replace struct wait_item_s.
(_gpgme_fd_table_init): New function.
(_gpgme_fd_table_deinit): Likewise.
(_gpgme_fd_table_put): Likewise.
(set_process_done): Remove function.
(do_select): Take argument FDT. Use that to decide which fds to
select on.
(_gpgme_remove_proc_from_wait_queue): Remove function.
(_gpgme_wait_event_cb): New function.
(_gpgme_wait_one): Likewise.
(_gpgme_register_pipe_hanldler): Remove function.
(_gpgme_add_io_cb): New function.
(_gpgme_remove_io_cb): Likewise.
(_gpgme_freeze_fd): Remove function.
(_gpgme_thaw_fd): Remove function.
* rungpg.c (struct fd_data_map_s): Add new member TAG.
(struct gpg_object_s): Likewise for STATUS and COLON. Add member
IDX to CMD. Add new member IO_CBS.
(close_notify_handler): New variables POSSIBLY_DONE and NOT_DONE.
For each I/O callback, check if it should be unregistered. If all
callbacks have been unregistered, trigger GPGME_EVENT_DONE.
Remove member RUNNING.
(_gpgme_gpg_new): Initialize new members.
(_gpgme_gpg_release): Check PID not RUNNING. Don't call
_gpgme_remove_proc_from_wait_queue. Close GPG->CMD.FD if set.
(build_argv): Store away the index instead the file descriptor for
CMD.
(_gpgme_gpg_add_io_cb): New function.
(_gpgme_gpg_spawn): Use _gpgme_gpg_add_io_cb to register IO
callbacks.
(gpg_status_handler): Change return type to void, remove PID
argument, close filedescriptor if EOF or error occurs.
(read_status): Use _gpgme_gpg_add_io_cb instead _gpgme_thaw_fd.
Use IO_CBS->remove instead _gpgme_freeze_fd.
(gpg_colon_line_handler): Change return type to void, remove PID
argument, close filedescriptor if EOF or error occurs.
(command_cb): Use IO_CBS->remove instead _gpgme_freeze_fd.
(_gpgme_gpg_set_io_cbs): New function.
* rungpg.h (_gpgme_gpg_set_io_cbs): Prototype for
_gpgme_gpg_set_io_cbs.
* gpgme.h (GpgmeIOCb): New type.
(GpgmeRegisterIOCb): Likewise.
(GpgmeRemoveIOCb): Likewise.
(GpgmeEventIO): Likewise.
(GpgmeEventIOCb): Likewise.
(struct GpgmeIOCbs): New structure to hold I/O callbacks.
(gpgme_set_op_io_cbs): New prototype.
(gpgme_get_op_io_cbs): Likewise.
* ops.h: New prototype for _gpgme_op_event_cb. Remove prototypes
for _gpgme_freeze_fd and _gpgme_thaw_fd. Remove PID argument from
_gpgme_data_inbound_handler and _gpgme_data_outbound_handler
prototype. Add prototype for _gpgme_op_reset.
Add synchronous argument to _gpgme_decrypt_start prototype.
* io.h: Beautification.
* gpgme.c: Include "wait.h".
(gpgme_new): Initialize FDT.
(gpgme_set_io_cbs): New function.
(gpgme_get_io_cbs): Likewise.
(_gpgme_op_event_cb): Likewise.
* data.c (_gpgme_data_inbound_handler): Change return type to
void. Drop PID argument. Close FD on error and EOF.
(write_mem_data): Don't close FD here ...
(write_cb_data): ... or here ...
(_gpgme_data_outbound_handler): ... but here. Change return type
to void. Drop PID argument.
* context.h: Include "wait.h".
(struct gpgme_context_s): New members FDT and IO_CBS.
* op-support.c: New file.
* Makefile.am (libgpgme_la_SOURCES): Add op-support.c.
* ops.h: Add prototype for _gpgme_op_reset().
* decrypt.c (_gpgme_decrypt_start): New argument SYNCHRONOUS. Use
_gpgme_op_reset.
(gpgme_op_decrypt_start): Add synchronous argument.
(gpgme_op_decrypt): Likewise. Use _gpgme_wait_one instead
gpgme_wait.
* delete.c (gpgme_op_delete_start): Rename to ...
(_gpgme_op_delete_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_delete_start): Just a wrapper around
_gpgme_op_delete_start now.
(gpgme_op_delete): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* encrypt.c: Include "wait.h".
(ggpgme_op_encrypt_start): Rename to ...
(_gpgme_op_encrypt_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_encrypt_start): Just a wrapper around
_gpgme_op_encrypt_start now.
(gpgme_op_encrypt): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* encrypt_sign.c (gpgme_op_encrypt_sign_start): Rename to ...
(_gpgme_op_encrypt_sign_start): ... this. New argument
SYNCHRONOUS. Use _gpgme_op_reset. Make function static.
(gpgme_op_encrypt_sign_start): Just a wrapper around
_gpgme_op_encrypt_sign_start now.
(gpgme_op_encrypt_sign): Add synchronous argument. Use
_gpgme_wait_one instead gpgme_wait.
* export.c (gpgme_op_export_start): Rename to ...
(_gpgme_op_export_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_export_start): Just a wrapper around
_gpgme_op_export_start now.
(gpgme_op_export): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* genkey.c (gpgme_op_genkey_start): Rename to ...
(_gpgme_op_genkey_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_genkey_start): Just a wrapper around
_gpgme_op_genkey_start now.
(gpgme_op_genkey): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* import.c (gpgme_op_import_start): Rename to ...
(_gpgme_op_import_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_import_start): Just a wrapper around
_gpgme_op_import_start now.
(gpgme_op_import): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* keylist.c (gpgme_op_keylist_start): Use _gpgme_op_reset.
(gpgme_op_keylist_ext_start): Likewise.
* sign.c (gpgme_op_sign_start): Rename to ...
(_gpgme_op_sign_start): ... this. New argument SYNCHRONOUS. Use
_gpgme_op_reset. Make function static.
(gpgme_op_sign_start): Just a wrapper around _gpgme_op_sign_start
now.
(gpgme_op_sign): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* trustlist.c (gpgme_op_trustlist_start): Use _gpgme_op_reset.
* verify.c (gpgme_op_verify_start): Rename to ...
(_gpgme_op_verify_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_verify_start): Just a wrapper around
_gpgme_op_verify_start now.
(gpgme_op_verify): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* engine-gpgsm.c (iocb_data_t): New type.
(struct gpgsm_object_s): New member status_cb. Replace input_fd
and input_data with input_cb. Replace output_fd and output_data
with output_cb. Replace message_fd and message_data with
message_cb. New member io_cbs.
(_gpgme_gpgsm_new): Initialize all new members (and drop the old
ones).
(close_notify_handler): New variable POSSIBLY_DONE. For each I/O
callback, check if it should be unregistered. If all callbacks
have been unregistered, trigger GPGME_EVENT_DONE.
(_gpgme_gpgsm_release): Remove variable PID. Use new variable
names to close the file descriptors.
(_gpgme_gpgsm_op_decrypt): Use new variable names,
(_gpgme_gpgsm_op_encrypt): Likewise.
(_gpgme_gpgsm_op_genkey): Likewise.
(_gpgme_gpgsm_op_import): Likewise.
(_gpgme_gpgsm_op_keylist): Likewise.
(_gpgme_gpgsm_op_keylist_ext): Likewise.
(_gpgme_gpgsm_op_sign): Likewise.
(_gpgme_gpgsm_op_verify): Likewise.
(gpgsm_status_handler): Drop argument PID. Change return type to
void. Close status pipe before returning because of EOF or error.
(_gpgme_gpgsm_add_io_cb): New function.
(_gpgme_gpgsm_start): Use _gpgme_gpgsm_add_io_cb to register
callback function.
(_gpgme_gpgsm_set_io_cbs): New function.
* engine-gpgsm.h: New prototype for _gpgme_gpgsm_set_io_cbs.
* engine.c (_gpgme_engine_set_io_cbs): New function.
* engine.h: New prototype for _gpgme_engine_set_io_cbs.
2002-06-10 14:13:55 +00:00
|
|
|
|
ctx->io_cbs.add = NULL;
|
|
|
|
|
ctx->io_cbs.add_priv = NULL;
|
|
|
|
|
ctx->io_cbs.remove = NULL;
|
|
|
|
|
ctx->io_cbs.event = NULL;
|
|
|
|
|
ctx->io_cbs.event_priv = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-06-09 16:01:02 +00:00
|
|
|
|
/* This function provides access to the internal read function; it is
|
2009-06-15 17:05:47 +00:00
|
|
|
|
normally not used. */
|
Make definition of off_t robust against misbehaving w32 toolchains.
* configure.ac (NEED__FILE_OFFSET_BITS): Change to define gpgme_off_t
and gpgme_ssize_t.
(API__OFF_T, API__SSIZE_T): New ac_subst.
* src/gpgme.h.in: Replace all ssize_t and off_t by ac_subst macros.
* src/assuan-support.c, src/ath-pthread.c, src/ath.c, src/ath.h
* src/data-compat.c, src/data-fd.c, src/data-mem.c, src/data-stream.c
* src/data-user.c, src/data.c, src/data.h, src/engine-gpgsm.c
* src/engine-uiserver.c, src/gpgme-tool.c, src/gpgme.c: Replace off_t
by gpgme_off_t and sszie_t by gpgme_ssize_t.
* src/ath-pthread.c, src/ath.h: Include gpgme.h.
--
For a detailed description, see the gpgme.texi diff.
2013-04-25 11:00:16 +00:00
|
|
|
|
gpgme_ssize_t
|
2009-06-09 16:01:02 +00:00
|
|
|
|
gpgme_io_read (int fd, void *buffer, size_t count)
|
|
|
|
|
{
|
|
|
|
|
int ret;
|
2009-10-26 18:52:32 +00:00
|
|
|
|
TRACE_BEG2 (DEBUG_GLOBAL, "gpgme_io_read", fd,
|
|
|
|
|
"buffer=%p, count=%u", buffer, count);
|
2009-06-09 16:01:02 +00:00
|
|
|
|
|
|
|
|
|
ret = _gpgme_io_read (fd, buffer, count);
|
|
|
|
|
|
2009-10-26 18:52:32 +00:00
|
|
|
|
return TRACE_SYSRES (ret);
|
2009-06-09 16:01:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* This function provides access to the internal write function. It
|
|
|
|
|
is to be used by user callbacks to return data to gpgme. See
|
|
|
|
|
gpgme_passphrase_cb_t and gpgme_edit_cb_t. */
|
Make definition of off_t robust against misbehaving w32 toolchains.
* configure.ac (NEED__FILE_OFFSET_BITS): Change to define gpgme_off_t
and gpgme_ssize_t.
(API__OFF_T, API__SSIZE_T): New ac_subst.
* src/gpgme.h.in: Replace all ssize_t and off_t by ac_subst macros.
* src/assuan-support.c, src/ath-pthread.c, src/ath.c, src/ath.h
* src/data-compat.c, src/data-fd.c, src/data-mem.c, src/data-stream.c
* src/data-user.c, src/data.c, src/data.h, src/engine-gpgsm.c
* src/engine-uiserver.c, src/gpgme-tool.c, src/gpgme.c: Replace off_t
by gpgme_off_t and sszie_t by gpgme_ssize_t.
* src/ath-pthread.c, src/ath.h: Include gpgme.h.
--
For a detailed description, see the gpgme.texi diff.
2013-04-25 11:00:16 +00:00
|
|
|
|
gpgme_ssize_t
|
2009-06-09 16:01:02 +00:00
|
|
|
|
gpgme_io_write (int fd, const void *buffer, size_t count)
|
|
|
|
|
{
|
|
|
|
|
int ret;
|
2009-10-26 18:52:32 +00:00
|
|
|
|
TRACE_BEG2 (DEBUG_GLOBAL, "gpgme_io_write", fd,
|
|
|
|
|
"buffer=%p, count=%u", buffer, count);
|
2009-06-09 16:01:02 +00:00
|
|
|
|
|
|
|
|
|
ret = _gpgme_io_write (fd, buffer, count);
|
|
|
|
|
|
2009-10-26 18:52:32 +00:00
|
|
|
|
return TRACE_SYSRES (ret);
|
2009-06-09 16:01:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-02-07 19:51:29 +00:00
|
|
|
|
/* This function provides access to the internal write function. It
|
|
|
|
|
is to be used by user callbacks to return data to gpgme. See
|
|
|
|
|
gpgme_passphrase_cb_t and gpgme_edit_cb_t. Note that this is a
|
|
|
|
|
variant of gpgme_io_write which guarantees that all COUNT bytes are
|
|
|
|
|
written or an error is return. Returns: 0 on success or -1 on
|
|
|
|
|
error and the sets errno. */
|
|
|
|
|
int
|
2014-03-11 12:58:38 +00:00
|
|
|
|
gpgme_io_writen (int fd, const void *buffer_arg, size_t count)
|
2013-02-07 19:51:29 +00:00
|
|
|
|
{
|
2014-03-11 12:58:38 +00:00
|
|
|
|
const char *buffer = buffer_arg;
|
2013-02-07 19:51:29 +00:00
|
|
|
|
int ret = 0;
|
|
|
|
|
TRACE_BEG2 (DEBUG_GLOBAL, "gpgme_io_writen", fd,
|
|
|
|
|
"buffer=%p, count=%u", buffer, count);
|
|
|
|
|
while (count)
|
|
|
|
|
{
|
|
|
|
|
ret = _gpgme_io_write (fd, buffer, count);
|
|
|
|
|
if (ret < 0)
|
|
|
|
|
break;
|
|
|
|
|
buffer += ret;
|
|
|
|
|
count -= ret;
|
|
|
|
|
ret = 0;
|
|
|
|
|
}
|
|
|
|
|
return TRACE_SYSRES (ret);
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-09 16:01:02 +00:00
|
|
|
|
|
2003-05-29 03:21:02 +00:00
|
|
|
|
/* This function returns the callback function for I/O. */
|
2002-06-10 Marcus Brinkmann <marcus@g10code.de>
* engine-gpgsm.c (_gpgme_gpgsm_start): Move the code that sets the
close notification for the status fd to ...
(_gpgme_gpgsm_new): ... here.
* wait.h: Include "sema.h". Remove prototypes of
_gpgme_remove_proc_from_wait_queue and
_gpgme_register_pipe_handler. Add prototypes of
_gpgme_fd_table_init, _gpgme_fd_table_deinit, _gpgme_fd_table_put,
_gpgme_add_io_cb, _gpgme_remove_io_cb, _gpgme_wait_event_cb and
_gpgme_wait_one..
* wait.c: Remove global variables PROC_QUEUE, PROC_QUEUE_LOCK,
FD_TABLE_SIZE, FD_TABLE, FD_TABLE_LOCK. New global variables
FDT_GLOBAL, CTX_DONE_LIST, CTX_DONE_LIST_SIZE,
CTX_DONE_LIST_LENGTH and CTX_DONE_LIST_LOCK. Remove struct
proc_s. Replace struct wait_item_s.
(_gpgme_fd_table_init): New function.
(_gpgme_fd_table_deinit): Likewise.
(_gpgme_fd_table_put): Likewise.
(set_process_done): Remove function.
(do_select): Take argument FDT. Use that to decide which fds to
select on.
(_gpgme_remove_proc_from_wait_queue): Remove function.
(_gpgme_wait_event_cb): New function.
(_gpgme_wait_one): Likewise.
(_gpgme_register_pipe_hanldler): Remove function.
(_gpgme_add_io_cb): New function.
(_gpgme_remove_io_cb): Likewise.
(_gpgme_freeze_fd): Remove function.
(_gpgme_thaw_fd): Remove function.
* rungpg.c (struct fd_data_map_s): Add new member TAG.
(struct gpg_object_s): Likewise for STATUS and COLON. Add member
IDX to CMD. Add new member IO_CBS.
(close_notify_handler): New variables POSSIBLY_DONE and NOT_DONE.
For each I/O callback, check if it should be unregistered. If all
callbacks have been unregistered, trigger GPGME_EVENT_DONE.
Remove member RUNNING.
(_gpgme_gpg_new): Initialize new members.
(_gpgme_gpg_release): Check PID not RUNNING. Don't call
_gpgme_remove_proc_from_wait_queue. Close GPG->CMD.FD if set.
(build_argv): Store away the index instead the file descriptor for
CMD.
(_gpgme_gpg_add_io_cb): New function.
(_gpgme_gpg_spawn): Use _gpgme_gpg_add_io_cb to register IO
callbacks.
(gpg_status_handler): Change return type to void, remove PID
argument, close filedescriptor if EOF or error occurs.
(read_status): Use _gpgme_gpg_add_io_cb instead _gpgme_thaw_fd.
Use IO_CBS->remove instead _gpgme_freeze_fd.
(gpg_colon_line_handler): Change return type to void, remove PID
argument, close filedescriptor if EOF or error occurs.
(command_cb): Use IO_CBS->remove instead _gpgme_freeze_fd.
(_gpgme_gpg_set_io_cbs): New function.
* rungpg.h (_gpgme_gpg_set_io_cbs): Prototype for
_gpgme_gpg_set_io_cbs.
* gpgme.h (GpgmeIOCb): New type.
(GpgmeRegisterIOCb): Likewise.
(GpgmeRemoveIOCb): Likewise.
(GpgmeEventIO): Likewise.
(GpgmeEventIOCb): Likewise.
(struct GpgmeIOCbs): New structure to hold I/O callbacks.
(gpgme_set_op_io_cbs): New prototype.
(gpgme_get_op_io_cbs): Likewise.
* ops.h: New prototype for _gpgme_op_event_cb. Remove prototypes
for _gpgme_freeze_fd and _gpgme_thaw_fd. Remove PID argument from
_gpgme_data_inbound_handler and _gpgme_data_outbound_handler
prototype. Add prototype for _gpgme_op_reset.
Add synchronous argument to _gpgme_decrypt_start prototype.
* io.h: Beautification.
* gpgme.c: Include "wait.h".
(gpgme_new): Initialize FDT.
(gpgme_set_io_cbs): New function.
(gpgme_get_io_cbs): Likewise.
(_gpgme_op_event_cb): Likewise.
* data.c (_gpgme_data_inbound_handler): Change return type to
void. Drop PID argument. Close FD on error and EOF.
(write_mem_data): Don't close FD here ...
(write_cb_data): ... or here ...
(_gpgme_data_outbound_handler): ... but here. Change return type
to void. Drop PID argument.
* context.h: Include "wait.h".
(struct gpgme_context_s): New members FDT and IO_CBS.
* op-support.c: New file.
* Makefile.am (libgpgme_la_SOURCES): Add op-support.c.
* ops.h: Add prototype for _gpgme_op_reset().
* decrypt.c (_gpgme_decrypt_start): New argument SYNCHRONOUS. Use
_gpgme_op_reset.
(gpgme_op_decrypt_start): Add synchronous argument.
(gpgme_op_decrypt): Likewise. Use _gpgme_wait_one instead
gpgme_wait.
* delete.c (gpgme_op_delete_start): Rename to ...
(_gpgme_op_delete_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_delete_start): Just a wrapper around
_gpgme_op_delete_start now.
(gpgme_op_delete): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* encrypt.c: Include "wait.h".
(ggpgme_op_encrypt_start): Rename to ...
(_gpgme_op_encrypt_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_encrypt_start): Just a wrapper around
_gpgme_op_encrypt_start now.
(gpgme_op_encrypt): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* encrypt_sign.c (gpgme_op_encrypt_sign_start): Rename to ...
(_gpgme_op_encrypt_sign_start): ... this. New argument
SYNCHRONOUS. Use _gpgme_op_reset. Make function static.
(gpgme_op_encrypt_sign_start): Just a wrapper around
_gpgme_op_encrypt_sign_start now.
(gpgme_op_encrypt_sign): Add synchronous argument. Use
_gpgme_wait_one instead gpgme_wait.
* export.c (gpgme_op_export_start): Rename to ...
(_gpgme_op_export_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_export_start): Just a wrapper around
_gpgme_op_export_start now.
(gpgme_op_export): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* genkey.c (gpgme_op_genkey_start): Rename to ...
(_gpgme_op_genkey_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_genkey_start): Just a wrapper around
_gpgme_op_genkey_start now.
(gpgme_op_genkey): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* import.c (gpgme_op_import_start): Rename to ...
(_gpgme_op_import_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_import_start): Just a wrapper around
_gpgme_op_import_start now.
(gpgme_op_import): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* keylist.c (gpgme_op_keylist_start): Use _gpgme_op_reset.
(gpgme_op_keylist_ext_start): Likewise.
* sign.c (gpgme_op_sign_start): Rename to ...
(_gpgme_op_sign_start): ... this. New argument SYNCHRONOUS. Use
_gpgme_op_reset. Make function static.
(gpgme_op_sign_start): Just a wrapper around _gpgme_op_sign_start
now.
(gpgme_op_sign): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* trustlist.c (gpgme_op_trustlist_start): Use _gpgme_op_reset.
* verify.c (gpgme_op_verify_start): Rename to ...
(_gpgme_op_verify_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_verify_start): Just a wrapper around
_gpgme_op_verify_start now.
(gpgme_op_verify): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* engine-gpgsm.c (iocb_data_t): New type.
(struct gpgsm_object_s): New member status_cb. Replace input_fd
and input_data with input_cb. Replace output_fd and output_data
with output_cb. Replace message_fd and message_data with
message_cb. New member io_cbs.
(_gpgme_gpgsm_new): Initialize all new members (and drop the old
ones).
(close_notify_handler): New variable POSSIBLY_DONE. For each I/O
callback, check if it should be unregistered. If all callbacks
have been unregistered, trigger GPGME_EVENT_DONE.
(_gpgme_gpgsm_release): Remove variable PID. Use new variable
names to close the file descriptors.
(_gpgme_gpgsm_op_decrypt): Use new variable names,
(_gpgme_gpgsm_op_encrypt): Likewise.
(_gpgme_gpgsm_op_genkey): Likewise.
(_gpgme_gpgsm_op_import): Likewise.
(_gpgme_gpgsm_op_keylist): Likewise.
(_gpgme_gpgsm_op_keylist_ext): Likewise.
(_gpgme_gpgsm_op_sign): Likewise.
(_gpgme_gpgsm_op_verify): Likewise.
(gpgsm_status_handler): Drop argument PID. Change return type to
void. Close status pipe before returning because of EOF or error.
(_gpgme_gpgsm_add_io_cb): New function.
(_gpgme_gpgsm_start): Use _gpgme_gpgsm_add_io_cb to register
callback function.
(_gpgme_gpgsm_set_io_cbs): New function.
* engine-gpgsm.h: New prototype for _gpgme_gpgsm_set_io_cbs.
* engine.c (_gpgme_engine_set_io_cbs): New function.
* engine.h: New prototype for _gpgme_engine_set_io_cbs.
2002-06-10 14:13:55 +00:00
|
|
|
|
void
|
2003-05-18 20:45:24 +00:00
|
|
|
|
gpgme_get_io_cbs (gpgme_ctx_t ctx, gpgme_io_cbs_t io_cbs)
|
2002-06-10 Marcus Brinkmann <marcus@g10code.de>
* engine-gpgsm.c (_gpgme_gpgsm_start): Move the code that sets the
close notification for the status fd to ...
(_gpgme_gpgsm_new): ... here.
* wait.h: Include "sema.h". Remove prototypes of
_gpgme_remove_proc_from_wait_queue and
_gpgme_register_pipe_handler. Add prototypes of
_gpgme_fd_table_init, _gpgme_fd_table_deinit, _gpgme_fd_table_put,
_gpgme_add_io_cb, _gpgme_remove_io_cb, _gpgme_wait_event_cb and
_gpgme_wait_one..
* wait.c: Remove global variables PROC_QUEUE, PROC_QUEUE_LOCK,
FD_TABLE_SIZE, FD_TABLE, FD_TABLE_LOCK. New global variables
FDT_GLOBAL, CTX_DONE_LIST, CTX_DONE_LIST_SIZE,
CTX_DONE_LIST_LENGTH and CTX_DONE_LIST_LOCK. Remove struct
proc_s. Replace struct wait_item_s.
(_gpgme_fd_table_init): New function.
(_gpgme_fd_table_deinit): Likewise.
(_gpgme_fd_table_put): Likewise.
(set_process_done): Remove function.
(do_select): Take argument FDT. Use that to decide which fds to
select on.
(_gpgme_remove_proc_from_wait_queue): Remove function.
(_gpgme_wait_event_cb): New function.
(_gpgme_wait_one): Likewise.
(_gpgme_register_pipe_hanldler): Remove function.
(_gpgme_add_io_cb): New function.
(_gpgme_remove_io_cb): Likewise.
(_gpgme_freeze_fd): Remove function.
(_gpgme_thaw_fd): Remove function.
* rungpg.c (struct fd_data_map_s): Add new member TAG.
(struct gpg_object_s): Likewise for STATUS and COLON. Add member
IDX to CMD. Add new member IO_CBS.
(close_notify_handler): New variables POSSIBLY_DONE and NOT_DONE.
For each I/O callback, check if it should be unregistered. If all
callbacks have been unregistered, trigger GPGME_EVENT_DONE.
Remove member RUNNING.
(_gpgme_gpg_new): Initialize new members.
(_gpgme_gpg_release): Check PID not RUNNING. Don't call
_gpgme_remove_proc_from_wait_queue. Close GPG->CMD.FD if set.
(build_argv): Store away the index instead the file descriptor for
CMD.
(_gpgme_gpg_add_io_cb): New function.
(_gpgme_gpg_spawn): Use _gpgme_gpg_add_io_cb to register IO
callbacks.
(gpg_status_handler): Change return type to void, remove PID
argument, close filedescriptor if EOF or error occurs.
(read_status): Use _gpgme_gpg_add_io_cb instead _gpgme_thaw_fd.
Use IO_CBS->remove instead _gpgme_freeze_fd.
(gpg_colon_line_handler): Change return type to void, remove PID
argument, close filedescriptor if EOF or error occurs.
(command_cb): Use IO_CBS->remove instead _gpgme_freeze_fd.
(_gpgme_gpg_set_io_cbs): New function.
* rungpg.h (_gpgme_gpg_set_io_cbs): Prototype for
_gpgme_gpg_set_io_cbs.
* gpgme.h (GpgmeIOCb): New type.
(GpgmeRegisterIOCb): Likewise.
(GpgmeRemoveIOCb): Likewise.
(GpgmeEventIO): Likewise.
(GpgmeEventIOCb): Likewise.
(struct GpgmeIOCbs): New structure to hold I/O callbacks.
(gpgme_set_op_io_cbs): New prototype.
(gpgme_get_op_io_cbs): Likewise.
* ops.h: New prototype for _gpgme_op_event_cb. Remove prototypes
for _gpgme_freeze_fd and _gpgme_thaw_fd. Remove PID argument from
_gpgme_data_inbound_handler and _gpgme_data_outbound_handler
prototype. Add prototype for _gpgme_op_reset.
Add synchronous argument to _gpgme_decrypt_start prototype.
* io.h: Beautification.
* gpgme.c: Include "wait.h".
(gpgme_new): Initialize FDT.
(gpgme_set_io_cbs): New function.
(gpgme_get_io_cbs): Likewise.
(_gpgme_op_event_cb): Likewise.
* data.c (_gpgme_data_inbound_handler): Change return type to
void. Drop PID argument. Close FD on error and EOF.
(write_mem_data): Don't close FD here ...
(write_cb_data): ... or here ...
(_gpgme_data_outbound_handler): ... but here. Change return type
to void. Drop PID argument.
* context.h: Include "wait.h".
(struct gpgme_context_s): New members FDT and IO_CBS.
* op-support.c: New file.
* Makefile.am (libgpgme_la_SOURCES): Add op-support.c.
* ops.h: Add prototype for _gpgme_op_reset().
* decrypt.c (_gpgme_decrypt_start): New argument SYNCHRONOUS. Use
_gpgme_op_reset.
(gpgme_op_decrypt_start): Add synchronous argument.
(gpgme_op_decrypt): Likewise. Use _gpgme_wait_one instead
gpgme_wait.
* delete.c (gpgme_op_delete_start): Rename to ...
(_gpgme_op_delete_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_delete_start): Just a wrapper around
_gpgme_op_delete_start now.
(gpgme_op_delete): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* encrypt.c: Include "wait.h".
(ggpgme_op_encrypt_start): Rename to ...
(_gpgme_op_encrypt_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_encrypt_start): Just a wrapper around
_gpgme_op_encrypt_start now.
(gpgme_op_encrypt): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* encrypt_sign.c (gpgme_op_encrypt_sign_start): Rename to ...
(_gpgme_op_encrypt_sign_start): ... this. New argument
SYNCHRONOUS. Use _gpgme_op_reset. Make function static.
(gpgme_op_encrypt_sign_start): Just a wrapper around
_gpgme_op_encrypt_sign_start now.
(gpgme_op_encrypt_sign): Add synchronous argument. Use
_gpgme_wait_one instead gpgme_wait.
* export.c (gpgme_op_export_start): Rename to ...
(_gpgme_op_export_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_export_start): Just a wrapper around
_gpgme_op_export_start now.
(gpgme_op_export): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* genkey.c (gpgme_op_genkey_start): Rename to ...
(_gpgme_op_genkey_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_genkey_start): Just a wrapper around
_gpgme_op_genkey_start now.
(gpgme_op_genkey): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* import.c (gpgme_op_import_start): Rename to ...
(_gpgme_op_import_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_import_start): Just a wrapper around
_gpgme_op_import_start now.
(gpgme_op_import): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* keylist.c (gpgme_op_keylist_start): Use _gpgme_op_reset.
(gpgme_op_keylist_ext_start): Likewise.
* sign.c (gpgme_op_sign_start): Rename to ...
(_gpgme_op_sign_start): ... this. New argument SYNCHRONOUS. Use
_gpgme_op_reset. Make function static.
(gpgme_op_sign_start): Just a wrapper around _gpgme_op_sign_start
now.
(gpgme_op_sign): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* trustlist.c (gpgme_op_trustlist_start): Use _gpgme_op_reset.
* verify.c (gpgme_op_verify_start): Rename to ...
(_gpgme_op_verify_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_verify_start): Just a wrapper around
_gpgme_op_verify_start now.
(gpgme_op_verify): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* engine-gpgsm.c (iocb_data_t): New type.
(struct gpgsm_object_s): New member status_cb. Replace input_fd
and input_data with input_cb. Replace output_fd and output_data
with output_cb. Replace message_fd and message_data with
message_cb. New member io_cbs.
(_gpgme_gpgsm_new): Initialize all new members (and drop the old
ones).
(close_notify_handler): New variable POSSIBLY_DONE. For each I/O
callback, check if it should be unregistered. If all callbacks
have been unregistered, trigger GPGME_EVENT_DONE.
(_gpgme_gpgsm_release): Remove variable PID. Use new variable
names to close the file descriptors.
(_gpgme_gpgsm_op_decrypt): Use new variable names,
(_gpgme_gpgsm_op_encrypt): Likewise.
(_gpgme_gpgsm_op_genkey): Likewise.
(_gpgme_gpgsm_op_import): Likewise.
(_gpgme_gpgsm_op_keylist): Likewise.
(_gpgme_gpgsm_op_keylist_ext): Likewise.
(_gpgme_gpgsm_op_sign): Likewise.
(_gpgme_gpgsm_op_verify): Likewise.
(gpgsm_status_handler): Drop argument PID. Change return type to
void. Close status pipe before returning because of EOF or error.
(_gpgme_gpgsm_add_io_cb): New function.
(_gpgme_gpgsm_start): Use _gpgme_gpgsm_add_io_cb to register
callback function.
(_gpgme_gpgsm_set_io_cbs): New function.
* engine-gpgsm.h: New prototype for _gpgme_gpgsm_set_io_cbs.
* engine.c (_gpgme_engine_set_io_cbs): New function.
* engine.h: New prototype for _gpgme_engine_set_io_cbs.
2002-06-10 14:13:55 +00:00
|
|
|
|
{
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
TRACE6 (DEBUG_CTX, "gpgme_get_io_cbs", ctx,
|
|
|
|
|
"io_cbs=%p, ctx->io_cbs.add=%p/%p, .remove=%p, .event=%p/%p",
|
|
|
|
|
io_cbs, io_cbs->add, io_cbs->add_priv, io_cbs->remove,
|
|
|
|
|
io_cbs->event, io_cbs->event_priv);
|
|
|
|
|
|
2003-05-29 03:21:02 +00:00
|
|
|
|
*io_cbs = ctx->io_cbs;
|
2002-06-10 Marcus Brinkmann <marcus@g10code.de>
* engine-gpgsm.c (_gpgme_gpgsm_start): Move the code that sets the
close notification for the status fd to ...
(_gpgme_gpgsm_new): ... here.
* wait.h: Include "sema.h". Remove prototypes of
_gpgme_remove_proc_from_wait_queue and
_gpgme_register_pipe_handler. Add prototypes of
_gpgme_fd_table_init, _gpgme_fd_table_deinit, _gpgme_fd_table_put,
_gpgme_add_io_cb, _gpgme_remove_io_cb, _gpgme_wait_event_cb and
_gpgme_wait_one..
* wait.c: Remove global variables PROC_QUEUE, PROC_QUEUE_LOCK,
FD_TABLE_SIZE, FD_TABLE, FD_TABLE_LOCK. New global variables
FDT_GLOBAL, CTX_DONE_LIST, CTX_DONE_LIST_SIZE,
CTX_DONE_LIST_LENGTH and CTX_DONE_LIST_LOCK. Remove struct
proc_s. Replace struct wait_item_s.
(_gpgme_fd_table_init): New function.
(_gpgme_fd_table_deinit): Likewise.
(_gpgme_fd_table_put): Likewise.
(set_process_done): Remove function.
(do_select): Take argument FDT. Use that to decide which fds to
select on.
(_gpgme_remove_proc_from_wait_queue): Remove function.
(_gpgme_wait_event_cb): New function.
(_gpgme_wait_one): Likewise.
(_gpgme_register_pipe_hanldler): Remove function.
(_gpgme_add_io_cb): New function.
(_gpgme_remove_io_cb): Likewise.
(_gpgme_freeze_fd): Remove function.
(_gpgme_thaw_fd): Remove function.
* rungpg.c (struct fd_data_map_s): Add new member TAG.
(struct gpg_object_s): Likewise for STATUS and COLON. Add member
IDX to CMD. Add new member IO_CBS.
(close_notify_handler): New variables POSSIBLY_DONE and NOT_DONE.
For each I/O callback, check if it should be unregistered. If all
callbacks have been unregistered, trigger GPGME_EVENT_DONE.
Remove member RUNNING.
(_gpgme_gpg_new): Initialize new members.
(_gpgme_gpg_release): Check PID not RUNNING. Don't call
_gpgme_remove_proc_from_wait_queue. Close GPG->CMD.FD if set.
(build_argv): Store away the index instead the file descriptor for
CMD.
(_gpgme_gpg_add_io_cb): New function.
(_gpgme_gpg_spawn): Use _gpgme_gpg_add_io_cb to register IO
callbacks.
(gpg_status_handler): Change return type to void, remove PID
argument, close filedescriptor if EOF or error occurs.
(read_status): Use _gpgme_gpg_add_io_cb instead _gpgme_thaw_fd.
Use IO_CBS->remove instead _gpgme_freeze_fd.
(gpg_colon_line_handler): Change return type to void, remove PID
argument, close filedescriptor if EOF or error occurs.
(command_cb): Use IO_CBS->remove instead _gpgme_freeze_fd.
(_gpgme_gpg_set_io_cbs): New function.
* rungpg.h (_gpgme_gpg_set_io_cbs): Prototype for
_gpgme_gpg_set_io_cbs.
* gpgme.h (GpgmeIOCb): New type.
(GpgmeRegisterIOCb): Likewise.
(GpgmeRemoveIOCb): Likewise.
(GpgmeEventIO): Likewise.
(GpgmeEventIOCb): Likewise.
(struct GpgmeIOCbs): New structure to hold I/O callbacks.
(gpgme_set_op_io_cbs): New prototype.
(gpgme_get_op_io_cbs): Likewise.
* ops.h: New prototype for _gpgme_op_event_cb. Remove prototypes
for _gpgme_freeze_fd and _gpgme_thaw_fd. Remove PID argument from
_gpgme_data_inbound_handler and _gpgme_data_outbound_handler
prototype. Add prototype for _gpgme_op_reset.
Add synchronous argument to _gpgme_decrypt_start prototype.
* io.h: Beautification.
* gpgme.c: Include "wait.h".
(gpgme_new): Initialize FDT.
(gpgme_set_io_cbs): New function.
(gpgme_get_io_cbs): Likewise.
(_gpgme_op_event_cb): Likewise.
* data.c (_gpgme_data_inbound_handler): Change return type to
void. Drop PID argument. Close FD on error and EOF.
(write_mem_data): Don't close FD here ...
(write_cb_data): ... or here ...
(_gpgme_data_outbound_handler): ... but here. Change return type
to void. Drop PID argument.
* context.h: Include "wait.h".
(struct gpgme_context_s): New members FDT and IO_CBS.
* op-support.c: New file.
* Makefile.am (libgpgme_la_SOURCES): Add op-support.c.
* ops.h: Add prototype for _gpgme_op_reset().
* decrypt.c (_gpgme_decrypt_start): New argument SYNCHRONOUS. Use
_gpgme_op_reset.
(gpgme_op_decrypt_start): Add synchronous argument.
(gpgme_op_decrypt): Likewise. Use _gpgme_wait_one instead
gpgme_wait.
* delete.c (gpgme_op_delete_start): Rename to ...
(_gpgme_op_delete_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_delete_start): Just a wrapper around
_gpgme_op_delete_start now.
(gpgme_op_delete): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* encrypt.c: Include "wait.h".
(ggpgme_op_encrypt_start): Rename to ...
(_gpgme_op_encrypt_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_encrypt_start): Just a wrapper around
_gpgme_op_encrypt_start now.
(gpgme_op_encrypt): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* encrypt_sign.c (gpgme_op_encrypt_sign_start): Rename to ...
(_gpgme_op_encrypt_sign_start): ... this. New argument
SYNCHRONOUS. Use _gpgme_op_reset. Make function static.
(gpgme_op_encrypt_sign_start): Just a wrapper around
_gpgme_op_encrypt_sign_start now.
(gpgme_op_encrypt_sign): Add synchronous argument. Use
_gpgme_wait_one instead gpgme_wait.
* export.c (gpgme_op_export_start): Rename to ...
(_gpgme_op_export_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_export_start): Just a wrapper around
_gpgme_op_export_start now.
(gpgme_op_export): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* genkey.c (gpgme_op_genkey_start): Rename to ...
(_gpgme_op_genkey_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_genkey_start): Just a wrapper around
_gpgme_op_genkey_start now.
(gpgme_op_genkey): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* import.c (gpgme_op_import_start): Rename to ...
(_gpgme_op_import_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_import_start): Just a wrapper around
_gpgme_op_import_start now.
(gpgme_op_import): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* keylist.c (gpgme_op_keylist_start): Use _gpgme_op_reset.
(gpgme_op_keylist_ext_start): Likewise.
* sign.c (gpgme_op_sign_start): Rename to ...
(_gpgme_op_sign_start): ... this. New argument SYNCHRONOUS. Use
_gpgme_op_reset. Make function static.
(gpgme_op_sign_start): Just a wrapper around _gpgme_op_sign_start
now.
(gpgme_op_sign): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* trustlist.c (gpgme_op_trustlist_start): Use _gpgme_op_reset.
* verify.c (gpgme_op_verify_start): Rename to ...
(_gpgme_op_verify_start): ... this. New argument SYNCHRONOUS.
Use _gpgme_op_reset. Make function static.
(gpgme_op_verify_start): Just a wrapper around
_gpgme_op_verify_start now.
(gpgme_op_verify): Add synchronous argument. Use _gpgme_wait_one
instead gpgme_wait.
* engine-gpgsm.c (iocb_data_t): New type.
(struct gpgsm_object_s): New member status_cb. Replace input_fd
and input_data with input_cb. Replace output_fd and output_data
with output_cb. Replace message_fd and message_data with
message_cb. New member io_cbs.
(_gpgme_gpgsm_new): Initialize all new members (and drop the old
ones).
(close_notify_handler): New variable POSSIBLY_DONE. For each I/O
callback, check if it should be unregistered. If all callbacks
have been unregistered, trigger GPGME_EVENT_DONE.
(_gpgme_gpgsm_release): Remove variable PID. Use new variable
names to close the file descriptors.
(_gpgme_gpgsm_op_decrypt): Use new variable names,
(_gpgme_gpgsm_op_encrypt): Likewise.
(_gpgme_gpgsm_op_genkey): Likewise.
(_gpgme_gpgsm_op_import): Likewise.
(_gpgme_gpgsm_op_keylist): Likewise.
(_gpgme_gpgsm_op_keylist_ext): Likewise.
(_gpgme_gpgsm_op_sign): Likewise.
(_gpgme_gpgsm_op_verify): Likewise.
(gpgsm_status_handler): Drop argument PID. Change return type to
void. Close status pipe before returning because of EOF or error.
(_gpgme_gpgsm_add_io_cb): New function.
(_gpgme_gpgsm_start): Use _gpgme_gpgsm_add_io_cb to register
callback function.
(_gpgme_gpgsm_set_io_cbs): New function.
* engine-gpgsm.h: New prototype for _gpgme_gpgsm_set_io_cbs.
* engine.c (_gpgme_engine_set_io_cbs): New function.
* engine.h: New prototype for _gpgme_engine_set_io_cbs.
2002-06-10 14:13:55 +00:00
|
|
|
|
}
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Creating a Signature): Add info about
GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result.
(Crypto Operations): Add GpgmeInvalidUserID.
(Algorithms): New chapter.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID,
GpgmeNewSignature, GpgmeSignResult): New data types.
(gpgme_op_sign_result, gpgme_pubkey_algo_name,
gpgme_hash_algo_name): New prototypes.
* gpgme.c (gpgme_pubkey_algo_name): New function.
(gpgme_hash_algo_name): Likewise.
* ops.h (_gpgme_parse_inv_userid, _gpgme_op_sign_init_result): New
prototype.
(_gpgme_op_sign_status_handler): Fix prototype.
* op-support.c: Include <errno.h> and <string.h>.
(_gpgme_parse_inv_userid): New function.
* sign.c: Include <errno.h> and "gpgme.h", but not <stdio.h>,
<assert.h> and "util.h".
(SKIP_TOKEN_OR_RETURN): Remove macro.
(struct sign_result): Change to op_data_t type and rework it.
(release_sign_result): Rename to ...
(release_op_data): ... this and rewrite it.
(append_xml_info): Remove function.
(gpgme_op_sign_result): New function.
(parse_sig_created): New function.
(_gpgme_sign_status_handler): Change first argument to void *.
Rewrite the function to use the new result structure and functions.
(_gpgme_op_sign_init_result): New function.
(_gpgme_op_sign_start): Rename to ...
(sign_start): ... this. Call _gpgme_op_sign_init_result.
(gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start.
(gpgme_op_sign): Likewise.
2003-04-27 20:53:04 +00:00
|
|
|
|
|
2003-09-14 00:02:41 +00:00
|
|
|
|
|
|
|
|
|
/* This function sets the locale for the context CTX, or the default
|
|
|
|
|
locale if CTX is a null pointer. */
|
|
|
|
|
gpgme_error_t
|
|
|
|
|
gpgme_set_locale (gpgme_ctx_t ctx, int category, const char *value)
|
|
|
|
|
{
|
|
|
|
|
int failed = 0;
|
2006-07-16 13:36:04 +00:00
|
|
|
|
char *new_lc_ctype = NULL;
|
|
|
|
|
char *new_lc_messages = NULL;
|
2003-09-14 00:02:41 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
TRACE_BEG2 (DEBUG_CTX, "gpgme_set_locale", ctx,
|
|
|
|
|
"category=%i, value=%s", category, value ? value : "(null)");
|
|
|
|
|
|
2003-09-14 00:02:41 +00:00
|
|
|
|
#define PREPARE_ONE_LOCALE(lcat, ucat) \
|
|
|
|
|
if (!failed && value \
|
|
|
|
|
&& (category == LC_ALL || category == LC_ ## ucat)) \
|
|
|
|
|
{ \
|
|
|
|
|
new_lc_ ## lcat = strdup (value); \
|
|
|
|
|
if (!new_lc_ ## lcat) \
|
|
|
|
|
failed = 1; \
|
2006-07-16 13:36:04 +00:00
|
|
|
|
}
|
2003-09-14 00:02:41 +00:00
|
|
|
|
|
2010-05-07 01:32:54 +00:00
|
|
|
|
#ifdef LC_CTYPE
|
2003-09-14 00:02:41 +00:00
|
|
|
|
PREPARE_ONE_LOCALE (ctype, CTYPE);
|
2010-05-07 01:32:54 +00:00
|
|
|
|
#endif
|
2006-07-16 13:36:04 +00:00
|
|
|
|
#ifdef LC_MESSAGES
|
2003-09-14 00:02:41 +00:00
|
|
|
|
PREPARE_ONE_LOCALE (messages, MESSAGES);
|
2006-07-16 13:36:04 +00:00
|
|
|
|
#endif
|
2003-09-14 00:02:41 +00:00
|
|
|
|
|
|
|
|
|
if (failed)
|
|
|
|
|
{
|
2013-02-06 16:35:40 +00:00
|
|
|
|
int saved_err = gpg_error_from_syserror ();
|
2003-09-14 00:02:41 +00:00
|
|
|
|
|
|
|
|
|
if (new_lc_ctype)
|
|
|
|
|
free (new_lc_ctype);
|
|
|
|
|
if (new_lc_messages)
|
|
|
|
|
free (new_lc_messages);
|
|
|
|
|
|
2013-02-06 16:35:40 +00:00
|
|
|
|
return TRACE_ERR (saved_err);
|
2003-09-14 00:02:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define SET_ONE_LOCALE(lcat, ucat) \
|
|
|
|
|
if (category == LC_ALL || category == LC_ ## ucat) \
|
|
|
|
|
{ \
|
|
|
|
|
if (ctx) \
|
|
|
|
|
{ \
|
|
|
|
|
if (ctx->lc_ ## lcat) \
|
|
|
|
|
free (ctx->lc_ ## lcat); \
|
|
|
|
|
ctx->lc_ ## lcat = new_lc_ ## lcat; \
|
|
|
|
|
} \
|
|
|
|
|
else \
|
|
|
|
|
{ \
|
|
|
|
|
if (def_lc_ ## lcat) \
|
|
|
|
|
free (def_lc_ ## lcat); \
|
|
|
|
|
def_lc_ ## lcat = new_lc_ ## lcat; \
|
|
|
|
|
} \
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!ctx)
|
|
|
|
|
LOCK (def_lc_lock);
|
2010-05-07 01:32:54 +00:00
|
|
|
|
#ifdef LC_CTYPE
|
2003-09-14 00:02:41 +00:00
|
|
|
|
SET_ONE_LOCALE (ctype, CTYPE);
|
2010-05-07 01:32:54 +00:00
|
|
|
|
#endif
|
2006-07-16 13:36:04 +00:00
|
|
|
|
#ifdef LC_MESSAGES
|
2003-09-14 00:02:41 +00:00
|
|
|
|
SET_ONE_LOCALE (messages, MESSAGES);
|
2006-07-16 13:36:04 +00:00
|
|
|
|
#endif
|
2003-09-14 00:02:41 +00:00
|
|
|
|
if (!ctx)
|
|
|
|
|
UNLOCK (def_lc_lock);
|
2005-03-09 16:03:05 +00:00
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
return TRACE_ERR (0);
|
2003-09-14 00:02:41 +00:00
|
|
|
|
}
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Creating a Signature): Add info about
GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result.
(Crypto Operations): Add GpgmeInvalidUserID.
(Algorithms): New chapter.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID,
GpgmeNewSignature, GpgmeSignResult): New data types.
(gpgme_op_sign_result, gpgme_pubkey_algo_name,
gpgme_hash_algo_name): New prototypes.
* gpgme.c (gpgme_pubkey_algo_name): New function.
(gpgme_hash_algo_name): Likewise.
* ops.h (_gpgme_parse_inv_userid, _gpgme_op_sign_init_result): New
prototype.
(_gpgme_op_sign_status_handler): Fix prototype.
* op-support.c: Include <errno.h> and <string.h>.
(_gpgme_parse_inv_userid): New function.
* sign.c: Include <errno.h> and "gpgme.h", but not <stdio.h>,
<assert.h> and "util.h".
(SKIP_TOKEN_OR_RETURN): Remove macro.
(struct sign_result): Change to op_data_t type and rework it.
(release_sign_result): Rename to ...
(release_op_data): ... this and rewrite it.
(append_xml_info): Remove function.
(gpgme_op_sign_result): New function.
(parse_sig_created): New function.
(_gpgme_sign_status_handler): Change first argument to void *.
Rewrite the function to use the new result structure and functions.
(_gpgme_op_sign_init_result): New function.
(_gpgme_op_sign_start): Rename to ...
(sign_start): ... this. Call _gpgme_op_sign_init_result.
(gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start.
(gpgme_op_sign): Likewise.
2003-04-27 20:53:04 +00:00
|
|
|
|
|
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* libgpgme.vers (GPGME_1.1): New version.
* engine-backend.h (struct engine_ops): Add argument FILE_NAME to
member get_version(). Add arguments FILE_NAME and HOME_DIR to
member new(). Change return type of get_file_name and get_version
to char *.
* engine-gpgsm.c (gpgsm_get_version): Change return type to char
pointer. Do not cache result.
(gpgsm_new): Add file_name and home_dir argument, and use them
instead of the defaults, if set.
* rungpg.c (struct engine_gpg): New member file_name.
(gpg_get_version): Change return type to char pointer, and do not
cache result.
(gpg_release): Free gpg->file_name.
(gpg_new): Take new arguments file_name and home_dir. Set the
--homedir argument if HOME_DIR is not NULL. Set gpg->file_name.
(start): Use gpg->file_name instead _gpgme_get_gpg_path, if set.
* engine.h (_gpgme_engine_info_copy, _gpgme_engine_info_release):
New prototypes.
(_gpgme_engine_new): Change first argument to gpgme_engine_info_t
info.
* engine.c: Include <assert.h>.
(gpgme_get_engine_info): Set *INFO within the lock. Move
ENGINE_INFO and ENGINE_INFO_LOCK to ....
(engine_info, engine_info_lock): ... here. New static variables.
(engine_get_version): Add file_name argument to
get_version invocation. Change return type to char pointer.
(gpgme_engine_check_version): Rewritten to free() the return value
of engine_get_version after using it.
(_gpgme_engine_info_release): New function.
(gpgme_get_engine_info): Rewritten.
(_gpgme_engine_info_copy): New function.
(_gpgme_set_engine_info): New function.
(gpgme_set_engine_info): New function.
(_gpgme_engine_new): Change first argument to gpgme_engine_info_t
info, and use that.
* gpgme.h (struct _gpgme_engine_info): Change type of file_name
and version to char * (remove the const). New member home_dir.
(gpgme_set_engine_info, gpgme_ctx_get_engine_info,
gpgme_ctx_set_engine_info): New prototypes.
* context.h (struct gpgme_context): New member engine_info.
* gpgme.c (gpgme_new): Allocate CTX->engine_info.
(gpgme_release): Deallocate CTX->engine_info.
(gpgme_ctx_get_engine_info, gpgme_ctx_set_engine_info): New
functions.
* op-support.c (_gpgme_op_reset): Look for correct engine info and
pass it to _gpgme_engine_new.
* version.c (gpgme_check_version): Adjust to
_gpgme_compare_versions returning an int.
(_gpgme_compare_versions): Return an int value, not a const char
pointer.
* ops.h (_gpgme_compare_versions): Same for prototype.
2004-12-07 18:25:54 +00:00
|
|
|
|
|
|
|
|
|
/* Get the information about the configured engines. A pointer to the
|
|
|
|
|
first engine in the statically allocated linked list is returned.
|
|
|
|
|
The returned data is valid until the next gpgme_ctx_set_engine_info. */
|
|
|
|
|
gpgme_engine_info_t
|
|
|
|
|
gpgme_ctx_get_engine_info (gpgme_ctx_t ctx)
|
|
|
|
|
{
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
TRACE1 (DEBUG_CTX, "gpgme_ctx_get_engine_info", ctx,
|
|
|
|
|
"ctx->engine_info=%p", ctx->engine_info);
|
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* libgpgme.vers (GPGME_1.1): New version.
* engine-backend.h (struct engine_ops): Add argument FILE_NAME to
member get_version(). Add arguments FILE_NAME and HOME_DIR to
member new(). Change return type of get_file_name and get_version
to char *.
* engine-gpgsm.c (gpgsm_get_version): Change return type to char
pointer. Do not cache result.
(gpgsm_new): Add file_name and home_dir argument, and use them
instead of the defaults, if set.
* rungpg.c (struct engine_gpg): New member file_name.
(gpg_get_version): Change return type to char pointer, and do not
cache result.
(gpg_release): Free gpg->file_name.
(gpg_new): Take new arguments file_name and home_dir. Set the
--homedir argument if HOME_DIR is not NULL. Set gpg->file_name.
(start): Use gpg->file_name instead _gpgme_get_gpg_path, if set.
* engine.h (_gpgme_engine_info_copy, _gpgme_engine_info_release):
New prototypes.
(_gpgme_engine_new): Change first argument to gpgme_engine_info_t
info.
* engine.c: Include <assert.h>.
(gpgme_get_engine_info): Set *INFO within the lock. Move
ENGINE_INFO and ENGINE_INFO_LOCK to ....
(engine_info, engine_info_lock): ... here. New static variables.
(engine_get_version): Add file_name argument to
get_version invocation. Change return type to char pointer.
(gpgme_engine_check_version): Rewritten to free() the return value
of engine_get_version after using it.
(_gpgme_engine_info_release): New function.
(gpgme_get_engine_info): Rewritten.
(_gpgme_engine_info_copy): New function.
(_gpgme_set_engine_info): New function.
(gpgme_set_engine_info): New function.
(_gpgme_engine_new): Change first argument to gpgme_engine_info_t
info, and use that.
* gpgme.h (struct _gpgme_engine_info): Change type of file_name
and version to char * (remove the const). New member home_dir.
(gpgme_set_engine_info, gpgme_ctx_get_engine_info,
gpgme_ctx_set_engine_info): New prototypes.
* context.h (struct gpgme_context): New member engine_info.
* gpgme.c (gpgme_new): Allocate CTX->engine_info.
(gpgme_release): Deallocate CTX->engine_info.
(gpgme_ctx_get_engine_info, gpgme_ctx_set_engine_info): New
functions.
* op-support.c (_gpgme_op_reset): Look for correct engine info and
pass it to _gpgme_engine_new.
* version.c (gpgme_check_version): Adjust to
_gpgme_compare_versions returning an int.
(_gpgme_compare_versions): Return an int value, not a const char
pointer.
* ops.h (_gpgme_compare_versions): Same for prototype.
2004-12-07 18:25:54 +00:00
|
|
|
|
return ctx->engine_info;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Set the engine info for the context CTX, protocol PROTO, to the
|
|
|
|
|
file name FILE_NAME and the home directory HOME_DIR. */
|
|
|
|
|
gpgme_error_t
|
|
|
|
|
gpgme_ctx_set_engine_info (gpgme_ctx_t ctx, gpgme_protocol_t proto,
|
|
|
|
|
const char *file_name, const char *home_dir)
|
|
|
|
|
{
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
gpgme_error_t err;
|
|
|
|
|
TRACE_BEG4 (DEBUG_CTX, "gpgme_ctx_set_engine_info", ctx,
|
|
|
|
|
"protocol=%i (%s), file_name=%s, home_dir=%s",
|
|
|
|
|
proto, gpgme_get_protocol_name (proto)
|
|
|
|
|
? gpgme_get_protocol_name (proto) : "unknown",
|
|
|
|
|
file_name ? file_name : "(default)",
|
|
|
|
|
home_dir ? home_dir : "(default)");
|
2011-05-26 14:01:26 +00:00
|
|
|
|
|
|
|
|
|
if (!ctx)
|
|
|
|
|
return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2006-12-17 21:12:40 +00:00
|
|
|
|
/* Shut down the engine when changing engine info. */
|
|
|
|
|
if (ctx->engine)
|
|
|
|
|
{
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
TRACE_LOG1 ("releasing ctx->engine=%p", ctx->engine);
|
2006-12-17 21:12:40 +00:00
|
|
|
|
_gpgme_engine_release (ctx->engine);
|
|
|
|
|
ctx->engine = NULL;
|
|
|
|
|
}
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
err = _gpgme_set_engine_info (ctx->engine_info, proto,
|
|
|
|
|
file_name, home_dir);
|
|
|
|
|
return TRACE_ERR (err);
|
2004-12-07 Marcus Brinkmann <marcus@g10code.de>
* libgpgme.vers (GPGME_1.1): New version.
* engine-backend.h (struct engine_ops): Add argument FILE_NAME to
member get_version(). Add arguments FILE_NAME and HOME_DIR to
member new(). Change return type of get_file_name and get_version
to char *.
* engine-gpgsm.c (gpgsm_get_version): Change return type to char
pointer. Do not cache result.
(gpgsm_new): Add file_name and home_dir argument, and use them
instead of the defaults, if set.
* rungpg.c (struct engine_gpg): New member file_name.
(gpg_get_version): Change return type to char pointer, and do not
cache result.
(gpg_release): Free gpg->file_name.
(gpg_new): Take new arguments file_name and home_dir. Set the
--homedir argument if HOME_DIR is not NULL. Set gpg->file_name.
(start): Use gpg->file_name instead _gpgme_get_gpg_path, if set.
* engine.h (_gpgme_engine_info_copy, _gpgme_engine_info_release):
New prototypes.
(_gpgme_engine_new): Change first argument to gpgme_engine_info_t
info.
* engine.c: Include <assert.h>.
(gpgme_get_engine_info): Set *INFO within the lock. Move
ENGINE_INFO and ENGINE_INFO_LOCK to ....
(engine_info, engine_info_lock): ... here. New static variables.
(engine_get_version): Add file_name argument to
get_version invocation. Change return type to char pointer.
(gpgme_engine_check_version): Rewritten to free() the return value
of engine_get_version after using it.
(_gpgme_engine_info_release): New function.
(gpgme_get_engine_info): Rewritten.
(_gpgme_engine_info_copy): New function.
(_gpgme_set_engine_info): New function.
(gpgme_set_engine_info): New function.
(_gpgme_engine_new): Change first argument to gpgme_engine_info_t
info, and use that.
* gpgme.h (struct _gpgme_engine_info): Change type of file_name
and version to char * (remove the const). New member home_dir.
(gpgme_set_engine_info, gpgme_ctx_get_engine_info,
gpgme_ctx_set_engine_info): New prototypes.
* context.h (struct gpgme_context): New member engine_info.
* gpgme.c (gpgme_new): Allocate CTX->engine_info.
(gpgme_release): Deallocate CTX->engine_info.
(gpgme_ctx_get_engine_info, gpgme_ctx_set_engine_info): New
functions.
* op-support.c (_gpgme_op_reset): Look for correct engine info and
pass it to _gpgme_engine_new.
* version.c (gpgme_check_version): Adjust to
_gpgme_compare_versions returning an int.
(_gpgme_compare_versions): Return an int value, not a const char
pointer.
* ops.h (_gpgme_compare_versions): Same for prototype.
2004-12-07 18:25:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-10-01 02:33:35 +00:00
|
|
|
|
|
|
|
|
|
/* Clear all notation data from the context. */
|
|
|
|
|
void
|
2009-10-30 14:21:08 +00:00
|
|
|
|
_gpgme_sig_notation_clear (gpgme_ctx_t ctx)
|
2005-10-01 02:33:35 +00:00
|
|
|
|
{
|
|
|
|
|
gpgme_sig_notation_t notation;
|
|
|
|
|
|
|
|
|
|
if (!ctx)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
notation = ctx->sig_notations;
|
|
|
|
|
while (notation)
|
|
|
|
|
{
|
|
|
|
|
gpgme_sig_notation_t next_notation = notation->next;
|
|
|
|
|
_gpgme_sig_notation_free (notation);
|
|
|
|
|
notation = next_notation;
|
|
|
|
|
}
|
2008-09-23 10:52:09 +00:00
|
|
|
|
ctx->sig_notations = NULL;
|
2005-10-01 02:33:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-10-30 14:21:08 +00:00
|
|
|
|
void
|
|
|
|
|
gpgme_sig_notation_clear (gpgme_ctx_t ctx)
|
|
|
|
|
{
|
|
|
|
|
TRACE (DEBUG_CTX, "gpgme_sig_notation_clear", ctx);
|
2011-05-26 14:01:26 +00:00
|
|
|
|
|
|
|
|
|
if (!ctx)
|
|
|
|
|
return;
|
|
|
|
|
|
2009-10-30 14:21:08 +00:00
|
|
|
|
_gpgme_sig_notation_clear (ctx);
|
|
|
|
|
}
|
|
|
|
|
|
2005-10-01 02:33:35 +00:00
|
|
|
|
|
|
|
|
|
/* Add the human-readable notation data with name NAME and value VALUE
|
|
|
|
|
to the context CTX, using the flags FLAGS. If NAME is NULL, then
|
|
|
|
|
VALUE should be a policy URL. The flag
|
|
|
|
|
GPGME_SIG_NOTATION_HUMAN_READABLE is forced to be true for notation
|
|
|
|
|
data, and false for policy URLs. */
|
|
|
|
|
gpgme_error_t
|
|
|
|
|
gpgme_sig_notation_add (gpgme_ctx_t ctx, const char *name,
|
|
|
|
|
const char *value, gpgme_sig_notation_flags_t flags)
|
|
|
|
|
{
|
|
|
|
|
gpgme_error_t err;
|
|
|
|
|
gpgme_sig_notation_t notation;
|
|
|
|
|
gpgme_sig_notation_t *lastp;
|
|
|
|
|
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
TRACE_BEG3 (DEBUG_CTX, "gpgme_sig_notation_add", ctx,
|
|
|
|
|
"name=%s, value=%s, flags=0x%x",
|
|
|
|
|
name ? name : "(null)", value ? value : "(null)",
|
|
|
|
|
flags);
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2005-10-01 02:33:35 +00:00
|
|
|
|
if (!ctx)
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
return TRACE_ERR (gpg_error (GPG_ERR_INV_VALUE));
|
2005-10-01 02:33:35 +00:00
|
|
|
|
|
|
|
|
|
if (name)
|
|
|
|
|
flags |= GPGME_SIG_NOTATION_HUMAN_READABLE;
|
|
|
|
|
else
|
|
|
|
|
flags &= ~GPGME_SIG_NOTATION_HUMAN_READABLE;
|
|
|
|
|
|
|
|
|
|
err = _gpgme_sig_notation_create (¬ation, name, name ? strlen (name) : 0,
|
|
|
|
|
value, value ? strlen (value) : 0, flags);
|
|
|
|
|
if (err)
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
return TRACE_ERR (err);
|
2005-10-01 02:33:35 +00:00
|
|
|
|
|
|
|
|
|
lastp = &ctx->sig_notations;
|
|
|
|
|
while (*lastp)
|
|
|
|
|
lastp = &(*lastp)->next;
|
|
|
|
|
|
|
|
|
|
*lastp = notation;
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
return TRACE_ERR (0);
|
2005-10-01 02:33:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Get the sig notations for this context. */
|
|
|
|
|
gpgme_sig_notation_t
|
|
|
|
|
gpgme_sig_notation_get (gpgme_ctx_t ctx)
|
|
|
|
|
{
|
|
|
|
|
if (!ctx)
|
2007-07-17 Marcus Brinkmann <marcus@g10code.de>
* debug.c:;5B Include <errno.h> and "debug.h".
(_gpgme_debug): Save and restore ERRNO.
(TOHEX): New macro.
(_gpgme_debug_buffer): New function.
* conversion.c, data-compat.c, data-mem.c, data.c, engine-gpgsm.c,
gpgme.c, keylist.c, posix-io.c, rungpg.c, sign.c, version.c,
w32-io.c, wait.c: Replace DEBUG macros by TRACE_* variants. In
most of these files, add many more tracepoints.
2007-07-17 12:36:04 +00:00
|
|
|
|
{
|
|
|
|
|
TRACE (DEBUG_CTX, "gpgme_sig_notation_get", ctx);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
TRACE1 (DEBUG_CTX, "gpgme_sig_notation_get", ctx,
|
|
|
|
|
"ctx->sig_notations=%p", ctx->sig_notations);
|
2005-10-01 02:33:35 +00:00
|
|
|
|
|
|
|
|
|
return ctx->sig_notations;
|
|
|
|
|
}
|
2012-09-25 13:29:49 +00:00
|
|
|
|
|
2015-08-30 17:04:44 +00:00
|
|
|
|
|
2003-09-14 00:02:41 +00:00
|
|
|
|
|
2015-08-30 17:04:44 +00:00
|
|
|
|
/* Return a public key algorithm string made of the algorithm and size
|
|
|
|
|
or the curve name. May return NULL on error. Caller must free the
|
|
|
|
|
result using gpgme_free. */
|
|
|
|
|
char *
|
|
|
|
|
gpgme_pubkey_algo_string (gpgme_subkey_t subkey)
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Creating a Signature): Add info about
GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result.
(Crypto Operations): Add GpgmeInvalidUserID.
(Algorithms): New chapter.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID,
GpgmeNewSignature, GpgmeSignResult): New data types.
(gpgme_op_sign_result, gpgme_pubkey_algo_name,
gpgme_hash_algo_name): New prototypes.
* gpgme.c (gpgme_pubkey_algo_name): New function.
(gpgme_hash_algo_name): Likewise.
* ops.h (_gpgme_parse_inv_userid, _gpgme_op_sign_init_result): New
prototype.
(_gpgme_op_sign_status_handler): Fix prototype.
* op-support.c: Include <errno.h> and <string.h>.
(_gpgme_parse_inv_userid): New function.
* sign.c: Include <errno.h> and "gpgme.h", but not <stdio.h>,
<assert.h> and "util.h".
(SKIP_TOKEN_OR_RETURN): Remove macro.
(struct sign_result): Change to op_data_t type and rework it.
(release_sign_result): Rename to ...
(release_op_data): ... this and rewrite it.
(append_xml_info): Remove function.
(gpgme_op_sign_result): New function.
(parse_sig_created): New function.
(_gpgme_sign_status_handler): Change first argument to void *.
Rewrite the function to use the new result structure and functions.
(_gpgme_op_sign_init_result): New function.
(_gpgme_op_sign_start): Rename to ...
(sign_start): ... this. Call _gpgme_op_sign_init_result.
(gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start.
(gpgme_op_sign): Likewise.
2003-04-27 20:53:04 +00:00
|
|
|
|
{
|
2015-08-30 17:04:44 +00:00
|
|
|
|
const char *prefix = NULL;
|
|
|
|
|
char *result;
|
|
|
|
|
|
|
|
|
|
if (!subkey)
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Creating a Signature): Add info about
GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result.
(Crypto Operations): Add GpgmeInvalidUserID.
(Algorithms): New chapter.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID,
GpgmeNewSignature, GpgmeSignResult): New data types.
(gpgme_op_sign_result, gpgme_pubkey_algo_name,
gpgme_hash_algo_name): New prototypes.
* gpgme.c (gpgme_pubkey_algo_name): New function.
(gpgme_hash_algo_name): Likewise.
* ops.h (_gpgme_parse_inv_userid, _gpgme_op_sign_init_result): New
prototype.
(_gpgme_op_sign_status_handler): Fix prototype.
* op-support.c: Include <errno.h> and <string.h>.
(_gpgme_parse_inv_userid): New function.
* sign.c: Include <errno.h> and "gpgme.h", but not <stdio.h>,
<assert.h> and "util.h".
(SKIP_TOKEN_OR_RETURN): Remove macro.
(struct sign_result): Change to op_data_t type and rework it.
(release_sign_result): Rename to ...
(release_op_data): ... this and rewrite it.
(append_xml_info): Remove function.
(gpgme_op_sign_result): New function.
(parse_sig_created): New function.
(_gpgme_sign_status_handler): Change first argument to void *.
Rewrite the function to use the new result structure and functions.
(_gpgme_op_sign_init_result): New function.
(_gpgme_op_sign_start): Rename to ...
(sign_start): ... this. Call _gpgme_op_sign_init_result.
(gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start.
(gpgme_op_sign): Likewise.
2003-04-27 20:53:04 +00:00
|
|
|
|
{
|
2015-08-30 17:04:44 +00:00
|
|
|
|
gpg_err_set_errno (EINVAL);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Creating a Signature): Add info about
GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result.
(Crypto Operations): Add GpgmeInvalidUserID.
(Algorithms): New chapter.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID,
GpgmeNewSignature, GpgmeSignResult): New data types.
(gpgme_op_sign_result, gpgme_pubkey_algo_name,
gpgme_hash_algo_name): New prototypes.
* gpgme.c (gpgme_pubkey_algo_name): New function.
(gpgme_hash_algo_name): Likewise.
* ops.h (_gpgme_parse_inv_userid, _gpgme_op_sign_init_result): New
prototype.
(_gpgme_op_sign_status_handler): Fix prototype.
* op-support.c: Include <errno.h> and <string.h>.
(_gpgme_parse_inv_userid): New function.
* sign.c: Include <errno.h> and "gpgme.h", but not <stdio.h>,
<assert.h> and "util.h".
(SKIP_TOKEN_OR_RETURN): Remove macro.
(struct sign_result): Change to op_data_t type and rework it.
(release_sign_result): Rename to ...
(release_op_data): ... this and rewrite it.
(append_xml_info): Remove function.
(gpgme_op_sign_result): New function.
(parse_sig_created): New function.
(_gpgme_sign_status_handler): Change first argument to void *.
Rewrite the function to use the new result structure and functions.
(_gpgme_op_sign_init_result): New function.
(_gpgme_op_sign_start): Rename to ...
(sign_start): ... this. Call _gpgme_op_sign_init_result.
(gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start.
(gpgme_op_sign): Likewise.
2003-04-27 20:53:04 +00:00
|
|
|
|
|
2015-08-30 17:04:44 +00:00
|
|
|
|
switch (subkey->pubkey_algo)
|
|
|
|
|
{
|
|
|
|
|
case GPGME_PK_RSA:
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Creating a Signature): Add info about
GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result.
(Crypto Operations): Add GpgmeInvalidUserID.
(Algorithms): New chapter.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID,
GpgmeNewSignature, GpgmeSignResult): New data types.
(gpgme_op_sign_result, gpgme_pubkey_algo_name,
gpgme_hash_algo_name): New prototypes.
* gpgme.c (gpgme_pubkey_algo_name): New function.
(gpgme_hash_algo_name): Likewise.
* ops.h (_gpgme_parse_inv_userid, _gpgme_op_sign_init_result): New
prototype.
(_gpgme_op_sign_status_handler): Fix prototype.
* op-support.c: Include <errno.h> and <string.h>.
(_gpgme_parse_inv_userid): New function.
* sign.c: Include <errno.h> and "gpgme.h", but not <stdio.h>,
<assert.h> and "util.h".
(SKIP_TOKEN_OR_RETURN): Remove macro.
(struct sign_result): Change to op_data_t type and rework it.
(release_sign_result): Rename to ...
(release_op_data): ... this and rewrite it.
(append_xml_info): Remove function.
(gpgme_op_sign_result): New function.
(parse_sig_created): New function.
(_gpgme_sign_status_handler): Change first argument to void *.
Rewrite the function to use the new result structure and functions.
(_gpgme_op_sign_init_result): New function.
(_gpgme_op_sign_start): Rename to ...
(sign_start): ... this. Call _gpgme_op_sign_init_result.
(gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start.
(gpgme_op_sign): Likewise.
2003-04-27 20:53:04 +00:00
|
|
|
|
case GPGME_PK_RSA_E:
|
2015-08-30 17:04:44 +00:00
|
|
|
|
case GPGME_PK_RSA_S: prefix = "rsa"; break;
|
|
|
|
|
case GPGME_PK_ELG_E: prefix = "elg"; break;
|
|
|
|
|
case GPGME_PK_DSA: prefix = "dsa"; break;
|
|
|
|
|
case GPGME_PK_ELG: prefix = "xxx"; break;
|
2014-05-08 12:03:14 +00:00
|
|
|
|
case GPGME_PK_ECC:
|
2015-08-30 17:04:44 +00:00
|
|
|
|
case GPGME_PK_ECDH:
|
|
|
|
|
case GPGME_PK_ECDSA:
|
|
|
|
|
case GPGME_PK_EDDSA: prefix = ""; break;
|
|
|
|
|
}
|
2014-05-08 12:03:14 +00:00
|
|
|
|
|
2015-08-30 17:04:44 +00:00
|
|
|
|
if (prefix && *prefix)
|
|
|
|
|
{
|
|
|
|
|
char buffer[40];
|
|
|
|
|
snprintf (buffer, sizeof buffer, "%s%u", prefix, subkey->length);
|
|
|
|
|
result = strdup (buffer);
|
|
|
|
|
}
|
|
|
|
|
else if (prefix && subkey->curve && *subkey->curve)
|
|
|
|
|
result = strdup (subkey->curve);
|
|
|
|
|
else if (prefix)
|
|
|
|
|
result = strdup ("E_error");
|
|
|
|
|
else
|
|
|
|
|
result = strdup ("unknown");
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Creating a Signature): Add info about
GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result.
(Crypto Operations): Add GpgmeInvalidUserID.
(Algorithms): New chapter.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID,
GpgmeNewSignature, GpgmeSignResult): New data types.
(gpgme_op_sign_result, gpgme_pubkey_algo_name,
gpgme_hash_algo_name): New prototypes.
* gpgme.c (gpgme_pubkey_algo_name): New function.
(gpgme_hash_algo_name): Likewise.
* ops.h (_gpgme_parse_inv_userid, _gpgme_op_sign_init_result): New
prototype.
(_gpgme_op_sign_status_handler): Fix prototype.
* op-support.c: Include <errno.h> and <string.h>.
(_gpgme_parse_inv_userid): New function.
* sign.c: Include <errno.h> and "gpgme.h", but not <stdio.h>,
<assert.h> and "util.h".
(SKIP_TOKEN_OR_RETURN): Remove macro.
(struct sign_result): Change to op_data_t type and rework it.
(release_sign_result): Rename to ...
(release_op_data): ... this and rewrite it.
(append_xml_info): Remove function.
(gpgme_op_sign_result): New function.
(parse_sig_created): New function.
(_gpgme_sign_status_handler): Change first argument to void *.
Rewrite the function to use the new result structure and functions.
(_gpgme_op_sign_init_result): New function.
(_gpgme_op_sign_start): Rename to ...
(sign_start): ... this. Call _gpgme_op_sign_init_result.
(gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start.
(gpgme_op_sign): Likewise.
2003-04-27 20:53:04 +00:00
|
|
|
|
|
2015-08-30 17:04:44 +00:00
|
|
|
|
return result;
|
|
|
|
|
}
|
2010-01-05 17:36:53 +00:00
|
|
|
|
|
|
|
|
|
|
2015-08-30 17:04:44 +00:00
|
|
|
|
const char *
|
|
|
|
|
gpgme_pubkey_algo_name (gpgme_pubkey_algo_t algo)
|
|
|
|
|
{
|
|
|
|
|
switch (algo)
|
|
|
|
|
{
|
|
|
|
|
case GPGME_PK_RSA: return "RSA";
|
|
|
|
|
case GPGME_PK_RSA_E: return "RSA-E";
|
|
|
|
|
case GPGME_PK_RSA_S: return "RSA-S";
|
|
|
|
|
case GPGME_PK_ELG_E: return "ELG-E";
|
|
|
|
|
case GPGME_PK_DSA: return "DSA";
|
|
|
|
|
case GPGME_PK_ECC: return "ECC";
|
|
|
|
|
case GPGME_PK_ELG: return "ELG";
|
|
|
|
|
case GPGME_PK_ECDSA: return "ECDSA";
|
|
|
|
|
case GPGME_PK_ECDH: return "ECDH";
|
|
|
|
|
case GPGME_PK_EDDSA: return "EdDSA";
|
|
|
|
|
default: return NULL;
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Creating a Signature): Add info about
GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result.
(Crypto Operations): Add GpgmeInvalidUserID.
(Algorithms): New chapter.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID,
GpgmeNewSignature, GpgmeSignResult): New data types.
(gpgme_op_sign_result, gpgme_pubkey_algo_name,
gpgme_hash_algo_name): New prototypes.
* gpgme.c (gpgme_pubkey_algo_name): New function.
(gpgme_hash_algo_name): Likewise.
* ops.h (_gpgme_parse_inv_userid, _gpgme_op_sign_init_result): New
prototype.
(_gpgme_op_sign_status_handler): Fix prototype.
* op-support.c: Include <errno.h> and <string.h>.
(_gpgme_parse_inv_userid): New function.
* sign.c: Include <errno.h> and "gpgme.h", but not <stdio.h>,
<assert.h> and "util.h".
(SKIP_TOKEN_OR_RETURN): Remove macro.
(struct sign_result): Change to op_data_t type and rework it.
(release_sign_result): Rename to ...
(release_op_data): ... this and rewrite it.
(append_xml_info): Remove function.
(gpgme_op_sign_result): New function.
(parse_sig_created): New function.
(_gpgme_sign_status_handler): Change first argument to void *.
Rewrite the function to use the new result structure and functions.
(_gpgme_op_sign_init_result): New function.
(_gpgme_op_sign_start): Rename to ...
(sign_start): ... this. Call _gpgme_op_sign_init_result.
(gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start.
(gpgme_op_sign): Likewise.
2003-04-27 20:53:04 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const char *
|
2003-05-18 20:45:24 +00:00
|
|
|
|
gpgme_hash_algo_name (gpgme_hash_algo_t algo)
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Creating a Signature): Add info about
GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result.
(Crypto Operations): Add GpgmeInvalidUserID.
(Algorithms): New chapter.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID,
GpgmeNewSignature, GpgmeSignResult): New data types.
(gpgme_op_sign_result, gpgme_pubkey_algo_name,
gpgme_hash_algo_name): New prototypes.
* gpgme.c (gpgme_pubkey_algo_name): New function.
(gpgme_hash_algo_name): Likewise.
* ops.h (_gpgme_parse_inv_userid, _gpgme_op_sign_init_result): New
prototype.
(_gpgme_op_sign_status_handler): Fix prototype.
* op-support.c: Include <errno.h> and <string.h>.
(_gpgme_parse_inv_userid): New function.
* sign.c: Include <errno.h> and "gpgme.h", but not <stdio.h>,
<assert.h> and "util.h".
(SKIP_TOKEN_OR_RETURN): Remove macro.
(struct sign_result): Change to op_data_t type and rework it.
(release_sign_result): Rename to ...
(release_op_data): ... this and rewrite it.
(append_xml_info): Remove function.
(gpgme_op_sign_result): New function.
(parse_sig_created): New function.
(_gpgme_sign_status_handler): Change first argument to void *.
Rewrite the function to use the new result structure and functions.
(_gpgme_op_sign_init_result): New function.
(_gpgme_op_sign_start): Rename to ...
(sign_start): ... this. Call _gpgme_op_sign_init_result.
(gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start.
(gpgme_op_sign): Likewise.
2003-04-27 20:53:04 +00:00
|
|
|
|
{
|
|
|
|
|
switch (algo)
|
|
|
|
|
{
|
|
|
|
|
case GPGME_MD_MD5:
|
|
|
|
|
return "MD5";
|
|
|
|
|
|
|
|
|
|
case GPGME_MD_SHA1:
|
|
|
|
|
return "SHA1";
|
|
|
|
|
|
|
|
|
|
case GPGME_MD_RMD160:
|
2003-09-30 17:19:13 +00:00
|
|
|
|
return "RIPEMD160";
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Creating a Signature): Add info about
GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result.
(Crypto Operations): Add GpgmeInvalidUserID.
(Algorithms): New chapter.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID,
GpgmeNewSignature, GpgmeSignResult): New data types.
(gpgme_op_sign_result, gpgme_pubkey_algo_name,
gpgme_hash_algo_name): New prototypes.
* gpgme.c (gpgme_pubkey_algo_name): New function.
(gpgme_hash_algo_name): Likewise.
* ops.h (_gpgme_parse_inv_userid, _gpgme_op_sign_init_result): New
prototype.
(_gpgme_op_sign_status_handler): Fix prototype.
* op-support.c: Include <errno.h> and <string.h>.
(_gpgme_parse_inv_userid): New function.
* sign.c: Include <errno.h> and "gpgme.h", but not <stdio.h>,
<assert.h> and "util.h".
(SKIP_TOKEN_OR_RETURN): Remove macro.
(struct sign_result): Change to op_data_t type and rework it.
(release_sign_result): Rename to ...
(release_op_data): ... this and rewrite it.
(append_xml_info): Remove function.
(gpgme_op_sign_result): New function.
(parse_sig_created): New function.
(_gpgme_sign_status_handler): Change first argument to void *.
Rewrite the function to use the new result structure and functions.
(_gpgme_op_sign_init_result): New function.
(_gpgme_op_sign_start): Rename to ...
(sign_start): ... this. Call _gpgme_op_sign_init_result.
(gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start.
(gpgme_op_sign): Likewise.
2003-04-27 20:53:04 +00:00
|
|
|
|
|
|
|
|
|
case GPGME_MD_MD2:
|
|
|
|
|
return "MD2";
|
|
|
|
|
|
|
|
|
|
case GPGME_MD_TIGER:
|
2003-09-30 17:19:13 +00:00
|
|
|
|
return "TIGER192";
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Creating a Signature): Add info about
GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result.
(Crypto Operations): Add GpgmeInvalidUserID.
(Algorithms): New chapter.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID,
GpgmeNewSignature, GpgmeSignResult): New data types.
(gpgme_op_sign_result, gpgme_pubkey_algo_name,
gpgme_hash_algo_name): New prototypes.
* gpgme.c (gpgme_pubkey_algo_name): New function.
(gpgme_hash_algo_name): Likewise.
* ops.h (_gpgme_parse_inv_userid, _gpgme_op_sign_init_result): New
prototype.
(_gpgme_op_sign_status_handler): Fix prototype.
* op-support.c: Include <errno.h> and <string.h>.
(_gpgme_parse_inv_userid): New function.
* sign.c: Include <errno.h> and "gpgme.h", but not <stdio.h>,
<assert.h> and "util.h".
(SKIP_TOKEN_OR_RETURN): Remove macro.
(struct sign_result): Change to op_data_t type and rework it.
(release_sign_result): Rename to ...
(release_op_data): ... this and rewrite it.
(append_xml_info): Remove function.
(gpgme_op_sign_result): New function.
(parse_sig_created): New function.
(_gpgme_sign_status_handler): Change first argument to void *.
Rewrite the function to use the new result structure and functions.
(_gpgme_op_sign_init_result): New function.
(_gpgme_op_sign_start): Rename to ...
(sign_start): ... this. Call _gpgme_op_sign_init_result.
(gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start.
(gpgme_op_sign): Likewise.
2003-04-27 20:53:04 +00:00
|
|
|
|
|
|
|
|
|
case GPGME_MD_HAVAL:
|
|
|
|
|
return "HAVAL";
|
|
|
|
|
|
|
|
|
|
case GPGME_MD_SHA256:
|
|
|
|
|
return "SHA256";
|
|
|
|
|
|
|
|
|
|
case GPGME_MD_SHA384:
|
|
|
|
|
return "SHA384";
|
|
|
|
|
|
|
|
|
|
case GPGME_MD_SHA512:
|
|
|
|
|
return "SHA512";
|
|
|
|
|
|
2014-05-08 12:03:14 +00:00
|
|
|
|
case GPGME_MD_SHA224:
|
|
|
|
|
return "SHA224";
|
|
|
|
|
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Creating a Signature): Add info about
GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result.
(Crypto Operations): Add GpgmeInvalidUserID.
(Algorithms): New chapter.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID,
GpgmeNewSignature, GpgmeSignResult): New data types.
(gpgme_op_sign_result, gpgme_pubkey_algo_name,
gpgme_hash_algo_name): New prototypes.
* gpgme.c (gpgme_pubkey_algo_name): New function.
(gpgme_hash_algo_name): Likewise.
* ops.h (_gpgme_parse_inv_userid, _gpgme_op_sign_init_result): New
prototype.
(_gpgme_op_sign_status_handler): Fix prototype.
* op-support.c: Include <errno.h> and <string.h>.
(_gpgme_parse_inv_userid): New function.
* sign.c: Include <errno.h> and "gpgme.h", but not <stdio.h>,
<assert.h> and "util.h".
(SKIP_TOKEN_OR_RETURN): Remove macro.
(struct sign_result): Change to op_data_t type and rework it.
(release_sign_result): Rename to ...
(release_op_data): ... this and rewrite it.
(append_xml_info): Remove function.
(gpgme_op_sign_result): New function.
(parse_sig_created): New function.
(_gpgme_sign_status_handler): Change first argument to void *.
Rewrite the function to use the new result structure and functions.
(_gpgme_op_sign_init_result): New function.
(_gpgme_op_sign_start): Rename to ...
(sign_start): ... this. Call _gpgme_op_sign_init_result.
(gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start.
(gpgme_op_sign): Likewise.
2003-04-27 20:53:04 +00:00
|
|
|
|
case GPGME_MD_MD4:
|
|
|
|
|
return "MD4";
|
|
|
|
|
|
|
|
|
|
case GPGME_MD_CRC32:
|
|
|
|
|
return "CRC32";
|
|
|
|
|
|
|
|
|
|
case GPGME_MD_CRC32_RFC1510:
|
2003-09-30 17:19:13 +00:00
|
|
|
|
return "CRC32RFC1510";
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Creating a Signature): Add info about
GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result.
(Crypto Operations): Add GpgmeInvalidUserID.
(Algorithms): New chapter.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID,
GpgmeNewSignature, GpgmeSignResult): New data types.
(gpgme_op_sign_result, gpgme_pubkey_algo_name,
gpgme_hash_algo_name): New prototypes.
* gpgme.c (gpgme_pubkey_algo_name): New function.
(gpgme_hash_algo_name): Likewise.
* ops.h (_gpgme_parse_inv_userid, _gpgme_op_sign_init_result): New
prototype.
(_gpgme_op_sign_status_handler): Fix prototype.
* op-support.c: Include <errno.h> and <string.h>.
(_gpgme_parse_inv_userid): New function.
* sign.c: Include <errno.h> and "gpgme.h", but not <stdio.h>,
<assert.h> and "util.h".
(SKIP_TOKEN_OR_RETURN): Remove macro.
(struct sign_result): Change to op_data_t type and rework it.
(release_sign_result): Rename to ...
(release_op_data): ... this and rewrite it.
(append_xml_info): Remove function.
(gpgme_op_sign_result): New function.
(parse_sig_created): New function.
(_gpgme_sign_status_handler): Change first argument to void *.
Rewrite the function to use the new result structure and functions.
(_gpgme_op_sign_init_result): New function.
(_gpgme_op_sign_start): Rename to ...
(sign_start): ... this. Call _gpgme_op_sign_init_result.
(gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start.
(gpgme_op_sign): Likewise.
2003-04-27 20:53:04 +00:00
|
|
|
|
|
|
|
|
|
case GPGME_MD_CRC24_RFC2440:
|
2003-09-30 17:19:13 +00:00
|
|
|
|
return "CRC24RFC2440";
|
doc/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.texi (Creating a Signature): Add info about
GpgmeNewSignature, GpgmeSignResult and gpgme_op_sign_result.
(Crypto Operations): Add GpgmeInvalidUserID.
(Algorithms): New chapter.
gpgme/
2003-04-27 Marcus Brinkmann <marcus@g10code.de>
* gpgme.h (GpgmePubKeyAlgo, GpgmeHashAlgo, GpgmeInvalidUserID,
GpgmeNewSignature, GpgmeSignResult): New data types.
(gpgme_op_sign_result, gpgme_pubkey_algo_name,
gpgme_hash_algo_name): New prototypes.
* gpgme.c (gpgme_pubkey_algo_name): New function.
(gpgme_hash_algo_name): Likewise.
* ops.h (_gpgme_parse_inv_userid, _gpgme_op_sign_init_result): New
prototype.
(_gpgme_op_sign_status_handler): Fix prototype.
* op-support.c: Include <errno.h> and <string.h>.
(_gpgme_parse_inv_userid): New function.
* sign.c: Include <errno.h> and "gpgme.h", but not <stdio.h>,
<assert.h> and "util.h".
(SKIP_TOKEN_OR_RETURN): Remove macro.
(struct sign_result): Change to op_data_t type and rework it.
(release_sign_result): Rename to ...
(release_op_data): ... this and rewrite it.
(append_xml_info): Remove function.
(gpgme_op_sign_result): New function.
(parse_sig_created): New function.
(_gpgme_sign_status_handler): Change first argument to void *.
Rewrite the function to use the new result structure and functions.
(_gpgme_op_sign_init_result): New function.
(_gpgme_op_sign_start): Rename to ...
(sign_start): ... this. Call _gpgme_op_sign_init_result.
(gpgme_op_sign_start): Use sign_start instead _gpgme_op_sign_start.
(gpgme_op_sign): Likewise.
2003-04-27 20:53:04 +00:00
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|