summary refs log tree commit diff
path: root/archive.h
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-04-12 14:09:34 -0400
committerJune McEnroe <june@causal.agency>2020-04-12 14:13:43 -0400
commit0583e4c0c36ac3ebd4479c674ebd1dd0d5e8fe0d (patch)
treeeddd00889239bf88eb495d1f31fa735257f9f320 /archive.h
parentDo not use <h1> for subject lines (diff)
downloadbubger-0583e4c0c36ac3ebd4479c674ebd1dd0d5e8fe0d.tar.gz
bubger-0583e4c0c36ac3ebd4479c674ebd1dd0d5e8fe0d.zip
Fetch and parse BODYSTRUCTURE
Diffstat (limited to '')
-rw-r--r--archive.h51
1 files changed, 50 insertions, 1 deletions
diff --git a/archive.h b/archive.h
index 85428fe..820ca37 100644
--- a/archive.h
+++ b/archive.h
@@ -64,10 +64,59 @@ static inline void envelopeFree(struct Envelope envelope) {
 	free(envelope.bcc.addrs);
 }
 
+struct BodyPart {
+	bool multipart;
+	union {
+		const char *type;
+		struct {
+			size_t len;
+			struct BodyPart *ptr;
+		} parts;
+	};
+	const char *subtype;
+	struct List params;
+	const char *id;
+	const char *description;
+	const char *encoding;
+	uint32_t size;
+	struct {
+		struct Envelope *envelope;
+		struct BodyPart *structure;
+		uint32_t lines;
+	} message;
+	struct {
+		uint32_t lines;
+	} text;
+	const char *md5;
+	struct {
+		const char *type;
+		struct List params;
+	} disposition;
+	struct List language;
+	struct List location;
+};
+
+static inline void bodyPartFree(struct BodyPart part) {
+	if (part.multipart) {
+		for (size_t i = 0; i < part.parts.len; ++i) {
+			bodyPartFree(part.parts.ptr[i]);
+		}
+	}
+	if (part.message.envelope) {
+		envelopeFree(*part.message.envelope);
+		free(part.message.envelope);
+	}
+	if (part.message.structure) {
+		bodyPartFree(*part.message.structure);
+		free(part.message.structure);
+	}
+}
+
 void parseEnvelope(struct Envelope *envelope, struct List list);
+void parseBodyPart(struct BodyPart *part, struct List list);
 
 bool exportFetch(FILE *imap, enum Atom tag, struct List threads);
-void exportData(struct List items);
+bool exportData(FILE *imap, enum Atom tag, struct List items);
 
 void concatFetch(FILE *imap, enum Atom tag, struct List threads);
 void concatData(struct List threads, struct List items);