From: Richard Russon Date: Tue, 26 Feb 2019 23:44:53 +0000 (+0000) Subject: add typedef for SendFlags X-Git-Tag: 2019-10-25~347^2~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a6c1354f1dba54f1eb125fc6bb51a706b8cefaf3;p=neomutt add typedef for SendFlags --- diff --git a/main.c b/main.c index 3e9f781b2..c6ebb667c 100644 --- a/main.c +++ b/main.c @@ -416,7 +416,7 @@ int main(int argc, char *argv[], char *envp[]) struct ListHead alias_queries = STAILQ_HEAD_INITIALIZER(alias_queries); struct ListHead cc_list = STAILQ_HEAD_INITIALIZER(cc_list); struct ListHead bcc_list = STAILQ_HEAD_INITIALIZER(bcc_list); - int sendflags = 0; + SendFlags sendflags = SEND_NO_FLAGS; int flags = 0; int version = 0; int i; diff --git a/pager.c b/pager.c index 558b2623a..8b59d99ad 100644 --- a/pager.c +++ b/pager.c @@ -3233,9 +3233,10 @@ int mutt_pager(const char *banner, const char *fname, PagerFlags flags, struct P CHECK_MODE(IsEmail(extra) || IsMsgAttach(extra)); CHECK_ATTACH; - int replyflags = SEND_REPLY | (ch == OP_GROUP_REPLY ? SEND_GROUP_REPLY : 0) | - (ch == OP_GROUP_CHAT_REPLY ? SEND_GROUP_CHAT_REPLY : 0) | - (ch == OP_LIST_REPLY ? SEND_LIST_REPLY : 0); + SendFlags replyflags = + SEND_REPLY | (ch == OP_GROUP_REPLY ? SEND_GROUP_REPLY : 0) | + (ch == OP_GROUP_CHAT_REPLY ? SEND_GROUP_CHAT_REPLY : 0) | + (ch == OP_LIST_REPLY ? SEND_LIST_REPLY : 0); if (IsMsgAttach(extra)) mutt_attach_reply(extra->fp, extra->email, extra->actx, extra->body, replyflags); diff --git a/recvattach.c b/recvattach.c index 7bbdd006f..682f232d7 100644 --- a/recvattach.c +++ b/recvattach.c @@ -1320,7 +1320,7 @@ void mutt_view_attachments(struct Email *e) { char helpstr[1024]; struct Body *cur = NULL; - int flags = 0; + SendFlags flags = SEND_NO_FLAGS; int op = OP_NULL; struct Mailbox *m = Context ? Context->mailbox : NULL; diff --git a/recvcmd.c b/recvcmd.c index 2955ad42b..18e82e749 100644 --- a/recvcmd.c +++ b/recvcmd.c @@ -622,7 +622,7 @@ bail: * @param fp File handle to attachment * @param actx Attachment Context * @param cur Attachment to forward (OPTIONAL) - * @param flags Send mode, e.g. #SEND_RESEND + * @param flags Send mode, see #SendFlags * * This is different from the previous function since we want to mimic the * index menu's behavior. @@ -631,7 +631,8 @@ bail: * context structure to find messages, while, on the attachment menu, messages * are referenced through the attachment index. */ -static void attach_forward_msgs(FILE *fp, struct AttachCtx *actx, struct Body *cur, int flags) +static void attach_forward_msgs(FILE *fp, struct AttachCtx *actx, + struct Body *cur, SendFlags flags) { struct Email *e_cur = NULL; struct Email *e_tmp = NULL; @@ -747,10 +748,10 @@ static void attach_forward_msgs(FILE *fp, struct AttachCtx *actx, struct Body *c * @param e Email * @param actx Attachment Context * @param cur Current message - * @param flags Send mode, e.g. #SEND_RESEND + * @param flags Send mode, see #SendFlags */ void mutt_attach_forward(FILE *fp, struct Email *e, struct AttachCtx *actx, - struct Body *cur, int flags) + struct Body *cur, SendFlags flags) { if (check_all_msg(actx, cur, false)) attach_forward_msgs(fp, actx, cur, flags); @@ -770,7 +771,7 @@ void mutt_attach_forward(FILE *fp, struct Email *e, struct AttachCtx *actx, * @param env Envelope to fill in * @param actx Attachment Context * @param parent Parent Email - * @param flags Flags, e.g. #SEND_LIST_REPLY + * @param flags Flags, see #SendFlags * @retval 0 Success * @retval -1 Error * @@ -785,7 +786,7 @@ void mutt_attach_forward(FILE *fp, struct Email *e, struct AttachCtx *actx, * Note that this code is horribly similar to envelope_defaults() from send.c. */ static int attach_reply_envelope_defaults(struct Envelope *env, struct AttachCtx *actx, - struct Email *parent, int flags) + struct Email *parent, SendFlags flags) { struct Envelope *curenv = NULL; struct Email *e = NULL; @@ -899,10 +900,10 @@ static void attach_include_reply(FILE *fp, FILE *tmpfp, struct Email *cur) * @param e Email * @param actx Attachment Context * @param cur Current message - * @param flags Send mode, e.g. #SEND_RESEND + * @param flags Send mode, see #SendFlags */ void mutt_attach_reply(FILE *fp, struct Email *e, struct AttachCtx *actx, - struct Body *cur, int flags) + struct Body *cur, SendFlags flags) { bool mime_reply_any = false; diff --git a/send.c b/send.c index 95f9c7312..0c9c82e8c 100644 --- a/send.c +++ b/send.c @@ -261,11 +261,11 @@ static int edit_address(struct Address **a, const char *field) /** * edit_envelope - Edit Envelope fields * @param en Envelope to edit - * @param flags Flags, e.g. #SEND_LIST_REPLY + * @param flags Flags, see #SendFlags * @retval 0 Success * @retval -1 Failure */ -static int edit_envelope(struct Envelope *en, int flags) +static int edit_envelope(struct Envelope *en, SendFlags flags) { char buf[8192]; @@ -610,12 +610,12 @@ static int include_reply(struct Mailbox *m, struct Email *e, FILE *out) * default_to - Generate default email addresses * @param[out] to 'To' address * @param[in] env Envelope to populate - * @param[in] flags Flags, e.g. #SEND_LIST_REPLY + * @param[in] flags Flags, see #SendFlags * @param[in] hmfupto If true, add 'followup-to' address to 'to' address * @retval 0 Success * @retval -1 Aborted */ -static int default_to(struct Address **to, struct Envelope *env, int flags, int hmfupto) +static int default_to(struct Address **to, struct Envelope *env, SendFlags flags, int hmfupto) { char prompt[256]; @@ -692,11 +692,11 @@ static int default_to(struct Address **to, struct Envelope *env, int flags, int * mutt_fetch_recips - Generate recpients for a reply email * @param out Envelope to populate * @param in Envelope of source email - * @param flags Flags, e.g. SEND_LIST_REPLY + * @param flags Flags, see #SendFlags * @retval 0 Success * @retval -1 Failure */ -int mutt_fetch_recips(struct Envelope *out, struct Envelope *in, int flags) +int mutt_fetch_recips(struct Envelope *out, struct Envelope *in, SendFlags flags) { struct Address *tmp = NULL; int hmfupto = -1; @@ -900,12 +900,12 @@ static void make_reference_headers(struct EmailList *el, struct Envelope *env) * @param env Envelope for result * @param m Mailbox * @param el List of Emails to use - * @param flags Flags, e.g. #SEND_REPLY + * @param flags Flags, see #SendFlags * @retval 0 Success * @retval -1 Failure */ static int envelope_defaults(struct Envelope *env, struct Mailbox *m, - struct EmailList *el, int flags) + struct EmailList *el, SendFlags flags) { if (!el || STAILQ_EMPTY(el)) return -1; @@ -968,13 +968,13 @@ static int envelope_defaults(struct Envelope *env, struct Mailbox *m, * generate_body - Create a new email body * @param tempfp Stream for outgoing message * @param msg Header for outgoing message - * @param flags Compose mode + * @param flags Compose mode, see #SendFlags * @param m Mailbox * @param el List of Emails to use * @retval 0 Success * @retval -1 Error */ -static int generate_body(FILE *tempfp, struct Email *msg, int flags, +static int generate_body(FILE *tempfp, struct Email *msg, SendFlags flags, struct Mailbox *m, struct EmailList *el) { int i; @@ -1466,13 +1466,13 @@ static bool search_attach_keyword(char *filename) * @param[in] fcc_len Length of fcc buffer * @param[in] clear_content Cleartext content of Email * @param[in] pgpkeylist List of pgp keys - * @param[in] flags Send mode, e.g. #SEND_RESEND + * @param[in] flags Send mode, see #SendFlags * @param[out] finalpath Path of final folder * @retval 0 Success * @retval -1 Error */ static int save_fcc(struct Email *msg, char *fcc, size_t fcc_len, struct Body *clear_content, - char *pgpkeylist, int flags, char **finalpath) + char *pgpkeylist, SendFlags flags, char **finalpath) { int rc = 0; struct Body *save_content = NULL; @@ -1632,11 +1632,11 @@ full_fcc: * @param msg Email to postpone * @param cur Current Email in the index * @param fcc Folder for 'sent mail' - * @param flags Send mode, e.g. #SEND_RESEND + * @param flags Send mode, see #SendFlags * @retval 0 Success * @retval -1 Error */ -static int postpone_message(struct Email *msg, struct Email *cur, char *fcc, int flags) +static int postpone_message(struct Email *msg, struct Email *cur, char *fcc, SendFlags flags) { char *pgpkeylist = NULL; char *encrypt_as = NULL; @@ -1724,16 +1724,16 @@ static int postpone_message(struct Email *msg, struct Email *cur, char *fcc, int /** * ci_send_message - Send an email - * @param flags send mode, e.g. #SEND_RESEND - * @param msg template to use for new message - * @param tempfile file specified by -i or -H - * @param ctx current mailbox + * @param flags Send mode, see #SendFlags + * @param msg Template to use for new message + * @param tempfile File specified by -i or -H + * @param ctx Current mailbox * @param el List of Emails to send * @retval 0 Message was successfully sent * @retval -1 Message was aborted or an error occurred * @retval 1 Message was postponed */ -int ci_send_message(int flags, struct Email *msg, const char *tempfile, +int ci_send_message(SendFlags flags, struct Email *msg, const char *tempfile, struct Context *ctx, struct EmailList *el) { char buf[1024]; @@ -1803,12 +1803,13 @@ int ci_send_message(int flags, struct Email *msg, const char *tempfile, if (flags == SEND_POSTPONED) { - flags = mutt_get_postponed(ctx, msg, &cur, fcc, sizeof(fcc)); - if (flags < 0) + rc = mutt_get_postponed(ctx, msg, &cur, fcc, sizeof(fcc)); + if (rc < 0) { flags = SEND_POSTPONED; goto cleanup; } + flags = rc; #ifdef USE_NNTP /* If postponed message is a news article, it have * a "Newsgroups:" header line, then set appropriate flag. diff --git a/send.h b/send.h index 15c761357..cedc4b1e4 100644 --- a/send.h +++ b/send.h @@ -80,7 +80,8 @@ extern char * C_Signature; extern bool C_SigOnTop; extern bool C_UseFrom; -/* flags to ci_send_message() */ +typedef uint16_t SendFlags; ///< Flags for ci_send_message(), e.g. #SEND_REPLY +#define SEND_NO_FLAGS 0 ///< No flags are set #define SEND_REPLY (1 << 0) ///< Reply to sender #define SEND_GROUP_REPLY (1 << 1) ///< Reply to all #define SEND_LIST_REPLY (1 << 2) ///< Reply to mailing list @@ -97,11 +98,11 @@ extern bool C_UseFrom; #define SEND_GROUP_CHAT_REPLY (1 << 13) ///< Reply to all recipients preserving To/Cc #define SEND_NEWS (1 << 14) ///< Reply to a news article -int ci_send_message(int flags, struct Email *msg, const char *tempfile, struct Context *ctx, struct EmailList *el); +int ci_send_message(SendFlags flags, struct Email *msg, const char *tempfile, struct Context *ctx, struct EmailList *el); void mutt_add_to_reference_headers(struct Envelope *env, struct Envelope *curenv); struct Address *mutt_default_from(void); void mutt_encode_descriptions(struct Body *b, bool recurse); -int mutt_fetch_recips(struct Envelope *out, struct Envelope *in, int flags); +int mutt_fetch_recips(struct Envelope *out, struct Envelope *in, SendFlags flags); void mutt_fix_reply_recipients(struct Envelope *env); void mutt_forward_intro(struct Mailbox *m, struct Email *e, FILE *fp); void mutt_forward_trailer(struct Mailbox *m, struct Email *e, FILE *fp);