summary refs log tree commit diff
path: root/export.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--export.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/export.c b/export.c
index 411b70c..8e97370 100644
--- a/export.c
+++ b/export.c
@@ -71,8 +71,8 @@ static void exportEnvelope(uint32_t uid, const struct Envelope *envelope) {
 	file = fopen(pathUID(path, uid, "atom"), "w");
 	if (!file) err(EX_CANTCREAT, "%s", path);
 	error = 0
-		|| atomEntryHead(file, envelope)
-		|| atomEntryTail(file)
+		|| atomEntryOpen(file, envelope)
+		|| atomEntryClose(file)
 		|| fclose(file);
 	if (error) err(EX_IOERR, "%s", path);
 }
@@ -98,6 +98,12 @@ static void exportRaw(
 	if (error) err(EX_CANTCREAT, "%s", dst);
 }
 
+static void exportBodyPart(
+	uint32_t uid, const struct BodyPart *structure,
+	const struct BodyPart *part, const char *content
+) {
+}
+
 bool exportData(FILE *imap, enum Atom tag, struct List items) {
 	uint32_t uid = 0;
 	struct Envelope envelope = {0};
@@ -145,6 +151,12 @@ bool exportData(FILE *imap, enum Atom tag, struct List items) {
 	exportRaw(uid, &envelope, header, body);
 	exportEnvelope(uid, &envelope);
 
+	if (structure.multipart) {
+		// TODO: FETCH each body part.
+	} else {
+		exportBodyPart(uid, &structure, &structure, body);
+	}
+
 	envelopeFree(envelope);
 	bodyPartFree(structure);
 	return false;