[svn] gpgme - r1453 - in trunk: . doc src

svn author wk cvs at cvs.gnupg.org
Tue Feb 16 21:07:03 CET 2010


Author: wk
Date: 2010-02-16 21:07:03 +0100 (Tue, 16 Feb 2010)
New Revision: 1453

Modified:
   trunk/NEWS
   trunk/doc/gpgme.texi
   trunk/src/ChangeLog
   trunk/src/engine-gpg.c
   trunk/src/export.c
   trunk/src/gpgme-tool.c
   trunk/src/gpgme.h.in
Log:
Add option GPGME_EXPORT_MODE_MINIMAL


Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog	2010-02-16 19:37:51 UTC (rev 1452)
+++ trunk/src/ChangeLog	2010-02-16 20:07:03 UTC (rev 1453)
@@ -1,3 +1,12 @@
+2010-02-16  Werner Koch  <wk at g10code.com>
+
+	* gpgme-tool.c (spacep, has_option, skip_options): New.
+	(cmd_export): Implement option --minimal.
+
+	* gpgme.h.in (GPGME_EXPORT_MODE_MINIMAL): New.
+	* export.c (export_start, export_ext_start): Implement it.
+	* engine-gpg.c (export_common): Ditto.
+
 2010-01-25  Werner Koch  <wk at g10code.com>
 
 	* w32-io.c (_gpgme_io_connect): Fix return code check to make it work.

Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2010-02-16 19:37:51 UTC (rev 1452)
+++ trunk/NEWS	2010-02-16 20:07:03 UTC (rev 1453)
@@ -3,7 +3,12 @@
 
  * Under development.
 
+ * Interface changes relative to the 1.3.0 release:
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ GPGME_EXPORT_MODE_MINIMAL  NEW.
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+
 Noteworthy changes in version 1.3.0 (2010-01-11)
 ------------------------------------------------
 

Modified: trunk/doc/gpgme.texi
===================================================================
--- trunk/doc/gpgme.texi	2010-02-16 19:37:51 UTC (rev 1452)
+++ trunk/doc/gpgme.texi	2010-02-16 20:07:03 UTC (rev 1453)
@@ -3402,6 +3402,12 @@
 time.  Using this flag requires that the @var{keydata} argument of the
 export function is set to @code{NULL}.
 
+ at item GPGME_EXPORT_MODE_MINIMAL
+If this bit is set, the smallest possible key is exported.  For OpenPGP
+keys it removes all signatures except for the latest self-signatures.
+For X.509 keys it has no effect.
+
+
 @end table
 
 

