From b822b9df64ec48bfa2224c0fbec1fb51e9cb3d37 Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Tue, 12 Jun 2018 12:32:53 +0100 Subject: [PATCH] boolify params --- commands.c | 2 +- ncrypt/crypt.c | 2 +- ncrypt/crypt_gpgme.c | 53 +++++++++++++++++++++++--------------------- ncrypt/crypt_gpgme.h | 4 ++-- ncrypt/crypt_mod.h | 4 ++-- ncrypt/cryptglue.c | 4 ++-- ncrypt/cryptglue.h | 2 +- ncrypt/ncrypt.h | 2 +- ncrypt/pgp.c | 6 ++--- ncrypt/pgp.h | 4 ++-- ncrypt/pgpinvoke.c | 2 +- ncrypt/pgpinvoke.h | 2 +- recvattach.c | 4 ++-- 13 files changed, 47 insertions(+), 44 deletions(-) diff --git a/commands.c b/commands.c index 3b1a7d545..5332d73a0 100644 --- a/commands.c +++ b/commands.c @@ -1100,7 +1100,7 @@ static int check_traditional_pgp(struct Header *h, int *redraw) struct Message *msg = mx_msg_open(Context, h->msgno); if (!msg) return 0; - if (crypt_pgp_check_traditional(msg->fp, h->content, 0)) + if (crypt_pgp_check_traditional(msg->fp, h->content, false)) { h->security = crypt_query(h->content); *redraw |= REDRAW_FULL; diff --git a/ncrypt/crypt.c b/ncrypt/crypt.c index 5cfdf71c7..ab6d8fa66 100644 --- a/ncrypt/crypt.c +++ b/ncrypt/crypt.c @@ -288,7 +288,7 @@ int mutt_protect(struct Header *msg, char *keylist) if (((WithCrypto & APPLICATION_PGP) != 0) && (msg->security & APPLICATION_PGP)) { - pbody = crypt_pgp_encrypt_message(tmp_pgp_pbody, keylist, flags & SIGN); + pbody = crypt_pgp_encrypt_message(tmp_pgp_pbody, keylist, (flags & SIGN)); if (!pbody) { /* did we perform a retainable signature? */ diff --git a/ncrypt/crypt_gpgme.c b/ncrypt/crypt_gpgme.c index d0cf1282d..9b85a9db3 100644 --- a/ncrypt/crypt_gpgme.c +++ b/ncrypt/crypt_gpgme.c @@ -461,10 +461,10 @@ static int crypt_id_matches_addr(struct Address *addr, struct Address *u_addr, /** * create_gpgme_context - Create a new GPGME context - * @param for_smime If set, protocol of the context is set to CMS + * @param for_smime If true, protocol of the context is set to CMS * @retval ptr New GPGME context */ -static gpgme_ctx_t create_gpgme_context(int for_smime) +static gpgme_ctx_t create_gpgme_context(bool for_smime) { gpgme_error_t err; gpgme_ctx_t ctx; @@ -785,9 +785,12 @@ static gpgme_key_t *create_recipient_set(const char *keylist, gpgme_protocol_t p /** * set_signer - Make sure that the correct signer is set - * @retval 0 Success + * @param ctx gpgme Context + * @param for_smime Use S/MIME + * @retval 0 Success + * @retval -1 Error */ -static int set_signer(gpgme_ctx_t ctx, int for_smime) +static int set_signer(gpgme_ctx_t ctx, bool for_smime) { char *signid = for_smime ? SmimeDefaultKey : PgpSignAs; gpgme_error_t err; @@ -853,7 +856,7 @@ static gpgme_error_t set_pka_sig_notation(gpgme_ctx_t ctx) * a PGP message is signed and encrypted. Returns NULL in case of error */ static char *encrypt_gpgme_object(gpgme_data_t plaintext, gpgme_key_t *rset, - int use_smime, int combined_signed) + bool use_smime, bool combined_signed) { gpgme_error_t err; gpgme_ctx_t ctx; @@ -969,7 +972,7 @@ static void print_time(time_t t, struct State *s) * @retval ptr new Body * @retval NULL error */ -static struct Body *sign_message(struct Body *a, int use_smime) +static struct Body *sign_message(struct Body *a, bool use_smime) { struct Body *t = NULL; char *sigfile = NULL; @@ -1093,7 +1096,7 @@ static struct Body *sign_message(struct Body *a, int use_smime) */ struct Body *pgp_gpgme_sign_message(struct Body *a) { - return sign_message(a, 0); + return sign_message(a, false); } /** @@ -1101,13 +1104,13 @@ struct Body *pgp_gpgme_sign_message(struct Body *a) */ struct Body *smime_gpgme_sign_message(struct Body *a) { - return sign_message(a, 1); + return sign_message(a, true); } /** * pgp_gpgme_encrypt_message - Implements CryptModuleSpecs::pgp_encrypt_message() */ -struct Body *pgp_gpgme_encrypt_message(struct Body *a, char *keylist, int sign) +struct Body *pgp_gpgme_encrypt_message(struct Body *a, char *keylist, bool sign) { gpgme_key_t *rset = create_recipient_set(keylist, GPGME_PROTOCOL_OpenPGP); if (!rset) @@ -1122,7 +1125,7 @@ struct Body *pgp_gpgme_encrypt_message(struct Body *a, char *keylist, int sign) return NULL; } - char *outfile = encrypt_gpgme_object(plaintext, rset, 0, sign); + char *outfile = encrypt_gpgme_object(plaintext, rset, false, sign); gpgme_data_release(plaintext); free_recipient_set(&rset); if (!outfile) @@ -1177,7 +1180,7 @@ struct Body *smime_gpgme_build_smime_entity(struct Body *a, char *keylist) return NULL; } - char *outfile = encrypt_gpgme_object(plaintext, rset, 1, 0); + char *outfile = encrypt_gpgme_object(plaintext, rset, true, false); gpgme_data_release(plaintext); free_recipient_set(&rset); if (!outfile) @@ -1599,7 +1602,7 @@ static int show_one_sig_status(gpgme_ctx_t ctx, int idx, struct State *s) * * With IS_SMIME set to true we assume S/MIME (surprise!) */ -static int verify_one(struct Body *sigbdy, struct State *s, const char *tempfile, int is_smime) +static int verify_one(struct Body *sigbdy, struct State *s, const char *tempfile, bool is_smime) { int badsig = -1; int anywarn = 0; @@ -1728,7 +1731,7 @@ static int verify_one(struct Body *sigbdy, struct State *s, const char *tempfile */ int pgp_gpgme_verify_one(struct Body *sigbdy, struct State *s, const char *tempfile) { - return verify_one(sigbdy, s, tempfile, 0); + return verify_one(sigbdy, s, tempfile, false); } /** @@ -1736,7 +1739,7 @@ int pgp_gpgme_verify_one(struct Body *sigbdy, struct State *s, const char *tempf */ int smime_gpgme_verify_one(struct Body *sigbdy, struct State *s, const char *tempfile) { - return verify_one(sigbdy, s, tempfile, 1); + return verify_one(sigbdy, s, tempfile, true); } /** @@ -1749,7 +1752,7 @@ int smime_gpgme_verify_one(struct Body *sigbdy, struct State *s, const char *tem * encrypted but a signed message. */ static struct Body *decrypt_part(struct Body *a, struct State *s, FILE *fpout, - int is_smime, int *r_is_signed) + bool is_smime, int *r_is_signed) { if (!a || !s || !fpout) return NULL; @@ -1970,7 +1973,7 @@ int pgp_gpgme_decrypt_mime(FILE *fpin, FILE **fpout, struct Body *b, struct Body } unlink(tempfile); - *cur = decrypt_part(b, &s, *fpout, 0, &is_signed); + *cur = decrypt_part(b, &s, *fpout, false, &is_signed); if (!*cur) rc = -1; rewind(*fpout); @@ -2046,7 +2049,7 @@ int smime_gpgme_decrypt_mime(FILE *fpin, FILE **fpout, struct Body *b, struct Bo } mutt_file_unlink(tempfile); - *cur = decrypt_part(b, &s, *fpout, 1, &is_signed); + *cur = decrypt_part(b, &s, *fpout, true, &is_signed); if (*cur) (*cur)->goodsig = is_signed > 0; b->type = saved_b_type; @@ -2103,7 +2106,7 @@ int smime_gpgme_decrypt_mime(FILE *fpin, FILE **fpout, struct Body *b, struct Bo } mutt_file_unlink(tempfile); - tmp_b = decrypt_part(bb, &s, *fpout, 1, &is_signed); + tmp_b = decrypt_part(bb, &s, *fpout, true, &is_signed); if (tmp_b) tmp_b->goodsig = is_signed > 0; bb->type = saved_b_type; @@ -2327,14 +2330,14 @@ static int pgp_check_traditional_one_body(FILE *fp, struct Body *b) /** * pgp_gpgme_check_traditional - Implements CryptModuleSpecs::pgp_check_traditional() */ -int pgp_gpgme_check_traditional(FILE *fp, struct Body *b, int just_one) +int pgp_gpgme_check_traditional(FILE *fp, struct Body *b, bool just_one) { int rc = 0; int r; for (; b; b = b->next) { if (!just_one && is_multipart(b)) - rc = (pgp_gpgme_check_traditional(fp, b->parts, 0) || rc); + rc = (pgp_gpgme_check_traditional(fp, b->parts, false) || rc); else if (b->type == TYPETEXT) { r = mutt_is_application_pgp(b); @@ -2528,7 +2531,7 @@ int pgp_gpgme_application_handler(struct Body *m, struct State *s) gpgme_ctx_t ctx; plaintext = create_gpgme_data(); - ctx = create_gpgme_context(0); + ctx = create_gpgme_context(false); if (clearsign) err = gpgme_op_verify(ctx, armored_data, NULL, plaintext); @@ -2712,7 +2715,7 @@ int pgp_gpgme_encrypted_handler(struct Body *a, struct State *s) return -1; } - struct Body *tattach = decrypt_part(a, s, fpout, 0, &is_signed); + struct Body *tattach = decrypt_part(a, s, fpout, false, &is_signed); if (tattach) { tattach->goodsig = is_signed > 0; @@ -2771,7 +2774,7 @@ int pgp_gpgme_encrypted_handler(struct Body *a, struct State *s) int smime_gpgme_application_handler(struct Body *a, struct State *s) { char tempfile[PATH_MAX]; - int is_signed; + int is_signed = 0; int rc = 0; mutt_debug(2, "Entering handler\n"); @@ -2790,7 +2793,7 @@ int smime_gpgme_application_handler(struct Body *a, struct State *s) return -1; } - struct Body *tattach = decrypt_part(a, s, fpout, 1, &is_signed); + struct Body *tattach = decrypt_part(a, s, fpout, true, &is_signed); if (tattach) { tattach->goodsig = is_signed > 0; @@ -4762,7 +4765,7 @@ struct Body *pgp_gpgme_make_key_attachment(void) export_keys[0] = key->kobj; export_keys[1] = NULL; - context = create_gpgme_context(0); + context = create_gpgme_context(false); gpgme_set_armor(context, 1); keydata = create_gpgme_data(); err = gpgme_op_export_keys(context, export_keys, 0, keydata); diff --git a/ncrypt/crypt_gpgme.h b/ncrypt/crypt_gpgme.h index e095616cd..45d25dee2 100644 --- a/ncrypt/crypt_gpgme.h +++ b/ncrypt/crypt_gpgme.h @@ -34,10 +34,10 @@ struct State; void pgp_gpgme_set_sender(const char *sender); int pgp_gpgme_application_handler(struct Body *m, struct State *s); -int pgp_gpgme_check_traditional(FILE *fp, struct Body *b, int just_one); +int pgp_gpgme_check_traditional(FILE *fp, struct Body *b, bool just_one); int pgp_gpgme_decrypt_mime(FILE *fpin, FILE **fpout, struct Body *b, struct Body **cur); int pgp_gpgme_encrypted_handler(struct Body *a, struct State *s); -struct Body *pgp_gpgme_encrypt_message(struct Body *a, char *keylist, int sign); +struct Body *pgp_gpgme_encrypt_message(struct Body *a, char *keylist, bool sign); char * pgp_gpgme_find_keys(struct Address *addrlist, bool oppenc_mode); void pgp_gpgme_init(void); void pgp_gpgme_invoke_import(const char *fname); diff --git a/ncrypt/crypt_mod.h b/ncrypt/crypt_mod.h index fa4f1f2ed..89839645d 100644 --- a/ncrypt/crypt_mod.h +++ b/ncrypt/crypt_mod.h @@ -133,7 +133,7 @@ struct CryptModuleSpecs * * Encrypt the mail body to all the given keys. */ - struct Body *(*pgp_encrypt_message)(struct Body *a, char *keylist, int sign); + struct Body *(*pgp_encrypt_message)(struct Body *a, char *keylist, bool sign); /** * pgp_make_key_attachment - Generate a public key attachment * @retval ptr New Body containing the attachment @@ -148,7 +148,7 @@ struct CryptModuleSpecs * @retval 1 It's an inline PGP email * @retval 0 It's not inline, or an error */ - int (*pgp_check_traditional)(FILE *fp, struct Body *b, int just_one); + int (*pgp_check_traditional)(FILE *fp, struct Body *b, bool just_one); /** * pgp_traditional_encryptsign - Create an inline PGP encrypted, signed email * @param a Body of the email diff --git a/ncrypt/cryptglue.c b/ncrypt/cryptglue.c index facb6c67f..994b9770f 100644 --- a/ncrypt/cryptglue.c +++ b/ncrypt/cryptglue.c @@ -228,7 +228,7 @@ void crypt_pgp_invoke_getkeys(struct Address *addr) /** * crypt_pgp_check_traditional - Wrapper for CryptModuleSpecs::pgp_check_traditional() */ -int crypt_pgp_check_traditional(FILE *fp, struct Body *b, int just_one) +int crypt_pgp_check_traditional(FILE *fp, struct Body *b, bool just_one) { if (CRYPT_MOD_CALL_CHECK(PGP, pgp_check_traditional)) return (CRYPT_MOD_CALL(PGP, pgp_check_traditional))(fp, b, just_one); @@ -283,7 +283,7 @@ struct Body *crypt_pgp_sign_message(struct Body *a) /** * crypt_pgp_encrypt_message - Wrapper for CryptModuleSpecs::pgp_encrypt_message() */ -struct Body *crypt_pgp_encrypt_message(struct Body *a, char *keylist, int sign) +struct Body *crypt_pgp_encrypt_message(struct Body *a, char *keylist, bool sign) { if (CRYPT_MOD_CALL_CHECK(PGP, pgp_encrypt_message)) return (CRYPT_MOD_CALL(PGP, pgp_encrypt_message))(a, keylist, sign); diff --git a/ncrypt/cryptglue.h b/ncrypt/cryptglue.h index d2e22ee42..f44cb4f11 100644 --- a/ncrypt/cryptglue.h +++ b/ncrypt/cryptglue.h @@ -27,7 +27,7 @@ struct Address; struct Body; struct State; -struct Body *crypt_pgp_encrypt_message(struct Body *a, char *keylist, int sign); +struct Body *crypt_pgp_encrypt_message(struct Body *a, char *keylist, bool sign); char * crypt_pgp_find_keys(struct Address *addrlist, bool oppenc_mode); void crypt_pgp_invoke_import(const char *fname); void crypt_pgp_set_sender(const char *sender); diff --git a/ncrypt/ncrypt.h b/ncrypt/ncrypt.h index 5e12d52f4..50e740264 100644 --- a/ncrypt/ncrypt.h +++ b/ncrypt/ncrypt.h @@ -143,7 +143,7 @@ int crypt_has_module_backend(int type); void crypt_init(void); void crypt_invoke_message(int type); int crypt_pgp_application_handler(struct Body *m, struct State *s); -int crypt_pgp_check_traditional(FILE *fp, struct Body *b, int just_one); +int crypt_pgp_check_traditional(FILE *fp, struct Body *b, bool just_one); int crypt_pgp_decrypt_mime(FILE *a, FILE **b, struct Body *c, struct Body **d); int crypt_pgp_encrypted_handler(struct Body *a, struct State *s); void crypt_pgp_extract_key_from_attachment(FILE *fp, struct Body *top); diff --git a/ncrypt/pgp.c b/ncrypt/pgp.c index f07cbdb37..ed4b61dc7 100644 --- a/ncrypt/pgp.c +++ b/ncrypt/pgp.c @@ -682,14 +682,14 @@ static int pgp_check_traditional_one_body(FILE *fp, struct Body *b) /** * pgp_class_check_traditional - Implements CryptModuleSpecs::pgp_check_traditional() */ -int pgp_class_check_traditional(FILE *fp, struct Body *b, int just_one) +int pgp_class_check_traditional(FILE *fp, struct Body *b, bool just_one) { int rc = 0; int r; for (; b; b = b->next) { if (!just_one && is_multipart(b)) - rc = pgp_class_check_traditional(fp, b->parts, 0) || rc; + rc = pgp_class_check_traditional(fp, b->parts, false) || rc; else if (b->type == TYPETEXT) { r = mutt_is_application_pgp(b); @@ -1360,7 +1360,7 @@ char *pgp_class_find_keys(struct Address *addrlist, bool oppenc_mode) * @warning "a" is no longer freed in this routine, you need to free it later. * This is necessary for $fcc_attach. */ -struct Body *pgp_class_encrypt_message(struct Body *a, char *keylist, int sign) +struct Body *pgp_class_encrypt_message(struct Body *a, char *keylist, bool sign) { char buf[LONG_STRING]; char tempfile[PATH_MAX], pgperrfile[PATH_MAX]; diff --git a/ncrypt/pgp.h b/ncrypt/pgp.h index df430ac7d..6829f1e15 100644 --- a/ncrypt/pgp.h +++ b/ncrypt/pgp.h @@ -40,7 +40,7 @@ struct State; bool pgp_use_gpg_agent(void); -int pgp_class_check_traditional(FILE *fp, struct Body *b, int just_one); +int pgp_class_check_traditional(FILE *fp, struct Body *b, bool just_one); char *pgp_this_keyid(struct PgpKeyInfo *k); char *pgp_keyid(struct PgpKeyInfo *k); @@ -60,7 +60,7 @@ int pgp_class_valid_passphrase(void); int pgp_class_verify_one(struct Body *sigbdy, struct State *s, const char *tempfile); struct Body *pgp_class_traditional_encryptsign(struct Body *a, int flags, char *keylist); -struct Body *pgp_class_encrypt_message(struct Body *a, char *keylist, int sign); +struct Body *pgp_class_encrypt_message(struct Body *a, char *keylist, bool sign); struct Body *pgp_class_sign_message(struct Body *a); int pgp_class_send_menu(struct Header *msg); diff --git a/ncrypt/pgpinvoke.c b/ncrypt/pgpinvoke.c index 7763d466e..c8c6a168d 100644 --- a/ncrypt/pgpinvoke.c +++ b/ncrypt/pgpinvoke.c @@ -214,7 +214,7 @@ pid_t pgp_invoke_sign(FILE **pgpin, FILE **pgpout, FILE **pgperr, int pgpinfd, pid_t pgp_invoke_encrypt(FILE **pgpin, FILE **pgpout, FILE **pgperr, int pgpinfd, int pgpoutfd, int pgperrfd, - const char *fname, const char *uids, int sign) + const char *fname, const char *uids, bool sign) { if (sign) { diff --git a/ncrypt/pgpinvoke.h b/ncrypt/pgpinvoke.h index 11cde68b8..2b3a6e461 100644 --- a/ncrypt/pgpinvoke.h +++ b/ncrypt/pgpinvoke.h @@ -37,7 +37,7 @@ void pgp_class_invoke_getkeys(struct Address *addr); pid_t pgp_invoke_decode (FILE **pgpin, FILE **pgpout, FILE **pgperr, int pgpinfd, int pgpoutfd, int pgperrfd, const char *fname, bool need_passphrase); pid_t pgp_invoke_decrypt (FILE **pgpin, FILE **pgpout, FILE **pgperr, int pgpinfd, int pgpoutfd, int pgperrfd, const char *fname); -pid_t pgp_invoke_encrypt (FILE **pgpin, FILE **pgpout, FILE **pgperr, int pgpinfd, int pgpoutfd, int pgperrfd, const char *fname, const char *uids, int sign); +pid_t pgp_invoke_encrypt (FILE **pgpin, FILE **pgpout, FILE **pgperr, int pgpinfd, int pgpoutfd, int pgperrfd, const char *fname, const char *uids, bool sign); pid_t pgp_invoke_export (FILE **pgpin, FILE **pgpout, FILE **pgperr, int pgpinfd, int pgpoutfd, int pgperrfd, const char *uids); pid_t pgp_invoke_list_keys (FILE **pgpin, FILE **pgpout, FILE **pgperr, int pgpinfd, int pgpoutfd, int pgperrfd, enum PgpRing keyring, struct ListHead *hints); pid_t pgp_invoke_sign (FILE **pgpin, FILE **pgpout, FILE **pgperr, int pgpinfd, int pgpoutfd, int pgperrfd, const char *fname); diff --git a/recvattach.c b/recvattach.c index 684f7b38e..e8511b74d 100644 --- a/recvattach.c +++ b/recvattach.c @@ -899,12 +899,12 @@ static int recvattach_pgp_check_traditional(struct AttachCtx *actx, struct Menu int rc = 0; if (!menu->tagprefix) - rc = crypt_pgp_check_traditional(CURATTACH->fp, CURATTACH->content, 1); + rc = crypt_pgp_check_traditional(CURATTACH->fp, CURATTACH->content, true); else { for (int i = 0; i < actx->idxlen; i++) if (actx->idx[i]->content->tagged) - rc = rc || crypt_pgp_check_traditional(actx->idx[i]->fp, actx->idx[i]->content, 1); + rc = rc || crypt_pgp_check_traditional(actx->idx[i]->fp, actx->idx[i]->content, true); } return rc; -- 2.40.0