{
case MUTT_DELETE:
- if (!mutt_bit_isset(m->rights, MUTT_ACL_DELETE))
+ if (!(m->rights & MUTT_ACL_DELETE))
return;
if (bf)
case MUTT_PURGE:
- if (!mutt_bit_isset(m->rights, MUTT_ACL_DELETE))
+ if (!(m->rights & MUTT_ACL_DELETE))
return;
if (bf)
case MUTT_NEW:
- if (!mutt_bit_isset(m->rights, MUTT_ACL_SEEN))
+ if (!(m->rights & MUTT_ACL_SEEN))
return;
if (bf)
case MUTT_OLD:
- if (!mutt_bit_isset(m->rights, MUTT_ACL_SEEN))
+ if (!(m->rights & MUTT_ACL_SEEN))
return;
if (bf)
case MUTT_READ:
- if (!mutt_bit_isset(m->rights, MUTT_ACL_SEEN))
+ if (!(m->rights & MUTT_ACL_SEEN))
return;
if (bf)
case MUTT_REPLIED:
- if (!mutt_bit_isset(m->rights, MUTT_ACL_WRITE))
+ if (!(m->rights & MUTT_ACL_WRITE))
return;
if (bf)
case MUTT_FLAG:
- if (!mutt_bit_isset(m->rights, MUTT_ACL_WRITE))
+ if (!(m->rights & MUTT_ACL_WRITE))
return;
if (bf)
s = imap_next_word((char *) s);
/* zero out current rights set */
- memset(adata->mailbox->rights, 0, sizeof(adata->mailbox->rights));
+ adata->mailbox->rights = 0;
while (*s && !isspace((unsigned char) *s))
{
switch (*s)
{
case 'a':
- mutt_bit_set(adata->mailbox->rights, MUTT_ACL_ADMIN);
+ adata->mailbox->rights |= MUTT_ACL_ADMIN;
break;
case 'e':
- mutt_bit_set(adata->mailbox->rights, MUTT_ACL_EXPUNGE);
+ adata->mailbox->rights |= MUTT_ACL_EXPUNGE;
break;
case 'i':
- mutt_bit_set(adata->mailbox->rights, MUTT_ACL_INSERT);
+ adata->mailbox->rights |= MUTT_ACL_INSERT;
break;
case 'k':
- mutt_bit_set(adata->mailbox->rights, MUTT_ACL_CREATE);
+ adata->mailbox->rights |= MUTT_ACL_CREATE;
break;
case 'l':
- mutt_bit_set(adata->mailbox->rights, MUTT_ACL_LOOKUP);
+ adata->mailbox->rights |= MUTT_ACL_LOOKUP;
break;
case 'p':
- mutt_bit_set(adata->mailbox->rights, MUTT_ACL_POST);
+ adata->mailbox->rights |= MUTT_ACL_POST;
break;
case 'r':
- mutt_bit_set(adata->mailbox->rights, MUTT_ACL_READ);
+ adata->mailbox->rights |= MUTT_ACL_READ;
break;
case 's':
- mutt_bit_set(adata->mailbox->rights, MUTT_ACL_SEEN);
+ adata->mailbox->rights |= MUTT_ACL_SEEN;
break;
case 't':
- mutt_bit_set(adata->mailbox->rights, MUTT_ACL_DELETE);
+ adata->mailbox->rights |= MUTT_ACL_DELETE;
break;
case 'w':
- mutt_bit_set(adata->mailbox->rights, MUTT_ACL_WRITE);
+ adata->mailbox->rights |= MUTT_ACL_WRITE;
break;
case 'x':
- mutt_bit_set(adata->mailbox->rights, MUTT_ACL_DELMX);
+ adata->mailbox->rights |= MUTT_ACL_DELMX;
break;
/* obsolete rights */
case 'c':
- mutt_bit_set(adata->mailbox->rights, MUTT_ACL_CREATE);
- mutt_bit_set(adata->mailbox->rights, MUTT_ACL_DELMX);
+ adata->mailbox->rights |= MUTT_ACL_CREATE | MUTT_ACL_DELMX;
break;
case 'd':
- mutt_bit_set(adata->mailbox->rights, MUTT_ACL_DELETE);
- mutt_bit_set(adata->mailbox->rights, MUTT_ACL_EXPUNGE);
+ adata->mailbox->rights |= MUTT_ACL_DELETE | MUTT_ACL_EXPUNGE;
break;
default:
mutt_debug(1, "Unknown right: %c\n", *s);
}
/**
- * set_flag - append str to flags if we currently have permission according to aclbit
- * @param[in] m Selected Imap Mailbox
- * @param[in] aclbit Permissions, e.g. #MUTT_ACL_WRITE
- * @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
+ * 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] 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 aclbit, int flag, const char *str,
+static void set_flag(struct Mailbox *m, int aclflag, int flag, const char *str,
char *flags, size_t flsize)
{
- if (mutt_bit_isset(m->rights, aclbit))
+ if (m->rights & aclflag)
if (flag && imap_has_flag(&imap_mdata_get(m)->flags, str))
mutt_str_strcat(flags, flsize, str);
}
if (!m)
return -1;
- if (!mutt_bit_isset(m->rights, right))
+ if ((m->rights & right) == 0)
return 0;
if (right == MUTT_ACL_WRITE && !imap_has_flag(&imap_mdata_get(m)->flags, name))
set_flag(m, MUTT_ACL_DELETE, imap_edata_get(e)->deleted, "\\Deleted ", flags,
sizeof(flags));
- if (mutt_bit_isset(m->rights, MUTT_ACL_WRITE))
+ if (m->rights & MUTT_ACL_WRITE)
{
/* restore system flags */
if (imap_edata_get(e)->flags_system)
flags, sizeof(flags));
/* erase custom flags */
- if (mutt_bit_isset(m->rights, MUTT_ACL_WRITE) && imap_edata_get(e)->flags_remote)
+ if ((m->rights & MUTT_ACL_WRITE) && imap_edata_get(e)->flags_remote)
mutt_str_strcat(flags, sizeof(flags), imap_edata_get(e)->flags_remote);
mutt_str_remove_trailing_ws(flags);
return rc;
/* if we are expunging anyway, we can do deleted messages very quickly... */
- if (expunge && mutt_bit_isset(m->rights, MUTT_ACL_DELETE))
+ if (expunge && (m->rights & MUTT_ACL_DELETE))
{
rc = imap_exec_msgset(m, "UID STORE", "+FLAGS.SILENT (\\Deleted)",
MUTT_DELETED, true, false);
m->changed = false;
/* We must send an EXPUNGE command if we're not closing. */
- if (expunge && !close && mutt_bit_isset(m->rights, MUTT_ACL_DELETE))
+ if (expunge && !close && (m->rights & MUTT_ACL_DELETE))
{
mutt_message(_("Expunging messages from server..."));
/* Set expunge bit so we don't get spurious reopened messages */
/* clear mailbox status */
adata->status = 0;
- memset(m->rights, 0, sizeof(m->rights));
+ m->rights = 0;
mdata->new_mail_count = 0;
mutt_message(_("Selecting %s..."), mdata->name);
/* assume we have all rights if ACL is unavailable */
else
{
- mutt_bit_set(m->rights, MUTT_ACL_LOOKUP);
- mutt_bit_set(m->rights, MUTT_ACL_READ);
- mutt_bit_set(m->rights, MUTT_ACL_SEEN);
- mutt_bit_set(m->rights, MUTT_ACL_WRITE);
- mutt_bit_set(m->rights, MUTT_ACL_INSERT);
- mutt_bit_set(m->rights, MUTT_ACL_POST);
- mutt_bit_set(m->rights, MUTT_ACL_CREATE);
- mutt_bit_set(m->rights, MUTT_ACL_DELETE);
+ m->rights |= MUTT_ACL_LOOKUP | MUTT_ACL_READ | MUTT_ACL_SEEN | MUTT_ACL_WRITE |
+ MUTT_ACL_INSERT | MUTT_ACL_POST | MUTT_ACL_CREATE | MUTT_ACL_DELETE;
}
/* pipeline the postponed count if possible */
}
}
- if (!(mutt_bit_isset(m->rights, MUTT_ACL_DELETE) ||
- mutt_bit_isset(m->rights, MUTT_ACL_SEEN) || mutt_bit_isset(m->rights, MUTT_ACL_WRITE) ||
- mutt_bit_isset(m->rights, MUTT_ACL_INSERT)))
+ if (!((m->rights & MUTT_ACL_DELETE) || (m->rights & MUTT_ACL_SEEN) ||
+ (m->rights & MUTT_ACL_WRITE) || (m->rights & MUTT_ACL_INSERT)))
{
m->readonly = true;
}
if (*buf == '\0')
buf = NULL;
- if (!mutt_bit_isset(adata->mailbox->rights, MUTT_ACL_WRITE))
+ if (!(adata->mailbox->rights & MUTT_ACL_WRITE))
return 0;
snprintf(uid, sizeof(uid), "%u", imap_edata_get(e)->uid);
}
#define CHECK_ACL(aclbit, action) \
- if (!mutt_bit_isset(Context->mailbox->rights, aclbit)) \
+ if (!(Context->mailbox->rights & aclbit)) \
{ \
mutt_flushinp(); \
/* L10N: %s is one of the CHECK_ACL entries below. */ \
edit = true;
}
else if (op == OP_EDIT_OR_VIEW_RAW_MESSAGE)
- edit = !Context->mailbox->readonly &&
- mutt_bit_isset(Context->mailbox->rights, MUTT_ACL_INSERT);
+ edit = !Context->mailbox->readonly && (Context->mailbox->rights & MUTT_ACL_INSERT);
else
edit = false;
};
/**
- * enum AclRights - ACL Rights
- *
- * These show permission to...
+ * ACL Rights - These show permission to...
*/
-enum AclRights
-{
- MUTT_ACL_ADMIN = 0, ///< administer the account (get/set permissions)
- MUTT_ACL_CREATE, ///< create a mailbox
- MUTT_ACL_DELETE, ///< delete a message
- MUTT_ACL_DELMX, ///< delete a mailbox
- MUTT_ACL_EXPUNGE, ///< expunge messages
- MUTT_ACL_INSERT, ///< add/copy into the mailbox (used when editing a message)
- MUTT_ACL_LOOKUP, ///< lookup mailbox (visible to 'list')
- MUTT_ACL_POST, ///< post (submit messages to the server)
- MUTT_ACL_READ, ///< read the mailbox
- MUTT_ACL_SEEN, ///< change the 'seen' status of a message
- MUTT_ACL_WRITE, ///< write to a message (for flagging, or linking threads)
- MUTT_ACL_MAX,
-};
+#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)
/**
* struct Mailbox - A mailbox
bool quiet : 1; /**< inhibit status messages? */
bool readonly : 1; /**< don't allow changes to the mailbox */
- unsigned char rights[(MUTT_ACL_MAX + 7) / 8]; /**< ACL bits */
+ unsigned int rights; /**< ACL bits */
#ifdef USE_COMPRESSED
void *compress_info; /**< compressed mbox module private data */
m->msg_unread = 0;
m->msg_flagged = 0;
-
- for (int i = 0; i < MUTT_ACL_MAX; i++)
- mutt_bit_set(m->rights, i);
+ m->rights = MUTT_ACL_ALL;
if (flags & MUTT_QUIET)
m->quiet = true;
return -1;
}
- mutt_bit_unset(m->rights, MUTT_ACL_INSERT);
+ m->rights &= ~MUTT_ACL_INSERT; // Clear the flag
if (!mdata->newsrc_ent && !mdata->subscribed && !SaveUnsubscribed)
m->readonly = true;
nntp_hcache_update(mdata, hc);
#endif
if (!hc)
- {
- mutt_bit_unset(m->rights, MUTT_ACL_WRITE);
- mutt_bit_unset(m->rights, MUTT_ACL_DELETE);
- }
+ m->rights &= ~(MUTT_ACL_WRITE | MUTT_ACL_DELETE); // Clear the flags
+
nntp_newsrc_close(adata);
rc = nntp_fetch_headers(m, hc, first, mdata->last_message, false);
#ifdef USE_HCACHE
}
#define CHECK_ACL(aclbit, action) \
- if (!Context || !mutt_bit_isset(Context->mailbox->rights, aclbit)) \
+ if (!Context || !(Context->mailbox->rights & aclbit)) \
{ \
mutt_flushinp(); \
/* L10N: %s is one of the CHECK_ACL entries below. */ \
adata->bcache = mutt_bcache_open(&acct, NULL);
/* init (hard-coded) ACL rights */
- memset(m->rights, 0, sizeof(m->rights));
- mutt_bit_set(m->rights, MUTT_ACL_SEEN);
- mutt_bit_set(m->rights, MUTT_ACL_DELETE);
+ m->rights = MUTT_ACL_SEEN | MUTT_ACL_DELETE;
#ifdef USE_HCACHE
/* flags are managed using header cache, so it only makes sense to
* enable them in that case */
- mutt_bit_set(m->rights, MUTT_ACL_WRITE);
+ m->rights |= MUTT_ACL_WRITE;
#endif
while (true)