[Pkg-gnupg-commit] [gnupg2] 53/185: gpg: Refactor keyedit module.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Mon Aug 7 11:55:19 UTC 2017


This is an automated email from the git hooks/post-receive script.

dkg pushed a commit to branch experimental
in repository gnupg2.

commit 8095d16b3ef6b5f01ec351824855708149f1c1c3
Author: Justus Winter <justus at g10code.com>
Date:   Tue Jun 13 15:27:43 2017 +0200

    gpg: Refactor keyedit module.
    
    * g10/Makefile.am (gpg_SOURCES): Add new file.
    * g10/keyedit.c (NODFLG_*): Move flags to the new header file.
    (print_one_sig): Export symbol and rename accordingly.
    (print_and_check_one_sig): Adapt accordingly.
    (check_all_keysigs): Likewise.
    * g10/keyedit.h: New file.
    * g10/main.h: Drop declarations, include new header.
    
    GnuPG-bug-id: 2236
    Signed-off-by: Justus Winter <justus at g10code.com>
---
 g10/Makefile.am |  2 +-
 g10/keyedit.c   | 30 ++++++++++-------------------
 g10/keyedit.h   | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 g10/main.h      | 19 +------------------
 4 files changed, 70 insertions(+), 39 deletions(-)

diff --git a/g10/Makefile.am b/g10/Makefile.am
index 330d6c5..9994ea1 100644
--- a/g10/Makefile.am
+++ b/g10/Makefile.am
@@ -153,7 +153,7 @@ gpg_sources = server.c          \
 	      exec.c exec.h
 
 gpg_SOURCES  = gpg.c \
-	keyedit.c 	\
+	keyedit.c keyedit.h	\
 	$(gpg_sources)
 
 gpgcompose_SOURCES  = gpgcompose.c  $(gpg_sources)
diff --git a/g10/keyedit.c b/g10/keyedit.c
index 9f6add1..30cf012 100644
--- a/g10/keyedit.c
+++ b/g10/keyedit.c
@@ -48,6 +48,7 @@
 #include "call-agent.h"
 #include "../common/host2net.h"
 #include "tofu.h"
+#include "keyedit.h"
 
 static void show_prefs (PKT_user_id * uid, PKT_signature * selfsig,
 			int verbose);
@@ -105,17 +106,6 @@ static int update_trust = 0;
 
 #define CONTROL_D ('D' - 'A' + 1)
 
