Changeset View
Changeset View
Standalone View
Standalone View
src/gpgme.c
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | |||||
␌ | ␌ | ||||
/* The default locale. */ | /* The default locale. */ | ||||
DEFINE_STATIC_LOCK (def_lc_lock); | DEFINE_STATIC_LOCK (def_lc_lock); | ||||
static char *def_lc_ctype; | static char *def_lc_ctype; | ||||
static char *def_lc_messages; | static char *def_lc_messages; | ||||
␌ | ␌ | ||||
/* The global default trust model. */ | |||||
DEFINE_STATIC_LOCK (def_trust_model_lock); | |||||
static char *def_trust_model; | |||||
␌ | |||||
gpgme_error_t _gpgme_selftest = GPG_ERR_NOT_OPERATIONAL; | gpgme_error_t _gpgme_selftest = GPG_ERR_NOT_OPERATIONAL; | ||||
/* Protects all reference counters in result structures. All other | /* Protects all reference counters in result structures. All other | ||||
accesses to a result structure are read only. */ | accesses to a result structure are read only. */ | ||||
DEFINE_STATIC_LOCK (result_ref_lock); | DEFINE_STATIC_LOCK (result_ref_lock); | ||||
␌ | ␌ | ||||
/* Set the global flag NAME to VALUE. Return 0 on success. Note that | /* Set the global flag NAME to VALUE. Return 0 on success. Note that | ||||
Show All 17 Lines | gpgme_set_global_flag (const char *name, const char *value) | ||||
else if (!strcmp (name, "require-gnupg")) | else if (!strcmp (name, "require-gnupg")) | ||||
return _gpgme_set_engine_minimal_version (value); | return _gpgme_set_engine_minimal_version (value); | ||||
else if (!strcmp (name, "gpgconf-name")) | else if (!strcmp (name, "gpgconf-name")) | ||||
return _gpgme_set_default_gpgconf_name (value); | return _gpgme_set_default_gpgconf_name (value); | ||||
else if (!strcmp (name, "gpg-name")) | else if (!strcmp (name, "gpg-name")) | ||||
return _gpgme_set_default_gpg_name (value); | return _gpgme_set_default_gpg_name (value); | ||||
else if (!strcmp (name, "w32-inst-dir")) | else if (!strcmp (name, "w32-inst-dir")) | ||||
return _gpgme_set_override_inst_dir (value); | return _gpgme_set_override_inst_dir (value); | ||||
else if (!strcmp (name, "trust-model")) | |||||
{ | |||||
LOCK (def_trust_model_lock); | |||||
free (def_trust_model); | |||||
def_trust_model = strdup (value); | |||||
UNLOCK (def_trust_model_lock); | |||||
return !def_trust_model; | |||||
} | |||||
else | else | ||||
return -1; | return -1; | ||||
} | } | ||||
␌ | ␌ | ||||
/* Create a new context as an environment for GPGME crypto | /* Create a new context as an environment for GPGME crypto | ||||
operations. */ | operations. */ | ||||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | if (def_lc_messages) | ||||
free (ctx); | free (ctx); | ||||
return TRACE_ERR (saved_err); | return TRACE_ERR (saved_err); | ||||
} | } | ||||
} | } | ||||
else | else | ||||
def_lc_messages = NULL; | def_lc_messages = NULL; | ||||
UNLOCK (def_lc_lock); | UNLOCK (def_lc_lock); | ||||
LOCK (def_trust_model_lock); | |||||
if (def_trust_model && strlen (def_trust_model)) | |||||
{ | |||||
ctx->trust_model = strdup (def_trust_model); | |||||
} | |||||
UNLOCK (def_trust_model_lock); | |||||
*r_ctx = ctx; | *r_ctx = ctx; | ||||
return TRACE_SUC1 ("ctx=%p", ctx); | return TRACE_SUC1 ("ctx=%p", ctx); | ||||
} | } | ||||
gpgme_error_t | gpgme_error_t | ||||
_gpgme_cancel_with_err (gpgme_ctx_t ctx, gpg_error_t ctx_err, | _gpgme_cancel_with_err (gpgme_ctx_t ctx, gpg_error_t ctx_err, | ||||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | gpgme_release (gpgme_ctx_t ctx) | ||||
_gpgme_sig_notation_clear (ctx); | _gpgme_sig_notation_clear (ctx); | ||||
free (ctx->sender); | free (ctx->sender); | ||||
free (ctx->signers); | free (ctx->signers); | ||||
free (ctx->lc_ctype); | free (ctx->lc_ctype); | ||||
free (ctx->lc_messages); | free (ctx->lc_messages); | ||||
free (ctx->override_session_key); | free (ctx->override_session_key); | ||||
free (ctx->request_origin); | free (ctx->request_origin); | ||||
free (ctx->auto_key_locate); | free (ctx->auto_key_locate); | ||||
free (ctx->trust_model); | |||||
_gpgme_engine_info_release (ctx->engine_info); | _gpgme_engine_info_release (ctx->engine_info); | ||||
ctx->engine_info = NULL; | ctx->engine_info = NULL; | ||||
DESTROY_LOCK (ctx->lock); | DESTROY_LOCK (ctx->lock); | ||||
free (ctx); | free (ctx); | ||||
} | } | ||||
void | void | ||||
▲ Show 20 Lines • Show All 288 Lines • ▼ Show 20 Lines | else if (!strcmp (name, "ignore-mdc-error")) | ||||
} | } | ||||
else if (!strcmp (name, "auto-key-locate")) | else if (!strcmp (name, "auto-key-locate")) | ||||
{ | { | ||||
free (ctx->auto_key_locate); | free (ctx->auto_key_locate); | ||||
ctx->auto_key_locate = strdup (value); | ctx->auto_key_locate = strdup (value); | ||||
if (!ctx->auto_key_locate) | if (!ctx->auto_key_locate) | ||||
err = gpg_error_from_syserror (); | err = gpg_error_from_syserror (); | ||||
} | } | ||||
else if (!strcmp (name, "trust-model")) | |||||
{ | |||||
free (ctx->trust_model); | |||||
ctx->trust_model = strdup (value); | |||||
if (!ctx->trust_model) | |||||
err = gpg_error_from_syserror (); | |||||
} | |||||
else | else | ||||
err = gpg_error (GPG_ERR_UNKNOWN_NAME); | err = gpg_error (GPG_ERR_UNKNOWN_NAME); | ||||
return err; | return err; | ||||
} | } | ||||
/* Get the context flag named NAME. See gpgme_set_ctx_flag for a list | /* Get the context flag named NAME. See gpgme_set_ctx_flag for a list | ||||
▲ Show 20 Lines • Show All 721 Lines • Show Last 20 Lines |