[svn] gpgme - r1281 - in trunk: gpgme tests/gpgsm
svn author wk
cvs at cvs.gnupg.org
Mon Nov 26 11:59:12 CET 2007
Author: wk
Date: 2007-11-26 11:59:11 +0100 (Mon, 26 Nov 2007)
New Revision: 1281
Modified:
trunk/gpgme/ChangeLog
trunk/gpgme/engine-gpgsm.c
trunk/tests/gpgsm/t-verify.c
Log:
Made autolog feature for if --enable-fd-passing has not been enabled.
Pass HTML glag to test program.
Modified: trunk/gpgme/ChangeLog
===================================================================
--- trunk/gpgme/ChangeLog 2007-11-23 17:25:11 UTC (rev 1280)
+++ trunk/gpgme/ChangeLog 2007-11-26 10:59:11 UTC (rev 1281)
@@ -1,3 +1,11 @@
+2007-11-26 Werner Koch <wk at g10code.com>
+
+ * engine-gpgsm.c (struct engine_gpgsm): Add field INLINE_DATA and
+ always reset it before calling start.
+ (gpgsm_new): Clear it.
+ (status_handler): Implement it.
+ (gpgsm_getauditlog) [USE_DESCRIPTOR_PASSING]: Use INLINE_DATA.
+
2007-11-23 Werner Koch <wk at g10code.com>
* op-support.c (_gpgme_op_reset): Implement a no-reset flag.
Modified: trunk/gpgme/engine-gpgsm.c
===================================================================
--- trunk/gpgme/engine-gpgsm.c 2007-11-23 17:25:11 UTC (rev 1280)
+++ trunk/gpgme/engine-gpgsm.c 2007-11-26 10:59:11 UTC (rev 1281)
@@ -94,6 +94,8 @@
int any; /* any data line seen */
} colon;
+ gpgme_data_t inline_data; /* Used to collect D lines. */
+
struct gpgme_io_cbs io_cbs;
};
@@ -373,6 +375,8 @@
gpgsm->colon.attic.linelen = 0;
gpgsm->colon.any = 0;
+ gpgsm->inline_data = NULL;
+
gpgsm->io_cbs.add = NULL;
gpgsm->io_cbs.add_priv = NULL;
gpgsm->io_cbs.remove = NULL;
@@ -899,8 +903,7 @@
char **aline = &gpgsm->colon.attic.line;
int *alinelen = &gpgsm->colon.attic.linelen;
- if (gpgsm->colon.attic.linesize
- < *alinelen + linelen + 1)
+ if (gpgsm->colon.attic.linesize < *alinelen + linelen + 1)
{
char *newline = realloc (*aline, *alinelen + linelen + 1);
if (!newline)
@@ -958,6 +961,49 @@
fd, err? gpg_strerror (err):"ok");
}
else if (linelen > 2
+ && line[0] == 'D' && line[1] == ' '
+ && gpgsm->inline_data)
+ {
+ char *src = line + 2;
+ char *end = line + linelen;
+ char *dst = src;
+ ssize_t nwritten;
+
+ linelen = 0;
+ while (src < end)
+ {
+ if (*src == '%' && src + 2 < end)
+ {
+ /* Handle escaped characters. */
+ ++src;
+ *dst++ = _gpgme_hextobyte (src);
+ src += 2;
+ }
+ else
+ *dst++ = *src++;
+
+ linelen++;
+ }
+
+ src = line + 2;
+ while (linelen > 0)
+ {
+ nwritten = gpgme_data_write (gpgsm->inline_data, src, linelen);
+ if (!nwritten || (nwritten < 0 && errno != EINTR)
+ || nwritten > linelen)
+ {
+ err = gpg_error_from_errno (errno);
+ break;
+ }
+ src += nwritten;
+ linelen -= nwritten;
+ }
+
+ TRACE2 (DEBUG_CTX, "gpgme:status_handler", gpgsm,
+ "fd 0x%x: D inlinedata; final status: %s",
+ fd, err? gpg_strerror (err):"ok");
+ }
+ else if (linelen > 2
&& line[0] == 'S' && line[1] == ' ')
{
char *rest;
@@ -1094,6 +1140,7 @@
if (err)
return gpg_error (GPG_ERR_GENERAL); /* FIXME */
gpgsm_clear_fd (gpgsm, MESSAGE_FD);
+ gpgsm->inline_data = NULL;
err = start (engine, "DECRYPT");
return err;
@@ -1159,6 +1206,7 @@
gpgsm_clear_fd (gpgsm, OUTPUT_FD);
gpgsm_clear_fd (gpgsm, INPUT_FD);
gpgsm_clear_fd (gpgsm, MESSAGE_FD);
+ gpgsm->inline_data = NULL;
err = start (gpgsm, line);
free (line);
@@ -1248,6 +1296,7 @@
if (err)
return err;
gpgsm_clear_fd (gpgsm, MESSAGE_FD);
+ gpgsm->inline_data = NULL;
err = set_recipients (gpgsm, recp);
@@ -1284,6 +1333,7 @@
return err;
gpgsm_clear_fd (gpgsm, INPUT_FD);
gpgsm_clear_fd (gpgsm, MESSAGE_FD);
+ gpgsm->inline_data = NULL;
err = start (gpgsm, cmd);
free (cmd);
@@ -1375,6 +1425,7 @@
return err;
gpgsm_clear_fd (gpgsm, INPUT_FD);
gpgsm_clear_fd (gpgsm, MESSAGE_FD);
+ gpgsm->inline_data = NULL;
err = start (gpgsm, line);
free (line);
@@ -1401,6 +1452,7 @@
if (err)
return err;
gpgsm_clear_fd (gpgsm, MESSAGE_FD);
+ gpgsm->inline_data = NULL;
err = start (gpgsm, "GENKEY");
return err;
@@ -1422,6 +1474,7 @@
return err;
gpgsm_clear_fd (gpgsm, OUTPUT_FD);
gpgsm_clear_fd (gpgsm, MESSAGE_FD);
+ gpgsm->inline_data = NULL;
err = start (gpgsm, "IMPORT");
return err;
@@ -1483,6 +1536,7 @@
gpgsm_clear_fd (gpgsm, INPUT_FD);
gpgsm_clear_fd (gpgsm, OUTPUT_FD);
gpgsm_clear_fd (gpgsm, MESSAGE_FD);
+ gpgsm->inline_data = NULL;
err = start (gpgsm, line);
free (line);
@@ -1605,6 +1659,7 @@
gpgsm_clear_fd (gpgsm, INPUT_FD);
gpgsm_clear_fd (gpgsm, OUTPUT_FD);
gpgsm_clear_fd (gpgsm, MESSAGE_FD);
+ gpgsm->inline_data = NULL;
err = start (gpgsm, line);
free (line);
@@ -1670,6 +1725,7 @@
if (err)
return err;
gpgsm_clear_fd (gpgsm, MESSAGE_FD);
+ gpgsm->inline_data = NULL;
err = start (gpgsm, mode == GPGME_SIG_MODE_DETACH
? "SIGN --detached" : "SIGN");
@@ -1705,6 +1761,7 @@
err = gpgsm_set_fd (gpgsm, MESSAGE_FD, 0);
gpgsm_clear_fd (gpgsm, OUTPUT_FD);
}
+ gpgsm->inline_data = NULL;
if (!err)
err = start (gpgsm, "VERIFY");
@@ -1724,6 +1781,7 @@
if (!gpgsm || !output)
return gpg_error (GPG_ERR_INV_VALUE);
+#if USE_DESCRIPTOR_PASSING
gpgsm->output_cb.data = output;
err = gpgsm_set_fd (gpgsm, OUTPUT_FD, 0);
if (err)
@@ -1731,8 +1789,17 @@
gpgsm_clear_fd (gpgsm, INPUT_FD);
gpgsm_clear_fd (gpgsm, MESSAGE_FD);
+ gpgsm->inline_data = NULL;
+# define CMD "GETAUDITLOG"
+#else
+ gpgsm_clear_fd (gpgsm, OUTPUT_FD);
+ gpgsm_clear_fd (gpgsm, INPUT_FD);
+ gpgsm_clear_fd (gpgsm, MESSAGE_FD);
+ gpgsm->inline_data = output;
+# define CMD "GETAUDITLOG --data"
+#endif
- err = start (gpgsm, "GETAUDITLOG");
+ err = start (gpgsm, (flags & GPGME_AUDITLOG_HTML)? CMD " --html" : CMD);
return err;
}
Modified: trunk/tests/gpgsm/t-verify.c
===================================================================
--- trunk/tests/gpgsm/t-verify.c 2007-11-23 17:25:11 UTC (rev 1280)
+++ trunk/tests/gpgsm/t-verify.c 2007-11-26 10:59:11 UTC (rev 1281)
@@ -118,7 +118,7 @@
err = gpgme_data_new (&data);
fail_if_err (err);
- err = gpgme_op_getauditlog (ctx, data, 0);
+ err = gpgme_op_getauditlog (ctx, data, GPGME_AUDITLOG_HTML);
if (err)
{
fprintf (stderr, "%s:%i: Can't get audit log: %s\n",
More information about the Gnupg-commits
mailing list