report both the error-Id and the error-text to the calling program when signing or encrypting of mails could not be done

This commit is contained in:
Karl-Heinz Zimmer 2002-04-17 15:00:53 +00:00
parent 0fc18236a2
commit 76cc7612bd
2 changed files with 36 additions and 12 deletions

View File

@ -1420,10 +1420,12 @@ struct StructuringInfo {
\see StructuringInfo, free_StructuringInfo \see StructuringInfo, free_StructuringInfo
*/ */
bool signMessage( const char* cleartext, bool signMessage( const char* cleartext,
const char** ciphertext, char** ciphertext,
const size_t* cipherLen, const size_t* cipherLen,
const char* certificate, const char* certificate,
struct StructuringInfo* structuring ); struct StructuringInfo* structuring,
int* errId,
char** errTxt );
/*! \ingroup groupSignAct /*! \ingroup groupSignAct
@ -1515,7 +1517,9 @@ bool encryptMessage( const char* cleartext,
const char** ciphertext, const char** ciphertext,
const size_t* cipherLen, const size_t* cipherLen,
const char* addressee, const char* addressee,
struct StructuringInfo* structuring ); struct StructuringInfo* structuring,
int* errId,
char** errTxt );
/*! \ingroup groupCryptAct /*! \ingroup groupCryptAct

View File

@ -861,10 +861,12 @@ void storeNewCharPtr( char** dest, const char* src )
bool signMessage( const char* cleartext, bool signMessage( const char* cleartext,
const char** ciphertext, char** ciphertext,
const size_t* cipherLen, const size_t* cipherLen,
const char* certificate, const char* certificate,
struct StructuringInfo* structuring ) struct StructuringInfo* structuring,
int* errId,
char** errTxt )
{ {
GpgmeCtx ctx; GpgmeCtx ctx;
GpgmeError err; GpgmeError err;
@ -929,7 +931,7 @@ bool signMessage( const char* cleartext,
bOk = true; bOk = true;
strncpy((char*)*ciphertext, rSig, *cipherLen ); strncpy((char*)*ciphertext, rSig, *cipherLen );
} }
((char*)(*ciphertext))[*cipherLen] = '\0'; (*ciphertext)[*cipherLen] = '\0';
} }
free( rSig ); free( rSig );
} }
@ -937,8 +939,15 @@ bool signMessage( const char* cleartext,
else { else {
gpgme_data_release( sig ); gpgme_data_release( sig );
*ciphertext = 0; *ciphertext = 0;
/* erro handling missing to detect wther signing failed (hier fprintf( stderr, "\ngpgme_op_sign() returned this error code: %i\n\n", err );
fehlt eine Fehlerbehandlung, falls das Signieren schiefging) */ if( errId )
*errId = err;
if( errTxt ) {
const char* _errTxt = gpgme_strerror( err );
*errTxt = malloc( strlen( _errTxt ) + 1 );
if( *errTxt )
strcpy(*errTxt, _errTxt );
}
} }
gpgme_data_release( data ); gpgme_data_release( data );
gpgme_release (ctx); gpgme_release (ctx);
@ -1251,7 +1260,9 @@ bool encryptMessage( const char* cleartext,
const char** ciphertext, const char** ciphertext,
const size_t* cipherLen, const size_t* cipherLen,
const char* certificate, const char* certificate,
struct StructuringInfo* structuring ) struct StructuringInfo* structuring,
int* errId,
char** errTxt )
{ {
GpgmeCtx ctx; GpgmeCtx ctx;
GpgmeError err; GpgmeError err;
@ -1319,8 +1330,17 @@ bool encryptMessage( const char* cleartext,
err = gpgme_op_encrypt (ctx, rset, gPlaintext, gCiphertext ); err = gpgme_op_encrypt (ctx, rset, gPlaintext, gCiphertext );
if( err ) if( err ) {
fprintf( stderr, "gpgme_op_encrypt() returned this error code: %i\n\n", err ); fprintf( stderr, "\ngpgme_op_encrypt() returned this error code: %i\n\n", err );
if( errId )
*errId = err;
if( errTxt ) {
const char* _errTxt = gpgme_strerror( err );
*errTxt = malloc( strlen( _errTxt ) + 1 );
if( *errTxt )
strcpy(*errTxt, _errTxt );
}
}
gpgme_recipients_release (rset); gpgme_recipients_release (rset);
gpgme_data_release (gPlaintext); gpgme_data_release (gPlaintext);