X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=crypt-gpgme.c;h=e16bffaf2d7f4cbebd562e0f79db1eb17853d26e;hp=7f6ce258cd868c4bb4ddbef78e657725401b1a4a;hb=13b3b36c8f696aea26b7c60444f2baa4858b004d;hpb=be393b838c5e0b8dfe9bedcc7a4a63f05caae7c4 diff --git a/crypt-gpgme.c b/crypt-gpgme.c index 7f6ce25..e16bffa 100644 --- a/crypt-gpgme.c +++ b/crypt-gpgme.c @@ -22,9 +22,13 @@ #include "mutt_crypt.h" #include "mutt_menu.h" #include "mutt_curses.h" +#include "ascii.h" +#include "handler.h" +#include "enter.h" #include "mime.h" #include "copy.h" #include "pager.h" +#include "recvattach.h" #include "sort.h" #include "lib/mem.h" @@ -1531,7 +1535,7 @@ int smime_gpgme_decrypt_mime (FILE * fpin, FILE ** fpout, BODY * b, saved_b_length = b->length; memset (&s, 0, sizeof (s)); s.fpin = fpin; - fseek (s.fpin, b->offset, 0); + fseeko (s.fpin, b->offset, 0); mutt_mktemp (tempfile); if (!(tmpfp = safe_fopen (tempfile, "w+"))) { mutt_perror (tempfile); @@ -1542,7 +1546,7 @@ int smime_gpgme_decrypt_mime (FILE * fpin, FILE ** fpout, BODY * b, s.fpout = tmpfp; mutt_decode_attachment (b, &s); fflush (tmpfp); - b->length = ftell (s.fpout); + b->length = ftello (s.fpout); b->offset = 0; rewind (tmpfp); @@ -1583,7 +1587,7 @@ int smime_gpgme_decrypt_mime (FILE * fpin, FILE ** fpout, BODY * b, saved_b_length = bb->length; memset (&s, 0, sizeof (s)); s.fpin = *fpout; - fseek (s.fpin, bb->offset, 0); + fseeko (s.fpin, bb->offset, 0); mutt_mktemp (tempfile); if (!(tmpfp = safe_fopen (tempfile, "w+"))) { mutt_perror (tempfile); @@ -1594,7 +1598,7 @@ int smime_gpgme_decrypt_mime (FILE * fpin, FILE ** fpout, BODY * b, s.fpout = tmpfp; mutt_decode_attachment (bb, &s); fflush (tmpfp); - bb->length = ftell (s.fpout); + bb->length = ftello (s.fpout); bb->offset = 0; rewind (tmpfp); fclose (*fpout); @@ -1762,16 +1766,17 @@ static void copy_clearsigned (gpgme_data_t data, STATE * s, char *charset) /* Support for classic_application/pgp */ -void pgp_gpgme_application_handler (BODY * m, STATE * s) +int pgp_gpgme_application_handler (BODY * m, STATE * s) { int needpass = -1, pgp_keyblock = 0; int clearsign = 0; long start_pos = 0; - long bytes, last_pos, offset; + long bytes; + LOFF_T last_pos, offset; char buf[HUGE_STRING]; FILE *pgpout = NULL; - gpgme_error_t err; + gpgme_error_t err = 0; gpgme_data_t armored_data = NULL; short maybe_goodsig = 1; @@ -1787,14 +1792,14 @@ void pgp_gpgme_application_handler (BODY * m, STATE * s) if (!mutt_get_body_charset (body_charset, sizeof (body_charset), m)) strfcpy (body_charset, "iso-8859-1", sizeof body_charset); - fseek (s->fpin, m->offset, 0); + fseeko (s->fpin, m->offset, 0); last_pos = m->offset; for (bytes = m->length; bytes > 0;) { if (fgets (buf, sizeof (buf), s->fpin) == NULL) break; - offset = ftell (s->fpin); + offset = ftello (s->fpin); bytes -= (offset - last_pos); /* don't rely on str_len(buf) */ last_pos = offset; @@ -1827,7 +1832,7 @@ void pgp_gpgme_application_handler (BODY * m, STATE * s) armored_data = create_gpgme_data (); gpgme_data_write (armored_data, buf, str_len (buf)); while (bytes > 0 && fgets (buf, sizeof (buf) - 1, s->fpin) != NULL) { - offset = ftell (s->fpin); + offset = ftello (s->fpin); bytes -= (offset - last_pos); /* don't rely on str_len(buf) */ last_pos = offset; @@ -1982,9 +1987,10 @@ void pgp_gpgme_application_handler (BODY * m, STATE * s) if (needpass == -1) { state_attach_puts (_("[-- Error: could not find beginning" " of PGP message! --]\n\n"), s); - return; + return (-1); } debug_print (2, ("Leaving pgp_application_pgp handler\n")); + return (err); } /* @@ -1992,13 +1998,14 @@ void pgp_gpgme_application_handler (BODY * m, STATE * s) */ /* MIME handler for pgp/mime encrypted messages. */ -void pgp_gpgme_encrypted_handler (BODY * a, STATE * s) +int pgp_gpgme_encrypted_handler (BODY * a, STATE * s) { char tempfile[_POSIX_PATH_MAX]; FILE *fpout; BODY *tattach; BODY *orig_body = a; int is_signed; + int rc = 0; debug_print (2, ("Entering pgp_encrypted handler\n")); a = a->parts; @@ -2009,7 +2016,7 @@ void pgp_gpgme_encrypted_handler (BODY * a, STATE * s) if (s->flags & M_DISPLAY) state_attach_puts (_("[-- Error: malformed PGP/MIME message! --]\n\n"), s); - return; + return (-1); } /* Move forward to the application/pgp-encrypted body. */ @@ -2020,7 +2027,7 @@ void pgp_gpgme_encrypted_handler (BODY * a, STATE * s) if (s->flags & M_DISPLAY) state_attach_puts (_("[-- Error: could not create temporary file! " "--]\n"), s); - return; + return (-1); } tattach = decrypt_part (a, s, fpout, 0, &is_signed); @@ -2030,17 +2037,14 @@ void pgp_gpgme_encrypted_handler (BODY * a, STATE * s) if (s->flags & M_DISPLAY) state_attach_puts (is_signed ? _ - ("[-- The following data is PGP/MIME signed and encrypted --]\n\n") - : - _ - ("[-- The following data is PGP/MIME encrypted --]\n\n"), - s); + ("[-- The following data is PGP/MIME signed and encrypted --]\n\n") : + _("[-- The following data is PGP/MIME encrypted --]\n\n"), s); { FILE *savefp = s->fpin; s->fpin = fpout; - mutt_body_handler (tattach, s); + rc = mutt_body_handler (tattach, s); s->fpin = savefp; } @@ -2066,16 +2070,17 @@ void pgp_gpgme_encrypted_handler (BODY * a, STATE * s) fclose (fpout); mutt_unlink (tempfile); debug_print (2, ("Leaving pgp_encrypted handler\n")); + return (rc); } /* Support for application/smime */ -void smime_gpgme_application_handler (BODY * a, STATE * s) +int smime_gpgme_application_handler (BODY * a, STATE * s) { char tempfile[_POSIX_PATH_MAX]; FILE *fpout; BODY *tattach; int is_signed; - + int rc = 0; debug_print (2, ("Entering smime_encrypted handler\n")); @@ -2085,7 +2090,7 @@ void smime_gpgme_application_handler (BODY * a, STATE * s) if (s->flags & M_DISPLAY) state_attach_puts (_("[-- Error: could not create temporary file! " "--]\n"), s); - return; + return (-1); } tattach = decrypt_part (a, s, fpout, 1, &is_signed); @@ -2094,17 +2099,14 @@ void smime_gpgme_application_handler (BODY * a, STATE * s) if (s->flags & M_DISPLAY) state_attach_puts (is_signed ? - _("[-- The following data is S/MIME signed --]\n\n") - : - _ - ("[-- The following data is S/MIME encrypted --]\n\n"), - s); + _("[-- The following data is S/MIME signed --]\n\n") : + _("[-- The following data is S/MIME encrypted --]\n\n"), s); { FILE *savefp = s->fpin; s->fpin = fpout; - mutt_body_handler (tattach, s); + rc = mutt_body_handler (tattach, s); s->fpin = savefp; } @@ -2135,6 +2137,7 @@ void smime_gpgme_application_handler (BODY * a, STATE * s) fclose (fpout); mutt_unlink (tempfile); debug_print (2, ("Leaving smime_encrypted handler\n")); + return (rc); }