summary refs log tree commit diff
path: root/archive.h
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-04-17 16:35:52 -0400
committerJune McEnroe <june@causal.agency>2020-04-17 16:35:52 -0400
commitf83e1927a6225699522918bbdf581c2b73efbe71 (patch)
treeca1b5f35842ddcdb44c7d86c77895bf4912e857f /archive.h
parentLabel atom and mbox links "follow" and "download" (diff)
downloadbubger-f83e1927a6225699522918bbdf581c2b73efbe71.tar.gz
bubger-f83e1927a6225699522918bbdf581c2b73efbe71.zip
Write attachment files
All this path stuff needs cleaning up. I think it's time to use the
template renderer for paths.
Diffstat (limited to '')
-rw-r--r--archive.h15
1 files changed, 11 insertions, 4 deletions
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);