Modified: trunk/src/engine-gpg.c
===================================================================
--- trunk/src/engine-gpg.c	2010-02-16 19:37:51 UTC (rev 1452)
+++ trunk/src/engine-gpg.c	2010-02-16 20:07:03 UTC (rev 1453)
@@ -1727,12 +1727,18 @@
 export_common (engine_gpg_t gpg, gpgme_export_mode_t mode,
                gpgme_data_t keydata, int use_armor)
 {
-  gpgme_error_t err;
+  gpgme_error_t err = 0;
 
-  if ((mode & ~GPGME_EXPORT_MODE_EXTERN))
+  if ((mode & ~(GPGME_EXPORT_MODE_EXTERN
+                |GPGME_EXPORT_MODE_MINIMAL)))
     return gpg_error (GPG_ERR_NOT_SUPPORTED);
 
-  if ((mode & GPGME_EXPORT_MODE_EXTERN))
+  if ((mode & GPGME_EXPORT_MODE_MINIMAL))
+    err = add_arg (gpg, "--export-options=export-minimal");
+
+  if (err)
+    ;
+  else if ((mode & GPGME_EXPORT_MODE_EXTERN))
     {
       err = add_arg (gpg, "--send-keys");
     }

Modified: trunk/src/export.c
===================================================================
--- trunk/src/export.c	2010-02-16 19:37:51 UTC (rev 1452)
+++ trunk/src/export.c	2010-02-16 20:07:03 UTC (rev 1453)
@@ -1,6 +1,6 @@
 /* export.c - Export a key.
    Copyright (C) 2000 Werner Koch (dd9jn)
-   Copyright (C) 2001, 2002, 2003, 2004 g10 Code GmbH
+   Copyright (C) 2001, 2002, 2003, 2004, 2010 g10 Code GmbH
 
    This file is part of GPGME.
  
@@ -15,9 +15,8 @@
    Lesser General Public License for more details.
    
    You should have received a copy of the GNU Lesser General Public
-   License along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-   02111-1307, USA.  */
+   License along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
 
 #if HAVE_CONFIG_H
 #include <config.h>
@@ -44,7 +43,8 @@
 {
   gpgme_error_t err;
 
-  if ((mode & ~(GPGME_EXPORT_MODE_EXTERN)))
+  if ((mode & ~(GPGME_EXPORT_MODE_EXTERN
+                |GPGME_EXPORT_MODE_MINIMAL)))
     return gpg_error (GPG_ERR_INV_VALUE); /* Invalid flags in MODE.  */
 
   
@@ -107,7 +107,8 @@
 {
   gpgme_error_t err;
 
-  if ((mode & ~(GPGME_EXPORT_MODE_EXTERN)))
+  if ((mode & ~(GPGME_EXPORT_MODE_EXTERN
+                |GPGME_EXPORT_MODE_MINIMAL)))
     return gpg_error (GPG_ERR_INV_VALUE); /* Invalid flags in MODE.  */
 
   if ((mode & GPGME_EXPORT_MODE_EXTERN))

Modified: trunk/src/gpgme-tool.c
===================================================================
--- trunk/src/gpgme-tool.c	2010-02-16 19:37:51 UTC (rev 1452)
+++ trunk/src/gpgme-tool.c	2010-02-16 20:07:03 UTC (rev 1453)
@@ -468,6 +468,9 @@
 FILE *log_stream;
 char *program_name = "gpgme-tool";
 
+#define spacep(p)   (*(p) == ' ' || *(p) == '\t')
+
+
 void log_error (int status, gpg_error_t errnum, 
                 const char *fmt, ...) GT_GCC_A_PRINTF(3,4);
 
@@ -497,6 +500,35 @@
 }
 
 
+/* Check whether the option NAME appears in LINE.  */
+static int
+has_option (const char *line, const char *name)
+{
+  const char *s;
+  int n = strlen (name);
+
+  s = strstr (line, name);
+  return (s && (s == line || spacep (s-1)) && (!s[n] || spacep (s+n)));
+}
+
+/* Skip over options.  It is assumed that leading spaces have been
+   removed (this is the case for lines passed to a handler from
+   assuan).  Blanks after the options are also removed.  */
+static char *
+skip_options (char *line)
+{
+  while ( *line == '-' && line[1] == '-' )
+    {
+      while (*line && !spacep (line))
+        line++;
+      while (spacep (line))
+        line++;
+    }
+  return line;
+}
+
+
+
 
 typedef gpg_error_t (*result_xml_write_cb_t) (void *hook, const void *buf,
 					      size_t len);
@@ -2334,6 +2366,11 @@
 }
 
 
+static const char hlp_export[] = 
+  "EXPORT [--extern] [--minimal] [<pattern>]\n"
+  "\n"
+  "Export the keys described by PATTERN.  Write the\n"
+  "the output to the object set by the last OUTPUT command.";
 static gpg_error_t
 cmd_export (assuan_context_t ctx, char *line)
 {
@@ -2343,7 +2380,6 @@
   gpgme_data_t out_data;
   gpgme_export_mode_t mode = 0;
   const char *pattern[2];
-  const char optstr[] = "--extern ";
 
   out_fd = assuan_get_output_fd (ctx);
   if (out_fd == ASSUAN_INVALID_FD)
@@ -2352,11 +2388,13 @@
   if (err)
     return err;
 
-  if (strncasecmp (line, optstr, strlen (optstr)))
-    {
-      mode |= GPGME_EXPORT_MODE_EXTERN;
-      line += strlen (optstr);
-    }
+  if (has_option (line, "--extern"))
+    mode |= GPGME_EXPORT_MODE_EXTERN;
+  if (has_option (line, "--minimal"))
+    mode |= GPGME_EXPORT_MODE_MINIMAL;
+
+  line = skip_options (line);
+
   pattern[0] = line;
   pattern[1] = NULL;
 
@@ -2695,7 +2733,7 @@
     { "SIGN", cmd_sign },
     { "VERIFY", cmd_verify },
     { "IMPORT", cmd_import },
-    { "EXPORT", cmd_export },
+    { "EXPORT", cmd_export, hlp_export },
     { "GENKEY", cmd_genkey },
     { "DELETE", cmd_delete },
     /* TODO: EDIT, CARD_EDIT (with INQUIRE) */

Modified: trunk/src/gpgme.h.in
===================================================================
--- trunk/src/gpgme.h.in	2010-02-16 19:37:51 UTC (rev 1452)
+++ trunk/src/gpgme.h.in	2010-02-16 20:07:03 UTC (rev 1453)
@@ -348,6 +348,7 @@
 
 /* The available export mode flags.  */
 #define GPGME_EXPORT_MODE_EXTERN                2
+#define GPGME_EXPORT_MODE_MINIMAL               4
 
 typedef unsigned int gpgme_export_mode_t;
 




More information about the Gnupg-commits mailing list