* 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)
------------------------------------------------
time. Using this flag requires that the @var{keydata} argument of the
export function is set to @code{NULL}.
+@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
+2010-02-16 Werner Koch <wk@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@g10code.com>
* w32-io.c (_gpgme_io_connect): Fix return code check to make it work.
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");
}
/* 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.
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>
{
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. */
{
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))
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);
}
+/* 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;
+}
+
+
+
\f
typedef gpg_error_t (*result_xml_write_cb_t) (void *hook, const void *buf,
size_t len);
}
+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)
{
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)
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;
{ "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) */
\f
/* The available export mode flags. */
#define GPGME_EXPORT_MODE_EXTERN 2
+#define GPGME_EXPORT_MODE_MINIMAL 4
typedef unsigned int gpgme_export_mode_t;