summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--concat.c25
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);
 }
d>Use first word of params in input commandsJune McEnroe 2019-02-23Add C-n and C-p key bindings to switch windowsJune McEnroe 2019-02-23Change example command to join #ascii.town on freenodeJune McEnroe 2019-02-23Call def_prog_mode after termNoFlowJune McEnroe 2019-02-22Move IRC formatting reset to C-sJune McEnroe 2019-02-22Disable terminal flow controlJune McEnroe 2019-02-22Bind up and down arrows to scrollJune McEnroe 2019-02-22Remove topic TODOJune McEnroe 2019-02-22Add /znc commandJune McEnroe 2019-02-22Update status line after scrolling and term eventsJune McEnroe 2019-02-22Reorganize input.cJune McEnroe 2019-02-22Fix name of <raw> window in man pageJune McEnroe 2019-02-22Rename global tags with angle bracketsJune McEnroe 2019-02-22Show status window while connectingJune McEnroe 2019-02-22Reorganize UI code for the umpteenth timeJune McEnroe 2019-02-21Replace "view" with "window"June McEnroe 2019-02-21Remove ROT13June McEnroe 2019-02-21Clean up man pageJune McEnroe 2019-01-26Draw UI before connectingJune McEnroe 2019-01-25Avoid unused variable warnings with getyxJune McEnroe 2019-01-25Add GNU/Linux build instructionsJune McEnroe