From: Pierre Habouzit Date: Wed, 4 Apr 2007 23:52:54 +0000 (+0200) Subject: More simplification and prototype hiding X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=commitdiff_plain;h=7d9dec2f12342892c972bed1ece496b03180cd81 More simplification and prototype hiding Signed-off-by: Pierre Habouzit --- diff --git a/crypt.c b/crypt.c index b22d616..d044e9a 100644 --- a/crypt.c +++ b/crypt.c @@ -76,6 +76,34 @@ static gpgme_key_t signature_key = NULL; * General helper functions. */ +static void convert_to_7bit (BODY * a) +{ + while (a) { + if (a->type == TYPEMULTIPART) { + if (a->encoding != ENC7BIT) { + a->encoding = ENC7BIT; + convert_to_7bit (a->parts); + } else { + convert_to_7bit (a->parts); + } + } + else if (a->type == TYPEMESSAGE && + m_strcasecmp(a->subtype, "delivery-status")) { + if (a->encoding != ENC7BIT) + mutt_message_to_7bit (a, NULL); + } + else if (a->encoding == ENC8BIT) + a->encoding = ENCQUOTEDPRINTABLE; + else if (a->encoding == ENCBINARY) + a->encoding = ENCBASE64; + else if (a->content && a->encoding != ENCBASE64 && + (a->content->from || a->content->space)) + a->encoding = ENCQUOTEDPRINTABLE; + a = a->next; + } +} + + /* return true when S points to a didgit or letter. */ static int digit_or_letter (const unsigned char *s) { @@ -781,24 +809,13 @@ static BODY *sign_message (BODY * a, int use_smime) return a; } - -BODY *crypt_pgp_sign_message (BODY * a) -{ - return sign_message (a, 0); -} - -BODY *crypt_smime_sign_message (BODY * a) -{ - return sign_message (a, 1); -} - /* * Implementation of `encrypt_message'. */ /* Encrypt the mail body A to all keys given as space separated keyids or fingerprints in KEYLIST and return the encrypted body. */ -BODY *crypt_pgp_encrypt_message (BODY * a, char *keylist, int sign) +static BODY *crypt_pgp_encrypt_message (BODY * a, char *keylist, int sign) { char *outfile = NULL; BODY *t; @@ -858,7 +875,7 @@ BODY *crypt_pgp_encrypt_message (BODY * a, char *keylist, int sign) /* Encrypt the mail body A to all keys given as space separated fingerprints in KEYLIST and return the S/MIME encrypted body. */ -BODY *crypt_smime_build_smime_entity (BODY * a, char *keylist) +static BODY *crypt_smime_build_smime_entity (BODY * a, char *keylist) { char *outfile = NULL; BODY *t; @@ -1198,7 +1215,7 @@ static int show_one_sig_status (gpgme_ctx_t ctx, int idx, STATE * s) /* Do the actual verification step. With IS_SMIME set to true we assume S/MIME (surprise!) */ -int crypt_verify_one(BODY *sigbdy, STATE *s, FILE *fp, int is_smime) +static int crypt_verify_one(BODY *sigbdy, STATE *s, FILE *fp, int is_smime) { int badsig = -1; int anywarn = 0; @@ -3825,7 +3842,7 @@ int crypt_smime_verify_sender (HEADER * h) return ret; } -void crypt_invoke_import(FILE *stream, int smime) +static void crypt_invoke_import(FILE *stream, int smime) { gpgme_ctx_t ctx = create_gpgme_context(smime); gpgme_data_t data; @@ -3935,14 +3952,14 @@ int mutt_protect (HEADER * msg, char *keylist) if (msg->security & SIGN) { if (msg->security & APPLICATION_SMIME) { - if (!(tmp_pbody = crypt_smime_sign_message (msg->content))) + if (!(tmp_pbody = sign_message(msg->content, 1))) return -1; pbody = tmp_smime_pbody = tmp_pbody; } if ((msg->security & APPLICATION_PGP) && (!(flags & ENCRYPT) || option (OPTPGPRETAINABLESIG))) { - if (!(tmp_pbody = crypt_pgp_sign_message (msg->content))) + if (!(tmp_pbody = sign_message(msg->content, 0))) return -1; flags &= ~SIGN; @@ -4086,36 +4103,6 @@ static void crypt_write_signed(BODY * a, STATE * s, FILE *fp) } } - - -void convert_to_7bit (BODY * a) -{ - while (a) { - if (a->type == TYPEMULTIPART) { - if (a->encoding != ENC7BIT) { - a->encoding = ENC7BIT; - convert_to_7bit (a->parts); - } else { - convert_to_7bit (a->parts); - } - } - else if (a->type == TYPEMESSAGE && - m_strcasecmp(a->subtype, "delivery-status")) { - if (a->encoding != ENC7BIT) - mutt_message_to_7bit (a, NULL); - } - else if (a->encoding == ENC8BIT) - a->encoding = ENCQUOTEDPRINTABLE; - else if (a->encoding == ENCBINARY) - a->encoding = ENCBASE64; - else if (a->content && a->encoding != ENCBASE64 && - (a->content->from || a->content->space)) - a->encoding = ENCQUOTEDPRINTABLE; - a = a->next; - } -} - - static void extract_keys_aux(FILE *fpout, HEADER *h) { mutt_parse_mime_message (Context, h); diff --git a/crypt.h b/crypt.h index 12acc61..e6db9b7 100644 --- a/crypt.h +++ b/crypt.h @@ -59,19 +59,10 @@ #define KEYFLAG_ABILITIES (KEYFLAG_CANSIGN|KEYFLAG_CANENCRYPT|KEYFLAG_PREFER_ENCRYPTION|KEYFLAG_PREFER_SIGNING) -/*-- new API --*/ - -void crypt_invoke_import(FILE *stream, int smime); int crypt_send_menu(HEADER *msg, int *redraw, int smime); -int crypt_verify_one(BODY *, STATE *s, FILE *fp, int smime); - - -/*-- crypt.c --*/ - int mutt_protect (HEADER *, char *); int mutt_signed_handler (BODY *, STATE *); int mutt_parse_crypt_hdr (char *, int); -void convert_to_7bit (BODY *); /* Check out the type of encryption used and set the cached status values if there are any. */ @@ -107,13 +98,6 @@ int crypt_pgp_check_traditional (FILE * fp, BODY * b, int tagged_only); /* Generate a PGP public key attachment. */ BODY *crypt_pgp_make_key_attachment (char *tempf); -/* Create a new body with a PGP signed message from A. */ -BODY *crypt_pgp_sign_message (BODY * a); - -/* Warning: A is no longer freed in this routine, you need to free it - later. This is necessary for $fcc_attach. */ -BODY *crypt_pgp_encrypt_message (BODY * a, char *keylist, int sign); - /* fixme: needs documentation */ void crypt_pgp_extract_keys_from_attachment_list (FILE * fp, int tag, BODY * top); @@ -131,10 +115,4 @@ void crypt_smime_getkeys (ENVELOPE * env); /* Check that the sender matches. */ int crypt_smime_verify_sender (HEADER * h); -/* fixme: Needs documentation. */ -BODY *crypt_smime_sign_message (BODY * a); - -/* fixme: needs documentation. */ -BODY *crypt_smime_build_smime_entity (BODY * a, char *certlist); - #endif /*MUTT_CRYPT_H */