]> git.notmuchmail.org Git - notmuch/blobdiff - database.cc
Trim down prefix list to things we are actually using.
[notmuch] / database.cc
index 712ab260225658588f0d427888694c74a5728800..c470cc34977c17beff7d152f78c5f1ac975cefd2 100644 (file)
 
 using namespace std;
 
+#define ARRAY_SIZE(arr) (sizeof (arr) / sizeof (arr[0]))
+
+/* These prefix values are specifically chosen to be compatible
+ * with sup, (http://sup.rubyforge.org), written by
+ * William Morgan <wmorgan-sup@masanjin.net>, and released
+ * under the GNU GPL v2.
+ */
+
+typedef struct {
+    const char *name;
+    const char *prefix;
+} prefix_t;
+
+prefix_t BOOLEAN_PREFIX[] = {
+    { "type", "K" },
+    { "tag", "L" },
+    { "msgid", "Q" },
+    { "thread", "H" },
+    { "ref", "R" },
+    { "timestamp", "KTS" },
+};
+
+const char *
+_find_prefix (const char *name)
+{
+    unsigned int i;
+
+    for (i = 0; i < ARRAY_SIZE (BOOLEAN_PREFIX); i++)
+       if (strcmp (name, BOOLEAN_PREFIX[i].name) == 0)
+           return BOOLEAN_PREFIX[i].prefix;
+
+    fprintf (stderr, "Internal error: No prefix exists for '%s'\n", name);
+    exit (1);
+
+    return "";
+}
+
 const char *
 notmuch_status_to_string (notmuch_status_t status)
 {