about summary refs log tree commit diff
path: root/archive.h
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-04-12 16:43:08 -0400
committerJune McEnroe <june@causal.agency>2020-04-12 16:43:08 -0400
commitc5db1246fbafe62fc125f13664dd0e10204aa0b1 (patch)
treeb05e2bc24a392a61e07b9d8594ea2c17f821de5e /archive.h
parentAvoid mutating header/body for mbox output (diff)
downloadbubger-c5db1246fbafe62fc125f13664dd0e10204aa0b1.tar.gz
bubger-c5db1246fbafe62fc125f13664dd0e10204aa0b1.zip
Factor out path functions
Diffstat (limited to 'archive.h')
-rw-r--r--archive.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/archive.h b/archive.h
index 8fd9693..e9d4648 100644
--- a/archive.h
+++ b/archive.h
@@ -14,6 +14,9 @@
  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
+#include <inttypes.h>
+#include <limits.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <time.h>
@@ -139,6 +142,26 @@ int templateRender(
 );
 char *templateURL(const char *template, const struct Variable vars[]);
 
+static inline char *
+pathUID(char path[static PATH_MAX], uint32_t uid, const char *type) {
+	snprintf(path, PATH_MAX, "UID/%" PRIu32 ".%s", uid, type);
+	return path;
+}
+
+static inline char *pathMessage(
+	char path[static PATH_MAX], const char *messageID, const char *type
+) {
+	snprintf(path, PATH_MAX, "message/%s.%s", messageID, type);
+	return path;
+}
+
+static inline char *pathThread(
+	char path[static PATH_MAX], const char *messageID, const char *type
+) {
+	snprintf(path, PATH_MAX, "thread/%s.%s", messageID, type);
+	return path;
+}
+
 #define MBOX_HEADERS \
 	"Date Subject From Sender Reply-To To Cc Bcc " \
 	"Message-Id In-Reply-To References " \