From 0583e4c0c36ac3ebd4479c674ebd1dd0d5e8fe0d Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Sun, 12 Apr 2020 14:09:34 -0400 Subject: Fetch and parse BODYSTRUCTURE --- archive.h | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) (limited to 'archive.h') 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); -- cgit 1.4.1