8 * iterated over all of the items in the message set.
9 * errors are accumulated, but processing continues.
10 * if uids, then ignore non-existent messages.
11 * otherwise, that's an error
14 forMsgs(Box *box, MsgSet *ms, ulong max, int uids, int (*f)(Box*, Msg*, int, void*), void *rock)
21 for(; ms != nil; ms = ms->next){
24 for(m = box->msgs; m != nil && m->seq <= max; m = m->next){
25 if(!uids && m->seq > id
26 || uids && m->uid > ms->to)
28 if(!uids && m->seq == id
29 || uids && m->uid >= id){
30 if(!(*f)(box, m, uids, rock))
50 mkStore(int sign, int op, int flags)
54 st = binalloc(&parseBin, sizeof(Store), 1);
56 parseErr("out of memory");
64 mkFetch(int op, Fetch *next)
68 f = binalloc(&parseBin, sizeof(Fetch), 1);
70 parseErr("out of memory");
82 for(; f != nil; f = next){
91 mkNList(ulong n, NList *next)
95 nl = binalloc(&parseBin, sizeof(NList), 0);
97 parseErr("out of memory");
109 for(; nl != nil; nl = next){
118 mkSList(char *s, SList *next)
122 sl = binalloc(&parseBin, sizeof(SList), 0);
124 parseErr("out of memory");
136 for(; sl != nil; sl = next){
145 BNList(Biobuf *b, NList *nl, char *sep)
152 for(; nl != nil; nl = nl->next){
153 n += Bprint(b, "%s%lud", s, nl->n);
160 BSList(Biobuf *b, SList *sl, char *sep)
167 for(; sl != nil; sl = sl->next){
168 n += Bprint(b, "%s", s);
169 n += Bimapstr(b, sl->s);
176 Bimapdate(Biobuf *b, Tm *tm)
181 tm = localtime(time(nil));
182 imap4date(buf, sizeof(buf), tm);
183 return Bimapstr(b, buf);
187 Brfc822date(Biobuf *b, Tm *tm)
192 tm = localtime(time(nil));
193 rfc822date(buf, sizeof(buf), tm);
194 return Bimapstr(b, buf);
198 Bimapstr(Biobuf *b, char *s)
204 return Bprint(b, "NIL");
208 return Bprint(b, "\"%s\"", s);
209 if(t - s > 64 || c >= 0x7f || strchr("\"\\\r\n", c) != nil)
212 return Bprint(b, "{%lud}\r\n%s", strlen(s), s);