From f83e1927a6225699522918bbdf581c2b73efbe71 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Fri, 17 Apr 2020 16:35:52 -0400 Subject: Write attachment files All this path stuff needs cleaning up. I think it's time to use the template renderer for paths. --- archive.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'archive.h') diff --git a/archive.h b/archive.h index d0bc00d..06fd435 100644 --- a/archive.h +++ b/archive.h @@ -156,15 +156,19 @@ char *decodeHeader(const char *header); char *decodeToString(const struct BodyPart *part, const char *content); int decodeToFile(FILE *file, const struct BodyPart *part, const char *content); +struct Attachment { + char path[3][NAME_MAX + 1]; +}; + static inline const char *pathUID(uint32_t uid, const char *type) { - static char buf[PATH_MAX]; + static char buf[PATH_MAX + 1]; snprintf(buf, sizeof(buf), "UID/%" PRIu32 ".%s", uid, type); return buf; } static inline const char *pathSafe(const char *messageID) { if (!strchr(messageID, '/')) return messageID; - static char buf[PATH_MAX]; + static char buf[NAME_MAX + 1]; strlcpy(buf, messageID, sizeof(buf)); for (char *ptr = buf; (ptr = strchr(ptr, '/')); ++ptr) { *ptr = ';'; @@ -173,13 +177,13 @@ static inline const char *pathSafe(const char *messageID) { } static inline const char *pathMessage(const char *messageID, const char *type) { - static char buf[PATH_MAX]; + static char buf[PATH_MAX + 1]; snprintf(buf, sizeof(buf), "message/%s.%s", pathSafe(messageID), type); return buf; } static inline const char *pathThread(const char *messageID, const char *type) { - static char buf[PATH_MAX]; + static char buf[PATH_MAX + 1]; snprintf(buf, sizeof(buf), "thread/%s.%s", pathSafe(messageID), type); return buf; } @@ -203,6 +207,9 @@ int atomFeedClose(FILE *file); extern const char *htmlTitle; int htmlMessageOpen(FILE *file, const struct Envelope *envelope); int htmlInline(FILE *file, const struct BodyPart *part, const char *content); +int htmlAttachment( + FILE *file, const struct BodyPart *part, const struct Attachment *attach +); int htmlMessageClose(FILE *file); int htmlThreadHead(FILE *file, const struct Envelope *envelope); int htmlThreadOpen(FILE *file, const struct Envelope *envelope); -- cgit 1.4.1 id=09890238b600659d76b42cb326da25a3e2904fe4&showmsg=1&follow=1'>irc/litterbox/distinfo (unfollow)
Commit message (Collapse)Author
2021-01-15Update litterbox to 1.7June McEnroe
2021-01-15Update pounce to 2.2June McEnroe
2021-01-15Update catgirl to 1.4June McEnroe
2020-12-28Replace cgit-patched with cgit-causal-agencyJune McEnroe
2020-12-18Add notemap portJune McEnroe
2020-12-15Update libretls to 3.3.1June McEnroe
2020-12-15Update catsit to 1.1June McEnroe
2020-12-15Update pounce to 2.1p1June McEnroe
2020-12-15Add imbox portJune McEnroe
2020-11-24Update pounce to 2.1June McEnroe
2020-11-24Update libretls to 3.3.0June McEnroe
2020-11-17Update catgirl to 1.3June McEnroe
2020-11-17Update libretls to 3.2.2June McEnroe
2020-09-29Update libretls to 3.2.1June McEnroe
2020-09-10Update catgirl to 1.2June McEnroe
2020-09-09Add pounce-palaver portJune McEnroe
2020-09-09Update pounce to 2.0June McEnroe
2020-09-09Update litterbox to 1.6June McEnroe
2020-08-23Add scooper portJune McEnroe
2020-08-23Add catsit portJune McEnroe
2020-08-13Update pounce to 1.4p2June McEnroe
2020-08-11Update pounce to 1.4p1June McEnroe
2020-08-10Add litterbox portJune McEnroe
2020-08-10Add missing USES=pkgconfig to pounceJune McEnroe