diff options
| author | Marcus Brinkmann <[email protected]> | 2009-06-16 14:43:38 +0000 | 
|---|---|---|
| committer | Marcus Brinkmann <[email protected]> | 2009-06-16 14:43:38 +0000 | 
| commit | 3320cc1742b541e9878dec1f6949f04811292cd3 (patch) | |
| tree | 273fc30aff84eac8b611f9a70ce72456143dcc15 | |
| parent | Add new functions to import and export keys specified by gpgme_key_t. (diff) | |
| download | gpgme-3320cc1742b541e9878dec1f6949f04811292cd3.tar.gz gpgme-3320cc1742b541e9878dec1f6949f04811292cd3.zip | |
doc/
2009-06-16  Marcus Brinkmann  <[email protected]>
	* gpgme.texi (Result Management): New section.
src/
2009-06-16  Marcus Brinkmann  <[email protected]>
	* gpgme.c (result_ref_lock): New global variable.
	(gpgme_result_ref, gpgme_result_unref): use it.
Diffstat (limited to '')
| -rw-r--r-- | NEWS | 12 | ||||
| -rw-r--r-- | doc/ChangeLog | 4 | ||||
| -rw-r--r-- | doc/gpgme.texi | 34 | ||||
| -rw-r--r-- | src/ChangeLog | 5 | ||||
| -rw-r--r-- | src/gpgme.c | 26 | 
5 files changed, 74 insertions, 7 deletions
| @@ -1,4 +1,4 @@ -Noteworthy changes in version 1.2.0 +Noteworthy changes in version 1.2.0 (unreleased)  ------------------------------------------------   * New encryption flag GPGME_ENCRYPT_NO_ENCRYPT_TO to disable default @@ -11,6 +11,16 @@ Noteworthy changes in version 1.2.0   * New functions gpgme_io_read and gpgme_io_write for use with     gpgme_passphrase_cb_t and gpgme_edit_cb_t functions. + * New functions gpgme_result_ref and gpgme_result_unref to detach +   result structures from a context. + + * New functions gpgme_op_export_keys_start and gpgme_op_export_keys +   that allow to specify exported keys through gpgme_key_t objects +   instead of patterns. + + * New mode of operation gpgme_export_mode_t that allows exporting +   external keys. +   * Interface changes relative to the 1.1.7 release:   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   GPGME_KEYLIST_MODE_EPHEMERAL   NEW. diff --git a/doc/ChangeLog b/doc/ChangeLog index 5138a57f..6bc623b4 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,7 @@ +2009-06-16  Marcus Brinkmann  <[email protected]> + +	* gpgme.texi (Result Management): New section. +  2009-06-16  Werner Koch  <[email protected]>  	* gpgme.texi (Exporting Keys): Document gpgme_op_export_keys. diff --git a/doc/gpgme.texi b/doc/gpgme.texi index a6f15d18..8ecb449d 100644 --- a/doc/gpgme.texi +++ b/doc/gpgme.texi @@ -173,6 +173,7 @@ Contexts  * Creating Contexts::             Creating new @acronym{GPGME} contexts.  * Destroying Contexts::           Releasing @acronym{GPGME} contexts. +* Result Management::             Managing the result of crypto operations.  * Context Attributes::            Setting properties of a context.  * Key Management::                Managing keys with @acronym{GPGME}.  * Trust Item Management::         Managing trust items with @acronym{GPGME}. @@ -1971,6 +1972,7 @@ cryptographic operations.  @menu  * Creating Contexts::             Creating new @acronym{GPGME} contexts.  * Destroying Contexts::           Releasing @acronym{GPGME} contexts. +* Result Management::             Managing the result of crypto operations.  * Context Attributes::            Setting properties of a context.  * Key Management::                Managing keys with @acronym{GPGME}.  * Trust Item Management::         Managing trust items with @acronym{GPGME}. @@ -2008,6 +2010,38 @@ The function @code{gpgme_release} destroys the context with the handle  @end deftypefun +@node Result Management +@section Result Management +@cindex context, result of operation + +The detailed result of an operation is returned in operation-specific +structures such as @code{gpgme_decrypt_result_t}.  The corresponding +retrieval functions such as @code{gpgme_op_decrypt_result} provide +static access to the results after an operation completes.  The +following interfaces make it possible to detach a result structure +from its associated context and give it a lifetime beyond that of the +current operation or context. + +@deftypefun void gpgme_result_ref (@w{void *@var{result}}) +The function @code{gpgme_result_ref} acquires an additional reference +for the result @var{result}, which may be of any type +@code{gpgme_*_result_t}.  As long as the user holds a reference, the +result structure is guaranteed to be valid and unmodified. +@end deftypefun + +@deftypefun void gpgme_result_unref (@w{void *@var{result}}) +The function @code{gpgme_result_unref} releases a reference for the +result @var{result}.  If this was the last reference, the result +structure will be destroyed and all resources associated to it will be +released. +@end deftypefun + +Note that a context may hold its own references to result structures, +typically until the context is destroyed or the next operation is +started.  In fact, these references are accessed through the +@code{gpgme_op_*_result} functions. + +  @node Context Attributes  @section Context Attributes  @cindex context, attributes diff --git a/src/ChangeLog b/src/ChangeLog index dc1e1164..68619136 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2009-06-16  Marcus Brinkmann  <[email protected]> + +	* gpgme.c (result_ref_lock): New global variable. +	(gpgme_result_ref, gpgme_result_unref): use it. +  2009-06-16  Werner Koch  <[email protected]>  	* gpgme.h.in (gpgme_op_export_keys_start, gpgme_op_export_keys): New. diff --git a/src/gpgme.c b/src/gpgme.c index 2372a06a..73788e7e 100644 --- a/src/gpgme.c +++ b/src/gpgme.c @@ -45,6 +45,10 @@ static char *def_lc_messages;  gpgme_error_t _gpgme_selftest = GPG_ERR_NOT_OPERATIONAL; +/* Protects all reference counters in result structures.  All other +   accesses to a key are read only.  */ +DEFINE_STATIC_LOCK (result_ref_lock); +  /* Create a new context as an environment for GPGME crypto     operations.  */ @@ -178,29 +182,39 @@ gpgme_release (gpgme_ctx_t ctx)  void  gpgme_result_ref (void *result)  { -  struct ctx_op_data *data = result - sizeof (struct ctx_op_data); +  struct ctx_op_data *data;    if (! result)      return; +  data = result - sizeof (struct ctx_op_data); + +  LOCK (result_ref_lock);    data->references++; +  UNLOCK (result_ref_lock);  }  void  gpgme_result_unref (void *result)  { -  struct ctx_op_data *data = result - sizeof (struct ctx_op_data); +  struct ctx_op_data *data;    if (! result)      return; -  if (--data->references == 0) +  data = result - sizeof (struct ctx_op_data); + +  LOCK (result_ref_lock); +  if (--data->references)      { -      if (data->cleanup) -	(*data->cleanup) (data->hook); -      free (data); +      UNLOCK (result_ref_lock); +      return;      } + +  if (data->cleanup) +    (*data->cleanup) (data->hook); +  free (data);  } | 
