From 79efea7ad5ffa571d27321243e25c372ab4303b2 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Mon, 13 Apr 2020 11:47:36 -0400 Subject: Rename atom rendering functions Again, probably. --- archive.h | 8 ++++---- atom.c | 8 ++++---- concat.c | 4 ++-- export.c | 16 ++++++++++++++-- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/archive.h b/archive.h index 541c03c..ffe1561 100644 --- a/archive.h +++ b/archive.h @@ -190,7 +190,7 @@ int htmlThreadOpen(FILE *file); int htmlThreadClose(FILE *file); int htmlThreadTail(FILE *file); -int atomEntryHead(FILE *file, const struct Envelope *envelope); -int atomEntryTail(FILE *file); -int atomFeedHead(FILE *file, const struct Envelope *envelope); -int atomFeedTail(FILE *file); +int atomEntryOpen(FILE *file, const struct Envelope *envelope); +int atomEntryClose(FILE *file); +int atomFeedOpen(FILE *file, const struct Envelope *envelope); +int atomFeedClose(FILE *file); diff --git a/atom.c b/atom.c index bf4b456..83a4457 100644 --- a/atom.c +++ b/atom.c @@ -30,7 +30,7 @@ static char *atomID(const char *messageID) { return templateURL("mailto:?Message-Id=[messageID]", vars); } -int atomEntryHead(FILE *file, const struct Envelope *envelope) { +int atomEntryOpen(FILE *file, const struct Envelope *envelope) { char *id = atomID(envelope->messageID); char date[sizeof("0000-00-00T00:00:00Z")]; strftime(date, sizeof(date), "%FT%TZ", gmtime(&envelope->utc)); @@ -58,12 +58,12 @@ int atomEntryHead(FILE *file, const struct Envelope *envelope) { return error; } -int atomEntryTail(FILE *file) { +int atomEntryClose(FILE *file) { int n = fprintf(file, "\n"); return (n < 0 ? n : 0); } -int atomFeedHead(FILE *file, const struct Envelope *envelope) { +int atomFeedOpen(FILE *file, const struct Envelope *envelope) { char *id = atomID(envelope->messageID); char date[sizeof("0000-00-00T00:00:00Z")]; strftime(date, sizeof(date), "%FT%TZ", gmtime(&(time_t) { time(NULL) })); @@ -93,7 +93,7 @@ int atomFeedHead(FILE *file, const struct Envelope *envelope) { return error; } -int atomFeedTail(FILE *file) { +int atomFeedClose(FILE *file) { int n = fprintf(file, "\n"); return (n < 0 ? n : 0); } diff --git a/concat.c b/concat.c index 07d1f6f..5e8be3d 100644 --- a/concat.c +++ b/concat.c @@ -145,7 +145,7 @@ void concatData(struct List threads, struct List items) { FILE *file = fopen(dst, "w"); if (!file) err(EX_CANTCREAT, "%s", dst); - error = atomFeedHead(file, &envelope); + error = atomFeedOpen(file, &envelope); if (error) err(EX_IOERR, "%s", dst); for (size_t i = 0; i < flat.len; ++i) { @@ -154,7 +154,7 @@ void concatData(struct List threads, struct List items) { if (error) err(EX_IOERR, "%s", dst); } - error = atomFeedTail(file) || fclose(file); + error = atomFeedClose(file) || fclose(file); if (error) err(EX_IOERR, "%s", dst); } 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; -- cgit 1.4.1