core: Change a parameter for the engine's genkey function.
authorWerner Koch <wk@gnupg.org>
Wed, 14 Sep 2016 10:15:35 +0000 (12:15 +0200)
committerWerner Koch <wk@gnupg.org>
Wed, 14 Sep 2016 10:42:12 +0000 (12:42 +0200)
* src/engine.h (GENKEY_EXTRAFLAG_ARMOR): New.
* src/engine-backend.h (engine_ops): Rename USE_ARMOR in genkey to
EXTRAFLAGS.
* src/engine.c (_gpgme_engine_op_genkey): Ditto.
* src/engine-gpg.c (gpg_createkey_from_param): Ditto and test the
flags.
(gpg_createkey_legacy): Ditto.
(gpg_createkey): Ditto.
(gpg_addkey): Ditto.
(gpg_genkey): Ditto.

Signed-off-by: Werner Koch <wk@gnupg.org>
src/engine-backend.h
src/engine-gpg.c
src/engine-gpgsm.c
src/engine.c
src/engine.h
src/genkey.c

index 842292d..ec1a58c 100644 (file)
@@ -86,7 +86,8 @@ struct engine_ops
                            const char *userid, const char *algo,
                            unsigned long reserved, unsigned long expires,
                            gpgme_key_t key, unsigned int flags,
-                           gpgme_data_t help_data, int use_armor,
+                           gpgme_data_t help_data,
+                           unsigned int extraflags,
                           gpgme_data_t pubkey, gpgme_data_t seckey);
   gpgme_error_t (*import) (void *engine, gpgme_data_t keydata,
                            gpgme_key_t *keyarray);
index d2b6dd3..db6637a 100644 (file)
@@ -2012,12 +2012,12 @@ gpg_add_algo_usage_expire (engine_gpg_t gpg,
 
 static gpgme_error_t
 gpg_createkey_from_param (engine_gpg_t gpg,
-                          gpgme_data_t help_data, int use_armor)
+                          gpgme_data_t help_data, unsigned int extraflags)
 {
   gpgme_error_t err;
 
   err = add_arg (gpg, "--gen-key");
-  if (!err && use_armor)
+  if (!err && (extraflags & GENKEY_EXTRAFLAG_ARMOR))
     err = add_arg (gpg, "--armor");
   if (!err)
     err = add_arg (gpg, "--");
@@ -2036,7 +2036,7 @@ gpg_createkey_legacy (engine_gpg_t gpg,
                const char *userid, const char *algo,
                unsigned long expires,
                unsigned int flags,
-               int use_armor)
+               unsigned int extraflags)
 {
   return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
 }
