about summary refs log tree commit diff
path: root/archive.h
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-06-12 19:20:47 -0400
committerJune McEnroe <june@causal.agency>2021-06-12 19:20:47 -0400
commit9b09a5ff483aef05dc5b4d9ab0fd0243d21cb1d3 (patch)
tree2a2be7ddda0e4161833e0e35cdf8585aa8016fc7 /archive.h
parentAdd margin between header navs (diff)
downloadbubger-9b09a5ff483aef05dc5b4d9ab0fd0243d21cb1d3.tar.gz
bubger-9b09a5ff483aef05dc5b4d9ab0fd0243d21cb1d3.zip
Use SEARCH for a subset of thread roots
This does way less duplicate work by fetching all threads and all
thread root envelopes once, then doing searches for subsets of
thread roots.
Diffstat (limited to 'archive.h')
-rw-r--r--archive.h34
1 files changed, 21 insertions, 13 deletions
diff --git a/archive.h b/archive.h
index 7740b98..d6b9608 100644
--- a/archive.h
+++ b/archive.h
@@ -44,7 +44,7 @@
 #define PATH_THREAD "thread/[messageID].[type]"
 #define PATH_ATTACHMENT \
 	"attachment/[messageID]/[section]/[name][disposition][.][subtype]"
-#define PATH_SEARCH "[name].[type]"
+#define PATH_INDEX "[name].[type]"
 
 #define MBOX_HEADERS \
 	"Date Subject From Sender Reply-To To Cc Bcc " \
@@ -60,6 +60,13 @@ extern const char *baseMailto;
 extern const char *baseSubscribe;
 extern const char *baseStylesheet;
 
+extern struct Search {
+	size_t cap;
+	size_t len;
+	char **names;
+	char **exprs;
+} search;
+
 static inline struct U32 {
 	char s[sizeof("4294967295")];
 } u32(uint32_t u) {
@@ -215,15 +222,18 @@ bool exportFetch(FILE *imap, enum Atom tag, struct List threads);
 bool exportData(FILE *imap, enum Atom tag, struct List items);
 
 extern const char *concatHead;
-extern size_t concatSearchEntries;
+extern size_t concatIndexEntries;
 void concatFetch(FILE *imap, enum Atom tag, struct List threads);
+void concatSearch(
+	FILE *imap, enum Atom tag, struct List threads, const char *expr
+);
 void concatData(
 	struct List threads, struct Envelope *envelopes, struct List items
 );
 void concatThreads(struct List threads, const struct Envelope *envelopes);
-void concatSearch(
-	const char *name, struct List threads, const struct Envelope *envelopes,
-	char *searches[const], size_t len
+void concatIndex(
+	const char *name, struct List roots,
+	struct List threads, const struct Envelope *envelopes
 );
 
 int mboxFrom(FILE *file);
@@ -235,8 +245,8 @@ int atomContent(FILE *file, const char *content);
 int atomEntryClose(FILE *file);
 int atomThreadOpen(FILE *file, const struct Envelope *envelope);
 int atomThreadClose(FILE *file);
-int atomSearchOpen(FILE *file, const char *name);
-int atomSearchClose(FILE *file);
+int atomIndexOpen(FILE *file, const char *name);
+int atomIndexClose(FILE *file);
 
 int htmlMessageOpen(FILE *file, const struct Envelope *envelope, bool nested);
 int htmlInline(FILE *file, const struct BodyPart *part, const char *content);
@@ -251,11 +261,9 @@ int htmlThreadOpen(FILE *file, const struct Envelope *envelope);
 int htmlSubthreadOpen(FILE *file, struct List thread);
 int htmlSubthreadClose(FILE *file);
 int htmlThreadClose(FILE *file);
-int htmlSearchHead(FILE *file, const char *name);
-int htmlSearchOpen(
-	FILE *file, const char *name, char *searches[const], size_t len
-);
-int htmlSearchThread(
+int htmlIndexHead(FILE *file, const char *name);
+int htmlIndexOpen(FILE *file, const char *name);
+int htmlIndexThread(
 	FILE *file, const struct Envelope *envelope, struct List thread
 );
-int htmlSearchClose(FILE *file);
+int htmlIndexClose(FILE *file);