gpgme -- What is the purpose of cb_value in gpgme_set_passphrase_cb?
wk at gnupg.org
Thu May 24 21:47:01 CEST 2001
On Thu, 24 May 2001, andres at corrada.com wrote:
> I see, however, that in t_decrypt.c cb_value is set to a struct
> passphrase_cb_info_s pointer when calling gpgme_set_passphrase_cb.
This is the usual way to pass context to a callback function.
Along with the (address of the) callback function an arbitrary
pointer is stored in the internal GPGME context. When the callback
function is then called by GPME, that cb_value is passed to it, so
that the callback function has a way to get hands on its own state.
You can't use a global variable for this for 2 reasons:
* It cannot be thread save
* There is no guarantee that GPGME will call the callback function
in any given order.
> Why the difference? And what is the purpose of cb_value?
It depends on on the application.
Well, the whole GPGME thing is in Alpha state so be prepared to get
bitten by some bugs.
Werner Koch Omnis enim res, quae dando non deficit, dum habetur
g10 Code GmbH et non datur, nondum habetur, quomodo habenda est.
Privacy Solutions -- Augustinus
More information about the Gnupg-devel