summary refs log tree commit diff
path: root/archive.h
diff options
context:
space:
mode:
Diffstat (limited to 'archive.h')
-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);