about summary refs log tree commit diff
path: root/export.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--export.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/export.c b/export.c
index 2ff6c5d..c8d742f 100644
--- a/export.c
+++ b/export.c
@@ -50,7 +50,7 @@ static void flatten(struct List *flat, struct List nested) {
 	}
 }
 
-enum Atom exportFetch(FILE *imap, struct List threads) {
+bool exportFetch(FILE *imap, enum Atom tag, struct List threads) {
 	struct List uids = {0};
 	flatten(&uids, threads);
 	for (size_t i = uids.len - 1; i < uids.len; --i) {
@@ -66,10 +66,11 @@ enum Atom exportFetch(FILE *imap, struct List threads) {
 			uids.ptr[i] = uids.ptr[--uids.len];
 		}
 	}
-	enum Atom tag = 0;
-	if (!uids.len) goto done;
+	if (!uids.len) {
+		listFree(uids);
+		return false;
+	}
 
-	tag = atom("exportFetch");
 	fprintf(imap, "%s UID FETCH ", Atoms[tag]);
 	for (size_t i = 0; i < uids.len; ++i) {
 		fprintf(imap, "%s%" PRIu32, (i ? "," : ""), uids.ptr[i].number);
@@ -81,10 +82,7 @@ enum Atom exportFetch(FILE *imap, struct List threads) {
 		"BODY[HEADER.FIELDS (" MBOX_HEADERS ")] BODY[TEXT]"
 		")\r\n"
 	);
-
-done:
-	listFree(uids);
-	return tag;
+	return true;
 }
 
 static struct Address parseAddress(struct List list) {