From: Karl-Heinz Zimmer Date: Thu, 22 Nov 2001 09:36:53 +0000 (+0000) Subject: Now send the signature back to the calling function (instead of just printing it... X-Git-Tag: gpgme-0-3-0~84 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=66f4b09b45914a57e938c76748e6fa419dfff2a0;p=gpgme.git Now send the signature back to the calling function (instead of just printing it to stdout) --- diff --git a/gpgmeplug/gpgmeplug.c b/gpgmeplug/gpgmeplug.c index 248eebe..88582b2 100644 --- a/gpgmeplug/gpgmeplug.c +++ b/gpgmeplug/gpgmeplug.c @@ -671,11 +671,13 @@ bool signMessage( const char* cleartext, const char* certificate ) { GpgmeCtx ctx; - GpgmeData data, sig; - - char buf[1024]; - size_t nread; + GpgmeData data, sig; + size_t rDLen, rSLen; + char* rData = 0; + char* rSig = 0; + if( !ciphertext ) + return false; gpgme_new (&ctx); gpgme_set_armor (ctx, 1); @@ -686,28 +688,26 @@ bool signMessage( const char* cleartext, gpgme_data_new ( &sig ); gpgme_op_sign (ctx, data, sig, GPGME_SIG_MODE_DETACH ); - fputs ( "Content-Type: multipart/signed;\r\n" - " protocol=\"application/pgp-signature\";\r\n" - " boundary=\"42=.42=.42=.42\"\r\n" - "\r\n--42=.42=.42=.42\r\n", - stdout ); - - gpgme_data_rewind (data); - while ( !gpgme_data_read (data, buf, sizeof buf, &nread ) ) { - fwrite (buf, nread, 1, stdout ); - } - fputs ( "\r\n--42=.42=.42=.42\r\n" - "Content-Type: application/pgp-signature\r\n\r\n", stdout); - - gpgme_data_rewind (sig); - while ( !gpgme_data_read (sig, buf, sizeof buf, &nread ) ) { - fwrite (buf, nread, 1, stdout ); + rData = gpgme_data_release_and_get_mem( data, &rDLen ); + rSig = gpgme_data_release_and_get_mem( sig, &rSLen ); + + *ciphertext = malloc( rDLen + rSLen + 1000 ); + if( *ciphertext ) { + strcpy( (char*)*ciphertext, + "Content-Type: multipart/signed;\r\n" + " protocol=\"application/pgp-signature\";\r\n" + " boundary=\"42=.42=.42=.42\"\r\n" + "\r\n--42=.42=.42=.42\r\n" ); + strncat((char*)*ciphertext, rData, rDLen ); + strcat( (char*)*ciphertext, + "\r\n--42=.42=.42=.42\r\n" + "Content-Type: application/pgp-signature\r\n\r\n" ); + strncat((char*)*ciphertext, rSig, rSLen ); + strcat( (char*)*ciphertext, + "\r\n--42=.42=.42=.42--\r\n" ); } - fputs ( "\r\n--42=.42=.42=.42--\r\n", stdout ); gpgme_release (ctx); - gpgme_data_release(data); - gpgme_data_release(sig); return true; }