summary refs log tree commit diff
path: root/imap.h
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-04-10 14:20:35 -0400
committerJune McEnroe <june@causal.agency>2020-04-10 14:20:35 -0400
commit4d541ff929d0c320c382d6ebd6569c0c7faf8304 (patch)
tree0d15cc5675aedd31ac6d9c2b219ed6b0bb11ef7e /imap.h
parentFix UIDNEXT check and write (diff)
downloadbubger-4d541ff929d0c320c382d6ebd6569c0c7faf8304.tar.gz
bubger-4d541ff929d0c320c382d6ebd6569c0c7faf8304.zip
Refactor main loop state machine
Diffstat (limited to 'imap.h')
-rw-r--r--imap.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/imap.h b/imap.h
index f9b3106..a7b4b64 100644
--- a/imap.h
+++ b/imap.h
@@ -99,6 +99,17 @@ struct Data {
 	};
 };
 
+static inline struct Data dataCheck(struct Data data, enum Type type) {
+	const char *Types[] = { "atom", "number", "string", "list" };
+	if (data.type != type) {
+		errx(
+			EX_PROTOCOL, "expected %s, found %s",
+			Types[type], Types[data.type]
+		);
+	}
+	return data;
+}
+
 static inline void listPush(struct List *list, struct Data data) {
 	if (list->len == list->cap) {
 		list->cap = (list->cap ? list->cap * 2 : 4);