using namespace std;
+const char *
+notmuch_status_to_string (notmuch_status_t status)
+{
+ switch (status) {
+ case NOTMUCH_STATUS_SUCCESS:
+ return "No error occurred";
+ case NOTMUCH_STATUS_XAPIAN_EXCEPTION:
+ return "A Xapian exception occurred";
+ case NOTMUCH_STATUS_FILE_NOT_EMAIL:
+ return "File is not an email";
+ case NOTMUCH_STATUS_NULL_POINTER:
+ return "Erroneous NULL pointer";
+ case NOTMUCH_STATUS_TAG_TOO_LONG:
+ return "Tag value is too long";
+ default:
+ case NOTMUCH_STATUS_LAST_STATUS:
+ return "Unknown error status value";
+ }
+}
+
/* "128 bits of thread-id ought to be enough for anybody" */
#define NOTMUCH_THREAD_ID_BITS 128
#define NOTMUCH_THREAD_ID_DIGITS (NOTMUCH_THREAD_ID_BITS / 4)
return db->get_document (docid);
}
+static void
+insert_thread_id (GHashTable *thread_ids, Xapian::Document doc)
+{
+ string value_string;
+ const char *value, *id, *comma;
+
+ value_string = doc.get_value (NOTMUCH_VALUE_THREAD);
+ value = value_string.c_str();
+ if (strlen (value)) {
+ id = value;
+ while (*id) {
+ comma = strchr (id, ',');
+ if (comma == NULL)
+ comma = id + strlen (id);
+ g_hash_table_insert (thread_ids,
+ strndup (id, comma - id), NULL);
+ id = comma;
+ if (*id)
+ id++;
+ }
+ }
+}
+
notmuch_message_t *
notmuch_database_find_message (notmuch_database_t *notmuch,
const char *message_id)
find_messages_by_term (db, "ref", message_id, &child, &children_end);
for ( ; child != children_end; child++) {
- const char *thread_id;
doc = find_message_by_docid (db, *child);
-
- thread_id = doc.get_value (NOTMUCH_VALUE_THREAD).c_str ();
- if (strlen (thread_id) == 0) {
- fprintf (stderr, "Database error: Message with doc_id %u has empty thread-id value (value index %d)\n",
- *child, NOTMUCH_VALUE_THREAD);
- } else {
- g_hash_table_insert (thread_ids, strdup (thread_id), NULL);
- }
+ insert_thread_id (thread_ids, doc);
}
for (i = 0; i < parents->len; i++) {