From: Richard Russon Date: Sat, 2 Mar 2019 12:15:56 +0000 (+0000) Subject: add typedef for AclFlags X-Git-Tag: 2019-10-25~346^2~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2f5a75b9fa5e729a25c6046cce65d0b8b187d1b1;p=neomutt add typedef for AclFlags --- diff --git a/imap/imap.c b/imap/imap.c index 1117e8218..2b4d50999 100644 --- a/imap/imap.c +++ b/imap/imap.c @@ -154,14 +154,14 @@ static char *get_flags(struct ListHead *hflags, char *s) /** * set_flag - append str to flags if we currently have permission according to aclflag * @param[in] m Selected Imap Mailbox - * @param[in] aclflag Permissions, e.g. #MUTT_ACL_WRITE + * @param[in] aclflag Permissions, see #AclFlags * @param[in] flag Does the email have the flag set? * @param[in] str Server flag name * @param[out] flags Buffer for server command * @param[in] flsize Length of buffer */ -static void set_flag(struct Mailbox *m, int aclflag, int flag, const char *str, - char *flags, size_t flsize) +static void set_flag(struct Mailbox *m, AclFlags aclflag, int flag, + const char *str, char *flags, size_t flsize) { if (m->rights & aclflag) if (flag && imap_has_flag(&imap_mdata_get(m)->flags, str)) @@ -294,13 +294,13 @@ static bool compare_flags_for_copy(struct Email *e) /** * sync_helper - Sync flag changes to the server * @param m Selected Imap Mailbox - * @param right ACL, e.g. #MUTT_ACL_DELETE + * @param right ACL, see #AclFlags * @param flag Mutt flag, e.g. MUTT_DELETED * @param name Name of server flag * @retval >=0 Success, number of messages * @retval -1 Failure */ -static int sync_helper(struct Mailbox *m, int right, int flag, const char *name) +static int sync_helper(struct Mailbox *m, AclFlags right, int flag, const char *name) { int count = 0; int rc; diff --git a/index.c b/index.c index daf9622e3..67e43b835 100644 --- a/index.c +++ b/index.c @@ -206,11 +206,11 @@ static bool prereq(struct Context *ctx, struct Menu *menu, CheckFlags checks) /** * check_acl - Check the ACLs for a function * @param ctx Mailbox - * @param acl ACL, e.g. #MUTT_ACL_DELETE + * @param acl ACL, see #AclFlags * @param msg Error message for failure * @retval bool true if the function is permitted */ -static bool check_acl(struct Context *ctx, int acl, const char *msg) +static bool check_acl(struct Context *ctx, AclFlags acl, const char *msg) { if (!ctx || !ctx->mailbox) return false; @@ -2881,7 +2881,7 @@ int mutt_index_menu(void) { if (!prereq(Context, menu, CHECK_IN_MAILBOX | CHECK_MSGCOUNT | CHECK_VISIBLE | CHECK_READONLY)) break; - /* CHECK_ACL(MUTT_ACL_WRITE); */ + /* check_acl(MUTT_ACL_WRITE); */ struct EmailList el = STAILQ_HEAD_INITIALIZER(el); el_add_tagged(&el, Context, CUR_EMAIL, tag); diff --git a/mailbox.h b/mailbox.h index 0c6235fdd..95b8a11fd 100644 --- a/mailbox.h +++ b/mailbox.h @@ -60,17 +60,19 @@ enum MailboxNotification /** * ACL Rights - These show permission to... */ -#define MUTT_ACL_ADMIN (1 << 0) ///< administer the account (get/set permissions) -#define MUTT_ACL_CREATE (1 << 1) ///< create a mailbox -#define MUTT_ACL_DELETE (1 << 2) ///< delete a message -#define MUTT_ACL_DELMX (1 << 3) ///< delete a mailbox -#define MUTT_ACL_EXPUNGE (1 << 4) ///< expunge messages -#define MUTT_ACL_INSERT (1 << 5) ///< add/copy into the mailbox (used when editing a message) -#define MUTT_ACL_LOOKUP (1 << 6) ///< lookup mailbox (visible to 'list') -#define MUTT_ACL_POST (1 << 7) ///< post (submit messages to the server) -#define MUTT_ACL_READ (1 << 8) ///< read the mailbox -#define MUTT_ACL_SEEN (1 << 9) ///< change the 'seen' status of a message -#define MUTT_ACL_WRITE (1 << 10) ///< write to a message (for flagging or linking threads) +typedef uint16_t AclFlags; ///< Flags, e.g. #MUTT_ACL_ADMIN +#define MUTT_ACL_NO_FLAGS 0 ///< No flags are set +#define MUTT_ACL_ADMIN (1 << 0) ///< Administer the account (get/set permissions) +#define MUTT_ACL_CREATE (1 << 1) ///< Create a mailbox +#define MUTT_ACL_DELETE (1 << 2) ///< Delete a message +#define MUTT_ACL_DELMX (1 << 3) ///< Delete a mailbox +#define MUTT_ACL_EXPUNGE (1 << 4) ///< Expunge messages +#define MUTT_ACL_INSERT (1 << 5) ///< Add/copy into the mailbox (used when editing a message) +#define MUTT_ACL_LOOKUP (1 << 6) ///< Lookup mailbox (visible to 'list') +#define MUTT_ACL_POST (1 << 7) ///< Post (submit messages to the server) +#define MUTT_ACL_READ (1 << 8) ///< Read the mailbox +#define MUTT_ACL_SEEN (1 << 9) ///< Change the 'seen' status of a message +#define MUTT_ACL_WRITE (1 << 10) ///< Write to a message (for flagging or linking threads) #define MUTT_ACL_ALL ((1 << 11) - 1) @@ -116,7 +118,7 @@ struct Mailbox bool quiet : 1; /**< inhibit status messages? */ bool readonly : 1; /**< don't allow changes to the mailbox */ - unsigned int rights; /**< ACL bits */ + AclFlags rights; /**< ACL bits, see #AclFlags */ #ifdef USE_COMPRESSED void *compress_info; /**< compressed mbox module private data */