aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--gpgme/ChangeLog11
-rw-r--r--gpgme/context.h2
-rw-r--r--gpgme/encrypt.c103
-rw-r--r--gpgme/gpgme.c3
-rw-r--r--gpgme/ops.h3
-rw-r--r--gpgme/posix-util.c4
-rw-r--r--gpgme/recipient.c9
-rw-r--r--gpgme/rungpg.h3
-rw-r--r--gpgme/types.h4
-rw-r--r--jnlib/ChangeLog4
-rw-r--r--jnlib/logging.c4
-rw-r--r--tests/t-encrypt.c15
12 files changed, 157 insertions, 8 deletions
diff --git a/gpgme/ChangeLog b/gpgme/ChangeLog
index fedd4b1f..5437ad5e 100644
--- a/gpgme/ChangeLog
+++ b/gpgme/ChangeLog
@@ -1,5 +1,16 @@
+2001-09-03 Werner Koch <[email protected]>
+
+ * rungpg.h: Added STATUS_INV_RECP.
+ * gpgme.c (_gpgme_release_result): Add support for new
+ EncryptResult object.
+ * encrypt.c (append_xml_encinfo): New.
+ (encrypt_status_handler): Add some status parsing.
+ (_gpgme_release_encrypt_result): New.
+
2001-08-29 Werner Koch <[email protected]>
+ * recipient.c (gpgme_recipients_release): Free the list. By Timo.
+
* keylist.c (keylist_colon_handler): Do a finish key if we receive
an EOF here. This is probably the reason for a lot of bugs
related to keylisting. It is so obvious. Kudos to Enno Cramer
diff --git a/gpgme/context.h b/gpgme/context.h
index 662889f9..ad5886ca 100644
--- a/gpgme/context.h
+++ b/gpgme/context.h
@@ -31,6 +31,7 @@ typedef enum {
RESULT_TYPE_VERIFY,
RESULT_TYPE_DECRYPT,
RESULT_TYPE_SIGN,
+ RESULT_TYPE_ENCRYPT
} ResultType;
@@ -72,6 +73,7 @@ struct gpgme_context_s {
VerifyResult verify;
DecryptResult decrypt;
SignResult sign;
+ EncryptResult encrypt;
} result;
GpgmeData notation; /* last signature notation */
diff --git a/gpgme/encrypt.c b/gpgme/encrypt.c
index bff4153d..00531a01 100644
--- a/gpgme/encrypt.c
+++ b/gpgme/encrypt.c
@@ -29,10 +29,106 @@
#include "context.h"
#include "ops.h"
+#define SKIP_TOKEN_OR_RETURN(a) do { \
+ while (*(a) && *(a) != ' ') (a)++; \
+ while (*(a) == ' ') (a)++; \
+ if (!*(a)) \
+ return; /* oops */ \
+} while (0)
+
+
+
+struct encrypt_result_s {
+ GpgmeData xmlinfo;
+};
+
+
+void
+_gpgme_release_encrypt_result (EncryptResult res)
+{
+ gpgme_data_release (res->xmlinfo);
+ xfree (res);
+}
+
+
+/*
+ * Parse the args and save the information
+ * in an XML structure.
+ * With args of NULL the xml structure is closed.
+ */
+static void
+append_xml_encinfo (GpgmeData *rdh, char *args)
+{
+ GpgmeData dh;
+ char helpbuf[100];
+
+ if ( !*rdh ) {
+ if (gpgme_data_new (rdh)) {
+ return; /* fixme: We are ignoring out-of-core */
+ }
+ dh = *rdh;
+ _gpgme_data_append_string (dh, "<GnupgOperationInfo>\n");
+ }
+ else {
+ dh = *rdh;
+ _gpgme_data_append_string (dh, " </encryption>\n");
+ }
+
+ if (!args) { /* just close the XML containter */
+ _gpgme_data_append_string (dh, "</GnupgOperationInfo>\n");
+ return;
+ }
+
+ _gpgme_data_append_string (dh, " <encryption>\n"
+ " <error>\n"
+ " <invalidRecipient/>\n");
+
+ sprintf (helpbuf, " <reason>%d</reason>\n", atoi (args));
+ _gpgme_data_append_string (dh, helpbuf);
+ SKIP_TOKEN_OR_RETURN (args);
+
+ _gpgme_data_append_string (dh, " <name>");
+ _gpgme_data_append_percentstring_for_xml (dh, args);
+ _gpgme_data_append_string (dh, "</name>\n"
+ " </error>\n");
+}
+
+
+
+
+
static void
encrypt_status_handler ( GpgmeCtx ctx, GpgStatusCode code, char *args )
{
- DEBUG2 ("encrypt_status: code=%d args=`%s'\n", code, args );
+ if ( ctx->out_of_core )
+ return;
+ if ( ctx->result_type == RESULT_TYPE_NONE ) {
+ assert ( !ctx->result.encrypt );
+ ctx->result.encrypt = xtrycalloc ( 1, sizeof *ctx->result.encrypt );
+ if ( !ctx->result.encrypt ) {
+ ctx->out_of_core = 1;
+ return;
+ }
+ ctx->result_type = RESULT_TYPE_ENCRYPT;
+ }
+ assert ( ctx->result_type == RESULT_TYPE_ENCRYPT );
+
+ switch (code) {
+ case STATUS_EOF:
+ if (ctx->result.encrypt->xmlinfo) {
+ append_xml_encinfo (&ctx->result.encrypt->xmlinfo, NULL);
+ _gpgme_set_op_info (ctx, ctx->result.encrypt->xmlinfo);
+ ctx->result.encrypt->xmlinfo = NULL;
+ }
+ break;
+
+ case STATUS_INV_RECP:
+ append_xml_encinfo (&ctx->result.encrypt->xmlinfo, args);
+ break;
+
+ default:
+ break;
+ }
}
@@ -48,6 +144,9 @@ gpgme_op_encrypt_start ( GpgmeCtx c, GpgmeRecipients recp,
fail_on_pending_request( c );
c->pending = 1;
+ _gpgme_release_result (c);
+ c->out_of_core = 0;
+
/* do some checks */
if ( !gpgme_recipients_count ( recp ) ) {
/* Fixme: In this case we should do symmentric encryption */
@@ -127,7 +226,7 @@ gpgme_op_encrypt ( GpgmeCtx c, GpgmeRecipients recp,
if ( !rc ) {
gpgme_wait (c, 1);
c->pending = 0;
- /* FIXME: gpg does not return status info for invalid
+ /* FIXME: old gpg versions don't return status info for invalid
* recipients, so we simply check whether we got any output at
* all and if not assume that we don't have valid recipients
* */
diff --git a/gpgme/gpgme.c b/gpgme/gpgme.c
index 1140c4c8..b34fbde6 100644
--- a/gpgme/gpgme.c
+++ b/gpgme/gpgme.c
@@ -95,6 +95,9 @@ _gpgme_release_result ( GpgmeCtx c )
case RESULT_TYPE_SIGN:
_gpgme_release_sign_result ( c->result.sign );
break;
+ case RESULT_TYPE_ENCRYPT:
+ _gpgme_release_encrypt_result ( c->result.encrypt );
+ break;
}
c->result.verify = NULL;
diff --git a/gpgme/ops.h b/gpgme/ops.h
index 20a551bb..638e7818 100644
--- a/gpgme/ops.h
+++ b/gpgme/ops.h
@@ -76,6 +76,9 @@ void _gpgme_release_decrypt_result ( DecryptResult res );
/*-- sign.c --*/
void _gpgme_release_sign_result ( SignResult res );
+/*-- encrypt.c --*/
+void _gpgme_release_encrypt_result ( EncryptResult res );
+
#endif /* OPS_H */
diff --git a/gpgme/posix-util.c b/gpgme/posix-util.c
index 34150fb5..2478063e 100644
--- a/gpgme/posix-util.c
+++ b/gpgme/posix-util.c
@@ -34,9 +34,9 @@
const char *
_gpgme_get_gpg_path (void)
{
- /* #warning Forced to development version
+ #warning Forced to take GPG development version
return "/home/wk/work/gnupg-stable/g10/gpg";
- */
+
return GPG_PATH;
}
diff --git a/gpgme/recipient.c b/gpgme/recipient.c
index c9a217e2..522f6794 100644
--- a/gpgme/recipient.c
+++ b/gpgme/recipient.c
@@ -43,7 +43,14 @@ gpgme_recipients_new (GpgmeRecipients *r_rset)
void
gpgme_recipients_release ( GpgmeRecipients rset )
{
- /* fixme: release the linked list */
+ if (rset) {
+ struct user_id_s *u, *u2;
+
+ for (u = rset->list; u; u = u2) {
+ u2 = u->next;
+ xfree(u);
+ }
+ }
xfree ( rset );
}
diff --git a/gpgme/rungpg.h b/gpgme/rungpg.h
index 6323d591..3c2da5da 100644
--- a/gpgme/rungpg.h
+++ b/gpgme/rungpg.h
@@ -86,7 +86,8 @@ typedef enum {
STATUS_NOTATION_DATA ,
STATUS_POLICY_URL ,
STATUS_BEGIN_STREAM ,
- STATUS_END_STREAM
+ STATUS_END_STREAM ,
+ STATUS_INV_RECP
} GpgStatusCode;
typedef void (*GpgStatusHandler)( GpgmeCtx, GpgStatusCode code, char *args );
diff --git a/gpgme/types.h b/gpgme/types.h
index 4aa0df76..774e30e8 100644
--- a/gpgme/types.h
+++ b/gpgme/types.h
@@ -61,6 +61,10 @@ typedef struct decrypt_result_s *DecryptResult;
struct sign_result_s;
typedef struct sign_result_s *SignResult;
+/*-- encrypt.c --*/
+struct encrypt_result_s;
+typedef struct encrypt_result_s *EncryptResult;
+
/*-- key.c --*/
diff --git a/jnlib/ChangeLog b/jnlib/ChangeLog
index 93253685..92ce65a7 100644
--- a/jnlib/ChangeLog
+++ b/jnlib/ChangeLog
@@ -1,3 +1,7 @@
+2001-08-30 Werner Koch <[email protected]>
+
+ * logging.c (log_printf): Don't pass NULL instead of arg_ptr.
+
2001-07-19 Werner Koch <[email protected]>
* stringhelp.c (ascii_memistr,ascii_isupper,ascii_islower,
diff --git a/jnlib/logging.c b/jnlib/logging.c
index f03c5c45..dc439ff8 100644
--- a/jnlib/logging.c
+++ b/jnlib/logging.c
@@ -224,10 +224,10 @@ log_debug( const char *fmt, ... )
void
log_printf( const char *fmt, ... )
{
- va_list arg_ptr ;
+ va_list arg_ptr = 0;
if( !fmt ) {
- do_logv( MY_LOG_BEGIN, NULL, NULL );
+ do_logv( MY_LOG_BEGIN, NULL, arg_ptr );
}
else {
va_start( arg_ptr, fmt ) ;
diff --git a/tests/t-encrypt.c b/tests/t-encrypt.c
index bbb5557b..02ef11fa 100644
--- a/tests/t-encrypt.c
+++ b/tests/t-encrypt.c
@@ -33,6 +33,20 @@
} while(0)
static void
+print_op_info (GpgmeCtx c)
+{
+ char *s = gpgme_get_op_info (c, 0);
+
+ if (!s)
+ puts ("<!-- no operation info available -->");
+ else {
+ puts (s);
+ free (s);
+ }
+}
+
+
+static void
print_data ( GpgmeData dh )
{
char buf[100];
@@ -84,6 +98,7 @@ main (int argc, char **argv )
err = gpgme_op_encrypt (ctx, rset, in, out );
+ print_op_info (ctx);
fail_if_err (err);
fflush (NULL);