* Copyright (C) 2001 Thomas Roessler <roessler@does-not-exist.org>
* Oliver Ehli <elmy@acm.org>
* Copyright (C) 2002, 2003, 2004 g10 Code GmbH
+ * Copyright (C) 2012 Michael R. Elkins <me@sigpipe.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#define CRYPT_KV_STRONGID 8
#define CRYPT_KV_MATCH (CRYPT_KV_ADDR|CRYPT_KV_STRING)
-/* static local variables */
-static int GpgmeLocaleSet = 0;
-
/*
* Type definitions.
*/
gpgme_error_t err;
gpgme_ctx_t ctx;
- if (!GpgmeLocaleSet)
- {
- gpgme_set_locale (NULL, LC_CTYPE, setlocale (LC_CTYPE, NULL));
-#ifdef ENABLE_NLS
- gpgme_set_locale (NULL, LC_MESSAGES, setlocale (LC_MESSAGES, NULL));
-#endif
-
- GpgmeLocaleSet = 1;
- }
-
err = gpgme_new (&ctx);
if (err)
{
* Implementation of `init'.
*/
+/* This function contains common code needed to be executed for both the pgp
+ * and smime support of gpgme. */
+static void init_common(void)
+{
+ /* this initialization should only run one time, but it may be called by
+ * either pgp_gpgme_init or smime_gpgme_init */
+ static bool has_run = 0;
+ if (!has_run) {
+ gpgme_check_version(NULL);
+ gpgme_set_locale (NULL, LC_CTYPE, setlocale (LC_CTYPE, NULL));
+#ifdef ENABLE_NLS
+ gpgme_set_locale (NULL, LC_MESSAGES, setlocale (LC_MESSAGES, NULL));
+#endif
+ has_run = true;
+ }
+}
+
/* Initialization. */
static void init_gpgme (void)
{
void pgp_gpgme_init (void)
{
+ init_common();
init_gpgme ();
}
void smime_gpgme_init (void)
{
+ init_common();
}
static int gpgme_send_menu (HEADER *msg, int *redraw, int is_smime)