-#define NODFLG_BADSIG (1<<0)	/* Bad signature.  */
-#define NODFLG_NOKEY  (1<<1)	/* No public key.  */
-#define NODFLG_SIGERR (1<<2)	/* Other sig error.  */
-
-#define NODFLG_MARK_A (1<<4)	/* Temporary mark.  */
-#define NODFLG_DELSIG (1<<5)	/* To be deleted.  */
-
-#define NODFLG_SELUID (1<<8)	/* Indicate the selected userid. */
-#define NODFLG_SELKEY (1<<9)	/* Indicate the selected key.  */
-#define NODFLG_SELSIG (1<<10)	/* Indicate a selected signature.  */
-
 struct sign_attrib
 {
   int non_exportable, non_revocable;
@@ -201,10 +191,10 @@ print_and_check_one_sig_colon (ctrl_t ctrl, kbnode_t keyblock, kbnode_t node,
  * packet.  With EXTENDED set all possible signature list options will
  * always be printed.
  */
-static int
-print_one_sig (ctrl_t ctrl, int rc, kbnode_t keyblock, kbnode_t node,
-               int *inv_sigs, int *no_key, int *oth_err,
-               int is_selfsig, int print_without_key, int extended)
+int
+keyedit_print_one_sig (ctrl_t ctrl, int rc, kbnode_t keyblock, kbnode_t node,
+		       int *inv_sigs, int *no_key, int *oth_err,
+		       int is_selfsig, int print_without_key, int extended)
 {
   PKT_signature *sig = node->pkt->pkt.signature;
   int sigrc;
@@ -326,9 +316,9 @@ print_and_check_one_sig (ctrl_t ctrl, kbnode_t keyblock, kbnode_t node,
   int rc;
 
   rc = check_key_signature (ctrl, keyblock, node, is_selfsig);
-  return print_one_sig (ctrl, rc,
-                        keyblock, node, inv_sigs, no_key, oth_err,
-                        *is_selfsig, print_without_key, extended);
+  return keyedit_print_one_sig (ctrl, rc,
+				keyblock, node, inv_sigs, no_key, oth_err,
+				*is_selfsig, print_without_key, extended);
 }
 
 
@@ -808,8 +798,8 @@ check_all_keysigs (ctrl_t ctrl, kbnode_t kb,
               }
 
             if (modified)
-              print_one_sig (ctrl, rc, kb, n, NULL, NULL, NULL, has_selfsig,
-                             0, only_selfsigs);
+              keyedit_print_one_sig (ctrl, rc, kb, n, NULL, NULL, NULL,
+				     has_selfsig, 0, only_selfsigs);
           }
 
           if (dump_sig_params)
diff --git a/g10/keyedit.h b/g10/keyedit.h
new file mode 100644
index 0000000..d4c9632
--- /dev/null
+++ b/g10/keyedit.h
@@ -0,0 +1,58 @@
+/* keyedit.h - Edit properties of a key
+ * Copyright (C) 1998-2010 Free Software Foundation, Inc.
+ * Copyright (C) 1998-2017 Werner Koch
+ * Copyright (C) 2015-2017 g10 Code GmbH
+ *
+ * This file is part of GnuPG.
+ *
+ * GnuPG is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GnuPG is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <https://www.gnu.org/licenses/>.
+ */
+
+#ifndef GNUPG_G10_KEYEDIT_H
+#define GNUPG_G10_KEYEDIT_H
+
+#define NODFLG_BADSIG (1<<0)	/* Bad signature.  */
+#define NODFLG_NOKEY  (1<<1)	/* No public key.  */
+#define NODFLG_SIGERR (1<<2)	/* Other sig error.  */
+
+#define NODFLG_MARK_A (1<<4)	/* Temporary mark.  */
+#define NODFLG_DELSIG (1<<5)	/* To be deleted.  */
+
+#define NODFLG_SELUID (1<<8)	/* Indicate the selected userid. */
+#define NODFLG_SELKEY (1<<9)	/* Indicate the selected key.  */
+#define NODFLG_SELSIG (1<<10)	/* Indicate a selected signature.  */
+
+/*-- keyedit.c --*/
+void keyedit_menu (ctrl_t ctrl, const char *username, strlist_t locusr,
+		   strlist_t commands, int quiet, int seckey_check );
+void keyedit_passwd (ctrl_t ctrl, const char *username);
+void keyedit_quick_adduid (ctrl_t ctrl, const char *username,
+                           const char *newuid);
+void keyedit_quick_addkey (ctrl_t ctrl, const char *fpr, const char *algostr,
+                           const char *usagestr, const char *expirestr);
+void keyedit_quick_revuid (ctrl_t ctrl, const char *username,
+                           const char *uidtorev);
+void keyedit_quick_sign (ctrl_t ctrl, const char *fpr,
+                         strlist_t uids, strlist_t locusr, int local);
+void keyedit_quick_set_expire (ctrl_t ctrl,
+                               const char *fpr, const char *expirestr);
+void keyedit_quick_set_primary (ctrl_t ctrl, const char *username,
+                                const char *primaryuid);
+void show_basic_key_info (ctrl_t ctrl, kbnode_t keyblock);
+int keyedit_print_one_sig (ctrl_t ctrl, int rc, kbnode_t keyblock,
+			   kbnode_t node, int *inv_sigs, int *no_key,
+			   int *oth_err, int is_selfsig,
+			   int print_without_key, int extended);
+
+#endif	/* GNUPG_G10_KEYEDIT_H */
diff --git a/g10/main.h b/g10/main.h
index 33116d2..dad0fe3 100644
--- a/g10/main.h
+++ b/g10/main.h
@@ -23,6 +23,7 @@
 #include "../common/types.h"
 #include "../common/iobuf.h"
 #include "keydb.h"
+#include "keyedit.h"
 #include "../common/util.h"
 
 /* It could be argued that the default cipher should be 3DES rather
@@ -285,24 +286,6 @@ gpg_error_t check_signature_over_key_or_uid (ctrl_t ctrl,
 gpg_error_t delete_keys (ctrl_t ctrl,
                          strlist_t names, int secret, int allow_both);
 
-/*-- keyedit.c --*/
-void keyedit_menu (ctrl_t ctrl, const char *username, strlist_t locusr,
-		   strlist_t commands, int quiet, int seckey_check );
-void keyedit_passwd (ctrl_t ctrl, const char *username);
-void keyedit_quick_adduid (ctrl_t ctrl, const char *username,
-                           const char *newuid);
-void keyedit_quick_addkey (ctrl_t ctrl, const char *fpr, const char *algostr,
-                           const char *usagestr, const char *expirestr);
-void keyedit_quick_revuid (ctrl_t ctrl, const char *username,
-                           const char *uidtorev);
-void keyedit_quick_sign (ctrl_t ctrl, const char *fpr,
-                         strlist_t uids, strlist_t locusr, int local);
-void keyedit_quick_set_expire (ctrl_t ctrl,
-                               const char *fpr, const char *expirestr);
-void keyedit_quick_set_primary (ctrl_t ctrl, const char *username,
-                                const char *primaryuid);
-void show_basic_key_info (ctrl_t ctrl, kbnode_t keyblock);
-
 /*-- keygen.c --*/
 const char *get_default_pubkey_algo (void);
 u32 parse_expire_string(const char *string);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gnupg2.git



More information about the Pkg-gnupg-commit mailing list