1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203
|
/*
** seq_msgstats -- message and sequence manipulation and folder attributes
**
** (These functions had once been macros in h/mh.h)
*/
#include <sysexits.h>
#include <h/mh.h>
static void
assert_msg_range(struct msgs *mp, int msgnum)
{
if (msgnum < mp->lowoff || msgnum > mp->hghoff) {
adios(EX_SOFTWARE, NULL, "Bug: message out of bounds");
}
}
void
add_sequence(struct msgs *mp, int seqnum, int msgnum)
{
assert_msg_range(mp, msgnum);
mp->msgstats[msgnum - mp->lowoff] |= (1 << (FFATTRSLOT + seqnum));
}
void
clear_msg_flags(struct msgs *mp, int msgnum)
{
assert_msg_range(mp, msgnum);
mp->msgstats[msgnum - mp->lowoff] = 0;
}
void
clear_sequence(struct msgs *mp, int seqnum, int msgnum)
{
assert_msg_range(mp, msgnum);
mp->msgstats[msgnum - mp->lowoff] &= ~(1 << (FFATTRSLOT + seqnum));
}
void
copy_msg_flags(struct msgs *mp, int dstmsg, int srcmsg)
{
assert_msg_range(mp, srcmsg);
assert_msg_range(mp, dstmsg);
mp->msgstats[dstmsg - mp->lowoff] = mp->msgstats[srcmsg - mp->lowoff];
}
seqset_t
does_exist(struct msgs *mp, int msgnum)
{
assert_msg_range(mp, msgnum);
return mp->msgstats[msgnum - mp->lowoff] & EXISTS;
}
void
get_msg_flags(struct msgs *mp, seqset_t *dst, int msgnum)
{
assert_msg_range(mp, msgnum);
*dst = mp->msgstats[msgnum - mp->lowoff];
}
seqset_t
in_sequence(struct msgs *mp, int seqnum, int msgnum)
{
assert_msg_range(mp, msgnum);
return mp->msgstats[msgnum - mp->lowoff] & (1 << (FFATTRSLOT + seqnum));
}
seqset_t
is_selected(struct msgs *mp, int msgnum)
{
assert_msg_range(mp, msgnum);
return mp->msgstats[msgnum - mp->lowoff] & SELECTED;
}
seqset_t
is_unseen(struct msgs *mp, int msgnum)
{
assert_msg_range(mp, msgnum);
return mp->msgstats[msgnum - mp->lowoff] & SELECT_UNSEEN;
}
void
set_exists(struct msgs *mp, int msgnum)
{
assert_msg_range(mp, msgnum);
mp->msgstats[msgnum - mp->lowoff] |= EXISTS;
}
void
set_msg_flags(struct msgs *mp, seqset_t *src, int msgnum)
{
assert_msg_range(mp, msgnum);
mp->msgstats[msgnum - mp->lowoff] = *src;
}
void
set_selected(struct msgs *mp, int msgnum)
{
assert_msg_range(mp, msgnum);
if (is_selected(mp, msgnum)) {
return;
}
mp->msgstats[msgnum - mp->lowoff] |= SELECTED;
if (mp->lowsel == 0 || msgnum < mp->lowsel) {
mp->lowsel = msgnum;
}
if (msgnum > mp->hghsel) {
mp->hghsel = msgnum;
}
mp->numsel++;
}
void
set_unseen(struct msgs *mp, int msgnum)
{
assert_msg_range(mp, msgnum);
mp->msgstats[msgnum - mp->lowoff] |= SELECT_UNSEEN;
}
void
unset_exists(struct msgs *mp, int msgnum)
{
assert_msg_range(mp, msgnum);
mp->msgstats[msgnum - mp->lowoff] &= ~EXISTS;
}
void
unset_selected(struct msgs *mp, int msgnum)
{
assert_msg_range(mp, msgnum);
if (!is_selected(mp, msgnum)) {
return;
}
mp->msgstats[msgnum - mp->lowoff] &= ~SELECTED;
if (mp->numsel > 0) {
mp->numsel--;
}
}
/*
** private/public sequences
*/
int
is_seq_private(struct msgs *mp, int seqnum)
{
return mp->attrstats & (1 << (FFATTRSLOT + seqnum));
}
void
make_seq_public(struct msgs *mp, int seqnum)
{
mp->attrstats &= ~(1 << (FFATTRSLOT + seqnum));
}
void
make_seq_private(struct msgs *mp, int seqnum)
{
mp->attrstats |= (1 << (FFATTRSLOT + seqnum));
}
void
make_all_public(struct msgs *mp)
{
mp->attrstats = 0;
}
/*
** folder attributes
*/
void
clear_folder_flags(struct msgs *mp)
{
mp->msgflags = 0;
}
int
is_readonly(struct msgs *mp)
{
return mp->msgflags & READONLY;
}
void
set_readonly(struct msgs *mp)
{
mp->msgflags |= READONLY;
}
int
other_files(struct msgs *mp)
{
return mp->msgflags & OTHERS;
}
void
set_other_files(struct msgs *mp)
{
mp->msgflags |= OTHERS;
}
|