diff options
Diffstat (limited to '')
-rw-r--r-- | concat.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/concat.c b/concat.c index 9ad8537..26f24f6 100644 --- a/concat.c +++ b/concat.c @@ -33,6 +33,14 @@ static uint32_t threadRoot(struct List thread) { return dataCheck(thread.ptr[0], Number).number; } +static struct List threadFind(struct List threads, uint32_t root) { + for (size_t i = 0; i < threads.len; ++i) { + struct List thread = dataCheck(threads.ptr[i], List).list; + if (threadRoot(thread) == root) return thread; + } + errx(EX_TEMPFAIL, "no thread with root UID %" PRIu32, root); +} + void concatFetch(FILE *imap, enum Atom tag, struct List threads) { fprintf(imap, "%s UID FETCH ", Atoms[tag]); for (size_t i = 0; i < threads.len; ++i) { @@ -43,4 +51,21 @@ void concatFetch(FILE *imap, enum Atom tag, struct List threads) { } void concatData(struct List threads, struct List items) { + uint32_t uid = 0; + struct Envelope envelope = {0}; + for (size_t i = 0; i + 1 < items.len; i += 2) { + enum Atom name = dataCheck(items.ptr[i], Atom).atom; + struct Data data = items.ptr[i + 1]; + switch (name) { + break; case AtomUID: + uid = dataCheck(data, Number).number; + break; case AtomEnvelope: + parseEnvelope(&envelope, dataCheck(data, List).list); + break; default:; + } + } + if (!uid) errx(EX_PROTOCOL, "missing UID data item"); + if (!envelope.subject) errx(EX_PROTOCOL, "missing ENVELOPE data item"); + + struct List thread = threadFind(threads, uid); } |