Some changes
This commit is contained in:
parent
5ad992b6aa
commit
5b3d8162b4
@ -1,5 +1,16 @@
|
||||
2001-09-03 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* 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 <wk@gnupg.org>
|
||||
|
||||
* 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
|
||||
|
@ -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 */
|
||||
|
103
gpgme/encrypt.c
103
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
|
||||
* */
|
||||
|
@ -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;
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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 );
|
||||
}
|
||||
|
||||
|
@ -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 );
|
||||
|
@ -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 --*/
|
||||
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
2001-08-30 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* logging.c (log_printf): Don't pass NULL instead of arg_ptr.
|
||||
|
||||
2001-07-19 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* stringhelp.c (ascii_memistr,ascii_isupper,ascii_islower,
|
||||
|
@ -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 ) ;
|
||||
|
@ -32,6 +32,20 @@
|
||||
exit (1); } \
|
||||
} 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 )
|
||||
{
|
||||
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user