@@ -2047,12 +2047,12 @@ gpg_createkey (engine_gpg_t gpg,
                const char *userid, const char *algo,
                unsigned long expires,
                unsigned int flags,
-               int use_armor)
+               unsigned int extraflags)
 {
   gpgme_error_t err;
 
   err = add_arg (gpg, "--quick-gen-key");
-  if (!err && use_armor)
+  if (!err && (extraflags & GENKEY_EXTRAFLAG_ARMOR))
     err = add_arg (gpg, "--armor");
   if (!err && (flags & GPGME_CREATE_NOPASSWD))
     {
@@ -2082,7 +2082,7 @@ gpg_addkey (engine_gpg_t gpg,
             unsigned long expires,
             gpgme_key_t key,
             unsigned int flags,
-            int use_armor)
+            unsigned int extraflags)
 {
   gpgme_error_t err;
 
@@ -2090,7 +2090,7 @@ gpg_addkey (engine_gpg_t gpg,
     return gpg_error (GPG_ERR_INV_ARG);
 
   err = add_arg (gpg, "--quick-addkey");
-  if (!err && use_armor)
+  if (!err && (extraflags & GENKEY_EXTRAFLAG_ARMOR))
     err = add_arg (gpg, "--armor");
   if (!err && (flags & GPGME_CREATE_NOPASSWD))
     {
@@ -2141,7 +2141,7 @@ gpg_genkey (void *engine,
             const char *userid, const char *algo,
             unsigned long reserved, unsigned long expires,
             gpgme_key_t key, unsigned int flags,
-            gpgme_data_t help_data, int use_armor,
+            gpgme_data_t help_data, unsigned int extraflags,
            gpgme_data_t pubkey, gpgme_data_t seckey)
 {
   engine_gpg_t gpg = engine;
@@ -2169,20 +2169,20 @@ gpg_genkey (void *engine,
       if (pubkey || seckey)
         err = gpg_error (GPG_ERR_NOT_IMPLEMENTED);
       else
-        err = gpg_createkey_from_param (gpg, help_data, use_armor);
+        err = gpg_createkey_from_param (gpg, help_data, extraflags);
     }
   else if (userid && !key)
     {
       if (!have_gpg_version (gpg, "2.1.13"))
         err = gpg_createkey_legacy (gpg, userid, algo, expires, flags,
-                                    use_armor);
+                                    extraflags);
       else
-        err = gpg_createkey (gpg, userid, algo, expires, flags, use_armor);
+        err = gpg_createkey (gpg, userid, algo, expires, flags, extraflags);
     }
   else if (!have_gpg_version (gpg, "2.1.13"))
     err = gpg_error (GPG_ERR_NOT_SUPPORTED);
   else if (!userid && key)
-    err = gpg_addkey (gpg, algo, expires, key, flags, use_armor);
+    err = gpg_addkey (gpg, algo, expires, key, flags, extraflags);
   else if (userid && key && !algo)
     err = gpg_adduid (gpg, key, userid);
   else
index 0610c7a..071626a 100644 (file)
@@ -1447,7 +1447,7 @@ gpgsm_genkey (void *engine,
               const char *userid, const char *algo,
               unsigned long reserved, unsigned long expires,
               gpgme_key_t key, unsigned int flags,
-              gpgme_data_t help_data, int use_armor,
+              gpgme_data_t help_data, unsigned int extraflags,
              gpgme_data_t pubkey, gpgme_data_t seckey)
 {
   engine_gpgsm_t gpgsm = engine;
@@ -1468,7 +1468,8 @@ gpgsm_genkey (void *engine,
       if (err)
         return err;
       gpgsm->output_cb.data = pubkey;
-      err = gpgsm_set_fd (gpgsm, OUTPUT_FD, use_armor ? "--armor"
+      err = gpgsm_set_fd (gpgsm, OUTPUT_FD,
+                          (extraflags & GENKEY_EXTRAFLAG_ARMOR)? "--armor"
                           : map_data_enc (gpgsm->output_cb.data));
       if (err)
         return err;
index 1ff8698..b3bbcab 100644 (file)
@@ -778,8 +778,8 @@ _gpgme_engine_op_genkey (engine_t engine,
                          unsigned long reserved, unsigned long expires,
                          gpgme_key_t key, unsigned int flags,
                          gpgme_data_t help_data,
-                        int use_armor, gpgme_data_t pubkey,
-                        gpgme_data_t seckey)
+                        unsigned int extraflags,
+                         gpgme_data_t pubkey, gpgme_data_t seckey)
 {
   if (!engine)
     return gpg_error (GPG_ERR_INV_VALUE);
@@ -789,7 +789,7 @@ _gpgme_engine_op_genkey (engine_t engine,
 
   return (*engine->ops->genkey) (engine->engine,
                                  userid, algo, reserved, expires, key, flags,
-                                 help_data, use_armor,
+                                 help_data, extraflags,
                                 pubkey, seckey);
 }
 
index 857dff4..391caf2 100644 (file)
 
 #include "gpgme.h"
 
+/* Flags used by the EXTRAFLAGS arg of _gpgme_engine_op_genkey.  */
+#define GENKEY_EXTRAFLAG_ARMOR 1
+
+
 struct engine;
 typedef struct engine *engine_t;
 
@@ -113,7 +117,8 @@ gpgme_error_t _gpgme_engine_op_genkey (engine_t engine,
                                        unsigned long expires,
                                        gpgme_key_t key, unsigned int flags,
                                       gpgme_data_t help_data,
-                                      int use_armor, gpgme_data_t pubkey,
+                                      unsigned int extraflags,
+                                       gpgme_data_t pubkey,
                                       gpgme_data_t seckey);
 gpgme_error_t _gpgme_engine_op_import (engine_t engine,
                                       gpgme_data_t keydata,
index b93abb8..100e655 100644 (file)
@@ -267,7 +267,8 @@ genkey_start (gpgme_ctx_t ctx, int synchronous, const char *parms,
   return _gpgme_engine_op_genkey (ctx->engine,
                                   NULL, NULL, 0, 0, NULL, 0,
                                   opd->key_parameter,
-                                 ctx->use_armor, pubkey, seckey);
+                                 ctx->use_armor? GENKEY_EXTRAFLAG_ARMOR:0,
+                                  pubkey, seckey);
 }
 
 
@@ -352,7 +353,9 @@ createkey_start (gpgme_ctx_t ctx, int synchronous,
   return _gpgme_engine_op_genkey (ctx->engine,
                                   userid, algo, reserved, expires,
                                   anchorkey, flags,
-                                  NULL, ctx->use_armor, NULL, NULL);
+                                  NULL,
+                                 ctx->use_armor? GENKEY_EXTRAFLAG_ARMOR:0,
+                                  NULL, NULL);
 
 }
 
@@ -438,7 +441,9 @@ createsubkey_start (gpgme_ctx_t ctx, int synchronous,
   return _gpgme_engine_op_genkey (ctx->engine,
                                   NULL, algo, reserved, expires,
                                   key, flags,
-                                  NULL, ctx->use_armor, NULL, NULL);
+                                  NULL,
+                                 ctx->use_armor? GENKEY_EXTRAFLAG_ARMOR:0,
+                                  NULL, NULL);
 
 }
 
@@ -522,7 +527,9 @@ adduid_start (gpgme_ctx_t ctx, int synchronous,
   return _gpgme_engine_op_genkey (ctx->engine,
                                   userid, NULL, 0, 0,
                                   key, flags,
-                                  NULL, ctx->use_armor, NULL, NULL);
+                                  NULL,
+                                 ctx->use_armor? GENKEY_EXTRAFLAG_ARMOR:0,
+                                  NULL, NULL);
 
 }