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)
{
static char *
timestamp_db_key (const char *key)
{
- if (strlen (key) + 1 > NOTMUCH_TERM_MAX) {
+ int term_len = strlen (_find_prefix ("timestamp")) + strlen (key);
+
+ if (term_len > NOTMUCH_TERM_MAX)
return notmuch_sha1_of_string (key);
- } else {
+ else
return strdup (key);
- }
}
notmuch_status_t