mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-24 03:48:10 +01:00
lib: convert notmuch_bool_t to stdbool internally
C99 stdbool turned 18 this year. There really is no reason to use our own, except in the library interface for backward compatibility. Convert the lib internally to stdbool.
This commit is contained in:
parent
0f314c0c99
commit
008a5e92eb
17 changed files with 128 additions and 127 deletions
|
@ -404,7 +404,7 @@ static notmuch_status_t
|
||||||
_notmuch_database_link_message (notmuch_database_t *notmuch,
|
_notmuch_database_link_message (notmuch_database_t *notmuch,
|
||||||
notmuch_message_t *message,
|
notmuch_message_t *message,
|
||||||
notmuch_message_file_t *message_file,
|
notmuch_message_file_t *message_file,
|
||||||
notmuch_bool_t is_ghost)
|
bool is_ghost)
|
||||||
{
|
{
|
||||||
void *local = talloc_new (NULL);
|
void *local = talloc_new (NULL);
|
||||||
notmuch_status_t status;
|
notmuch_status_t status;
|
||||||
|
@ -467,7 +467,7 @@ notmuch_database_index_file (notmuch_database_t *notmuch,
|
||||||
notmuch_message_t *message = NULL;
|
notmuch_message_t *message = NULL;
|
||||||
notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS, ret2;
|
notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS, ret2;
|
||||||
notmuch_private_status_t private_status;
|
notmuch_private_status_t private_status;
|
||||||
notmuch_bool_t is_ghost = FALSE, is_new = FALSE;
|
bool is_ghost = false, is_new = false;
|
||||||
|
|
||||||
const char *date;
|
const char *date;
|
||||||
const char *from, *to, *subject;
|
const char *from, *to, *subject;
|
||||||
|
@ -510,12 +510,12 @@ notmuch_database_index_file (notmuch_database_t *notmuch,
|
||||||
/* We cannot call notmuch_message_get_flag for a new message */
|
/* We cannot call notmuch_message_get_flag for a new message */
|
||||||
switch (private_status) {
|
switch (private_status) {
|
||||||
case NOTMUCH_PRIVATE_STATUS_NO_DOCUMENT_FOUND:
|
case NOTMUCH_PRIVATE_STATUS_NO_DOCUMENT_FOUND:
|
||||||
is_ghost = FALSE;
|
is_ghost = false;
|
||||||
is_new = TRUE;
|
is_new = true;
|
||||||
break;
|
break;
|
||||||
case NOTMUCH_PRIVATE_STATUS_SUCCESS:
|
case NOTMUCH_PRIVATE_STATUS_SUCCESS:
|
||||||
is_ghost = notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_GHOST);
|
is_ghost = notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_GHOST);
|
||||||
is_new = FALSE;
|
is_new = false;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ret = COERCE_STATUS (private_status,
|
ret = COERCE_STATUS (private_status,
|
||||||
|
@ -551,7 +551,7 @@ notmuch_database_index_file (notmuch_database_t *notmuch,
|
||||||
} catch (const Xapian::Error &error) {
|
} catch (const Xapian::Error &error) {
|
||||||
_notmuch_database_log (notmuch, "A Xapian exception occurred adding message: %s.\n",
|
_notmuch_database_log (notmuch, "A Xapian exception occurred adding message: %s.\n",
|
||||||
error.get_msg().c_str());
|
error.get_msg().c_str());
|
||||||
notmuch->exception_reported = TRUE;
|
notmuch->exception_reported = true;
|
||||||
ret = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
|
ret = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
|
||||||
goto DONE;
|
goto DONE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,6 @@ notmuch_built_with (const char *name)
|
||||||
} else if (STRNCMP_LITERAL (name, "retry_lock") == 0) {
|
} else if (STRNCMP_LITERAL (name, "retry_lock") == 0) {
|
||||||
return HAVE_XAPIAN_DB_RETRY_LOCK;
|
return HAVE_XAPIAN_DB_RETRY_LOCK;
|
||||||
} else {
|
} else {
|
||||||
return FALSE;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ notmuch_database_set_config (notmuch_database_t *notmuch,
|
||||||
db->set_metadata (CONFIG_PREFIX + key, value);
|
db->set_metadata (CONFIG_PREFIX + key, value);
|
||||||
} catch (const Xapian::Error &error) {
|
} catch (const Xapian::Error &error) {
|
||||||
status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
|
status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
|
||||||
notmuch->exception_reported = TRUE;
|
notmuch->exception_reported = true;
|
||||||
_notmuch_database_log (notmuch, "Error: A Xapian exception occurred setting metadata: %s\n",
|
_notmuch_database_log (notmuch, "Error: A Xapian exception occurred setting metadata: %s\n",
|
||||||
error.get_msg().c_str());
|
error.get_msg().c_str());
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ _metadata_value (notmuch_database_t *notmuch,
|
||||||
value = notmuch->xapian_db->get_metadata (CONFIG_PREFIX + key);
|
value = notmuch->xapian_db->get_metadata (CONFIG_PREFIX + key);
|
||||||
} catch (const Xapian::Error &error) {
|
} catch (const Xapian::Error &error) {
|
||||||
status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
|
status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
|
||||||
notmuch->exception_reported = TRUE;
|
notmuch->exception_reported = true;
|
||||||
_notmuch_database_log (notmuch, "Error: A Xapian exception occurred getting metadata: %s\n",
|
_notmuch_database_log (notmuch, "Error: A Xapian exception occurred getting metadata: %s\n",
|
||||||
error.get_msg().c_str());
|
error.get_msg().c_str());
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ notmuch_database_get_config_list (notmuch_database_t *notmuch,
|
||||||
} catch (const Xapian::Error &error) {
|
} catch (const Xapian::Error &error) {
|
||||||
_notmuch_database_log (notmuch, "A Xapian exception occurred getting metadata iterator: %s.\n",
|
_notmuch_database_log (notmuch, "A Xapian exception occurred getting metadata iterator: %s.\n",
|
||||||
error.get_msg().c_str());
|
error.get_msg().c_str());
|
||||||
notmuch->exception_reported = TRUE;
|
notmuch->exception_reported = true;
|
||||||
status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
|
status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,9 +145,9 @@ notmuch_bool_t
|
||||||
notmuch_config_list_valid (notmuch_config_list_t *metadata)
|
notmuch_config_list_valid (notmuch_config_list_t *metadata)
|
||||||
{
|
{
|
||||||
if (metadata->iterator == metadata->notmuch->xapian_db->metadata_keys_end ())
|
if (metadata->iterator == metadata->notmuch->xapian_db->metadata_keys_end ())
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
|
|
|
@ -179,14 +179,14 @@ operator&(notmuch_field_flag_t a, notmuch_field_flag_t b)
|
||||||
Xapian::QueryParser::FLAG_PURE_NOT)
|
Xapian::QueryParser::FLAG_PURE_NOT)
|
||||||
|
|
||||||
struct _notmuch_database {
|
struct _notmuch_database {
|
||||||
notmuch_bool_t exception_reported;
|
bool exception_reported;
|
||||||
|
|
||||||
char *path;
|
char *path;
|
||||||
|
|
||||||
notmuch_database_mode_t mode;
|
notmuch_database_mode_t mode;
|
||||||
int atomic_nesting;
|
int atomic_nesting;
|
||||||
/* TRUE if changes have been made in this atomic section */
|
/* true if changes have been made in this atomic section */
|
||||||
notmuch_bool_t atomic_dirty;
|
bool atomic_dirty;
|
||||||
Xapian::Database *xapian_db;
|
Xapian::Database *xapian_db;
|
||||||
|
|
||||||
/* Bit mask of features used by this database. This is a
|
/* Bit mask of features used by this database. This is a
|
||||||
|
|
|
@ -562,7 +562,7 @@ notmuch_database_find_message (notmuch_database_t *notmuch,
|
||||||
} catch (const Xapian::Error &error) {
|
} catch (const Xapian::Error &error) {
|
||||||
_notmuch_database_log (notmuch, "A Xapian exception occurred finding message: %s.\n",
|
_notmuch_database_log (notmuch, "A Xapian exception occurred finding message: %s.\n",
|
||||||
error.get_msg().c_str());
|
error.get_msg().c_str());
|
||||||
notmuch->exception_reported = TRUE;
|
notmuch->exception_reported = true;
|
||||||
*message_ret = NULL;
|
*message_ret = NULL;
|
||||||
return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
|
return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
|
||||||
}
|
}
|
||||||
|
@ -691,7 +691,7 @@ _notmuch_database_new_revision (notmuch_database_t *notmuch)
|
||||||
* committed revision number until we commit the atomic section.
|
* committed revision number until we commit the atomic section.
|
||||||
*/
|
*/
|
||||||
if (notmuch->atomic_nesting)
|
if (notmuch->atomic_nesting)
|
||||||
notmuch->atomic_dirty = TRUE;
|
notmuch->atomic_dirty = true;
|
||||||
else
|
else
|
||||||
notmuch->revision = new_revision;
|
notmuch->revision = new_revision;
|
||||||
|
|
||||||
|
@ -854,7 +854,7 @@ notmuch_database_open_verbose (const char *path,
|
||||||
}
|
}
|
||||||
|
|
||||||
notmuch = talloc_zero (NULL, notmuch_database_t);
|
notmuch = talloc_zero (NULL, notmuch_database_t);
|
||||||
notmuch->exception_reported = FALSE;
|
notmuch->exception_reported = false;
|
||||||
notmuch->status_string = NULL;
|
notmuch->status_string = NULL;
|
||||||
notmuch->path = talloc_strdup (notmuch, path);
|
notmuch->path = talloc_strdup (notmuch, path);
|
||||||
|
|
||||||
|
@ -1040,7 +1040,7 @@ _notmuch_database_reopen (notmuch_database_t *notmuch)
|
||||||
if (! notmuch->exception_reported) {
|
if (! notmuch->exception_reported) {
|
||||||
_notmuch_database_log (notmuch, "Error: A Xapian exception reopening database: %s\n",
|
_notmuch_database_log (notmuch, "Error: A Xapian exception reopening database: %s\n",
|
||||||
error.get_msg ().c_str ());
|
error.get_msg ().c_str ());
|
||||||
notmuch->exception_reported = TRUE;
|
notmuch->exception_reported = true;
|
||||||
}
|
}
|
||||||
return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
|
return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
|
||||||
}
|
}
|
||||||
|
@ -1118,7 +1118,7 @@ notmuch_database_compact (const char *path,
|
||||||
notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS;
|
notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS;
|
||||||
notmuch_database_t *notmuch = NULL;
|
notmuch_database_t *notmuch = NULL;
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
notmuch_bool_t keep_backup;
|
bool keep_backup;
|
||||||
char *message = NULL;
|
char *message = NULL;
|
||||||
|
|
||||||
local = talloc_new (NULL);
|
local = talloc_new (NULL);
|
||||||
|
@ -1154,10 +1154,10 @@ notmuch_database_compact (const char *path,
|
||||||
ret = NOTMUCH_STATUS_OUT_OF_MEMORY;
|
ret = NOTMUCH_STATUS_OUT_OF_MEMORY;
|
||||||
goto DONE;
|
goto DONE;
|
||||||
}
|
}
|
||||||
keep_backup = FALSE;
|
keep_backup = false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
keep_backup = TRUE;
|
keep_backup = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stat (backup_path, &statbuf) != -1) {
|
if (stat (backup_path, &statbuf) != -1) {
|
||||||
|
@ -1313,7 +1313,7 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,
|
||||||
Xapian::WritableDatabase *db;
|
Xapian::WritableDatabase *db;
|
||||||
struct sigaction action;
|
struct sigaction action;
|
||||||
struct itimerval timerval;
|
struct itimerval timerval;
|
||||||
notmuch_bool_t timer_is_active = FALSE;
|
bool timer_is_active = false;
|
||||||
enum _notmuch_features target_features, new_features;
|
enum _notmuch_features target_features, new_features;
|
||||||
notmuch_status_t status;
|
notmuch_status_t status;
|
||||||
notmuch_private_status_t private_status;
|
notmuch_private_status_t private_status;
|
||||||
|
@ -1347,7 +1347,7 @@ notmuch_database_upgrade (notmuch_database_t *notmuch,
|
||||||
timerval.it_value.tv_usec = 0;
|
timerval.it_value.tv_usec = 0;
|
||||||
setitimer (ITIMER_REAL, &timerval, NULL);
|
setitimer (ITIMER_REAL, &timerval, NULL);
|
||||||
|
|
||||||
timer_is_active = TRUE;
|
timer_is_active = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Figure out how much total work we need to do. */
|
/* Figure out how much total work we need to do. */
|
||||||
|
@ -1588,7 +1588,7 @@ notmuch_database_begin_atomic (notmuch_database_t *notmuch)
|
||||||
} catch (const Xapian::Error &error) {
|
} catch (const Xapian::Error &error) {
|
||||||
_notmuch_database_log (notmuch, "A Xapian exception occurred beginning transaction: %s.\n",
|
_notmuch_database_log (notmuch, "A Xapian exception occurred beginning transaction: %s.\n",
|
||||||
error.get_msg().c_str());
|
error.get_msg().c_str());
|
||||||
notmuch->exception_reported = TRUE;
|
notmuch->exception_reported = true;
|
||||||
return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
|
return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1622,13 +1622,13 @@ notmuch_database_end_atomic (notmuch_database_t *notmuch)
|
||||||
} catch (const Xapian::Error &error) {
|
} catch (const Xapian::Error &error) {
|
||||||
_notmuch_database_log (notmuch, "A Xapian exception occurred committing transaction: %s.\n",
|
_notmuch_database_log (notmuch, "A Xapian exception occurred committing transaction: %s.\n",
|
||||||
error.get_msg().c_str());
|
error.get_msg().c_str());
|
||||||
notmuch->exception_reported = TRUE;
|
notmuch->exception_reported = true;
|
||||||
return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
|
return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (notmuch->atomic_dirty) {
|
if (notmuch->atomic_dirty) {
|
||||||
++notmuch->revision;
|
++notmuch->revision;
|
||||||
notmuch->atomic_dirty = FALSE;
|
notmuch->atomic_dirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
DONE:
|
DONE:
|
||||||
|
@ -1871,7 +1871,7 @@ notmuch_database_get_directory (notmuch_database_t *notmuch,
|
||||||
} catch (const Xapian::Error &error) {
|
} catch (const Xapian::Error &error) {
|
||||||
_notmuch_database_log (notmuch, "A Xapian exception occurred getting directory: %s.\n",
|
_notmuch_database_log (notmuch, "A Xapian exception occurred getting directory: %s.\n",
|
||||||
error.get_msg().c_str());
|
error.get_msg().c_str());
|
||||||
notmuch->exception_reported = TRUE;
|
notmuch->exception_reported = true;
|
||||||
status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
|
status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
|
@ -1968,7 +1968,7 @@ notmuch_database_find_message_by_filename (notmuch_database_t *notmuch,
|
||||||
} catch (const Xapian::Error &error) {
|
} catch (const Xapian::Error &error) {
|
||||||
_notmuch_database_log (notmuch, "Error: A Xapian exception occurred finding message by filename: %s\n",
|
_notmuch_database_log (notmuch, "Error: A Xapian exception occurred finding message by filename: %s\n",
|
||||||
error.get_msg().c_str());
|
error.get_msg().c_str());
|
||||||
notmuch->exception_reported = TRUE;
|
notmuch->exception_reported = true;
|
||||||
status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
|
status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2021,7 +2021,7 @@ notmuch_database_get_all_tags (notmuch_database_t *db)
|
||||||
} catch (const Xapian::Error &error) {
|
} catch (const Xapian::Error &error) {
|
||||||
_notmuch_database_log (db, "A Xapian exception occurred getting tags: %s.\n",
|
_notmuch_database_log (db, "A Xapian exception occurred getting tags: %s.\n",
|
||||||
error.get_msg().c_str());
|
error.get_msg().c_str());
|
||||||
db->exception_reported = TRUE;
|
db->exception_reported = true;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,7 +103,7 @@ _notmuch_directory_create (notmuch_database_t *notmuch,
|
||||||
notmuch_directory_t *directory;
|
notmuch_directory_t *directory;
|
||||||
notmuch_private_status_t private_status;
|
notmuch_private_status_t private_status;
|
||||||
const char *db_path;
|
const char *db_path;
|
||||||
notmuch_bool_t create = (flags & NOTMUCH_FIND_CREATE);
|
bool create = (flags & NOTMUCH_FIND_CREATE);
|
||||||
|
|
||||||
if (! (notmuch->features & NOTMUCH_FEATURE_DIRECTORY_DOCS)) {
|
if (! (notmuch->features & NOTMUCH_FEATURE_DIRECTORY_DOCS)) {
|
||||||
*status_ret = NOTMUCH_STATUS_UPGRADE_REQUIRED;
|
*status_ret = NOTMUCH_STATUS_UPGRADE_REQUIRED;
|
||||||
|
@ -189,7 +189,7 @@ _notmuch_directory_create (notmuch_database_t *notmuch,
|
||||||
_notmuch_database_log (notmuch,
|
_notmuch_database_log (notmuch,
|
||||||
"A Xapian exception occurred creating a directory: %s.\n",
|
"A Xapian exception occurred creating a directory: %s.\n",
|
||||||
error.get_msg().c_str());
|
error.get_msg().c_str());
|
||||||
notmuch->exception_reported = TRUE;
|
notmuch->exception_reported = true;
|
||||||
notmuch_directory_destroy (directory);
|
notmuch_directory_destroy (directory);
|
||||||
directory = NULL;
|
directory = NULL;
|
||||||
*status_ret = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
|
*status_ret = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
|
||||||
|
@ -234,7 +234,7 @@ notmuch_directory_set_mtime (notmuch_directory_t *directory,
|
||||||
_notmuch_database_log (notmuch,
|
_notmuch_database_log (notmuch,
|
||||||
"A Xapian exception occurred setting directory mtime: %s.\n",
|
"A Xapian exception occurred setting directory mtime: %s.\n",
|
||||||
error.get_msg().c_str());
|
error.get_msg().c_str());
|
||||||
notmuch->exception_reported = TRUE;
|
notmuch->exception_reported = true;
|
||||||
return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
|
return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,7 +301,7 @@ notmuch_directory_delete (notmuch_directory_t *directory)
|
||||||
_notmuch_database_log (directory->notmuch,
|
_notmuch_database_log (directory->notmuch,
|
||||||
"A Xapian exception occurred deleting directory entry: %s.\n",
|
"A Xapian exception occurred deleting directory entry: %s.\n",
|
||||||
error.get_msg().c_str());
|
error.get_msg().c_str());
|
||||||
directory->notmuch->exception_reported = TRUE;
|
directory->notmuch->exception_reported = true;
|
||||||
status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
|
status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
|
||||||
}
|
}
|
||||||
notmuch_directory_destroy (directory);
|
notmuch_directory_destroy (directory);
|
||||||
|
|
|
@ -46,7 +46,7 @@ notmuch_bool_t
|
||||||
notmuch_filenames_valid (notmuch_filenames_t *filenames)
|
notmuch_filenames_valid (notmuch_filenames_t *filenames)
|
||||||
{
|
{
|
||||||
if (filenames == NULL)
|
if (filenames == NULL)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
return (filenames->iterator != NULL);
|
return (filenames->iterator != NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -184,7 +184,7 @@ filter_filter (GMimeFilter *gmime_filter, char *inbuf, size_t inlen, size_t pres
|
||||||
|
|
||||||
int next;
|
int next;
|
||||||
|
|
||||||
g_mime_filter_set_size (gmime_filter, inlen, FALSE);
|
g_mime_filter_set_size (gmime_filter, inlen, false);
|
||||||
outptr = gmime_filter->outbuf;
|
outptr = gmime_filter->outbuf;
|
||||||
|
|
||||||
next = filter->state;
|
next = filter->state;
|
||||||
|
@ -460,7 +460,7 @@ _index_mime_part (notmuch_message_t *message,
|
||||||
byte_array = g_byte_array_new ();
|
byte_array = g_byte_array_new ();
|
||||||
|
|
||||||
stream = g_mime_stream_mem_new_with_byte_array (byte_array);
|
stream = g_mime_stream_mem_new_with_byte_array (byte_array);
|
||||||
g_mime_stream_mem_set_owner (GMIME_STREAM_MEM (stream), FALSE);
|
g_mime_stream_mem_set_owner (GMIME_STREAM_MEM (stream), false);
|
||||||
|
|
||||||
filter = g_mime_stream_filter_new (stream);
|
filter = g_mime_stream_filter_new (stream);
|
||||||
|
|
||||||
|
@ -493,7 +493,7 @@ _index_mime_part (notmuch_message_t *message,
|
||||||
g_object_unref (discard_non_term_filter);
|
g_object_unref (discard_non_term_filter);
|
||||||
|
|
||||||
g_byte_array_append (byte_array, (guint8 *) "\0", 1);
|
g_byte_array_append (byte_array, (guint8 *) "\0", 1);
|
||||||
body = (char *) g_byte_array_free (byte_array, FALSE);
|
body = (char *) g_byte_array_free (byte_array, false);
|
||||||
|
|
||||||
if (body) {
|
if (body) {
|
||||||
_notmuch_message_gen_terms (message, NULL, body);
|
_notmuch_message_gen_terms (message, NULL, body);
|
||||||
|
|
|
@ -104,16 +104,16 @@ _notmuch_message_file_close (notmuch_message_file_t *message)
|
||||||
talloc_free (message);
|
talloc_free (message);
|
||||||
}
|
}
|
||||||
|
|
||||||
static notmuch_bool_t
|
static bool
|
||||||
_is_mbox (FILE *file)
|
_is_mbox (FILE *file)
|
||||||
{
|
{
|
||||||
char from_buf[5];
|
char from_buf[5];
|
||||||
notmuch_bool_t ret = FALSE;
|
bool ret = false;
|
||||||
|
|
||||||
/* Is this mbox? */
|
/* Is this mbox? */
|
||||||
if (fread (from_buf, sizeof (from_buf), 1, file) == 1 &&
|
if (fread (from_buf, sizeof (from_buf), 1, file) == 1 &&
|
||||||
strncmp (from_buf, "From ", 5) == 0)
|
strncmp (from_buf, "From ", 5) == 0)
|
||||||
ret = TRUE;
|
ret = true;
|
||||||
|
|
||||||
rewind (file);
|
rewind (file);
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ _notmuch_message_file_parse (notmuch_message_file_t *message)
|
||||||
GMimeParser *parser;
|
GMimeParser *parser;
|
||||||
notmuch_status_t status = NOTMUCH_STATUS_SUCCESS;
|
notmuch_status_t status = NOTMUCH_STATUS_SUCCESS;
|
||||||
static int initialized = 0;
|
static int initialized = 0;
|
||||||
notmuch_bool_t is_mbox;
|
bool is_mbox;
|
||||||
|
|
||||||
if (message->message)
|
if (message->message)
|
||||||
return NOTMUCH_STATUS_SUCCESS;
|
return NOTMUCH_STATUS_SUCCESS;
|
||||||
|
@ -147,7 +147,7 @@ _notmuch_message_file_parse (notmuch_message_file_t *message)
|
||||||
stream = g_mime_stream_file_new (message->file);
|
stream = g_mime_stream_file_new (message->file);
|
||||||
|
|
||||||
/* We'll own and fclose the FILE* ourselves. */
|
/* We'll own and fclose the FILE* ourselves. */
|
||||||
g_mime_stream_file_set_owner (GMIME_STREAM_FILE (stream), FALSE);
|
g_mime_stream_file_set_owner (GMIME_STREAM_FILE (stream), false);
|
||||||
|
|
||||||
parser = g_mime_parser_new_with_stream (stream);
|
parser = g_mime_parser_new_with_stream (stream);
|
||||||
g_mime_parser_set_scan_from (parser, is_mbox);
|
g_mime_parser_set_scan_from (parser, is_mbox);
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
notmuch_string_map_t *
|
notmuch_string_map_t *
|
||||||
_notmuch_message_property_map (notmuch_message_t *message);
|
_notmuch_message_property_map (notmuch_message_t *message);
|
||||||
|
|
||||||
notmuch_bool_t
|
bool
|
||||||
_notmuch_message_frozen (notmuch_message_t *message);
|
_notmuch_message_frozen (notmuch_message_t *message);
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -38,7 +38,7 @@ notmuch_message_get_property (notmuch_message_t *message, const char *key, const
|
||||||
|
|
||||||
static notmuch_status_t
|
static notmuch_status_t
|
||||||
_notmuch_message_modify_property (notmuch_message_t *message, const char *key, const char *value,
|
_notmuch_message_modify_property (notmuch_message_t *message, const char *key, const char *value,
|
||||||
notmuch_bool_t delete_it)
|
bool delete_it)
|
||||||
{
|
{
|
||||||
notmuch_private_status_t private_status;
|
notmuch_private_status_t private_status;
|
||||||
notmuch_status_t status;
|
notmuch_status_t status;
|
||||||
|
@ -76,13 +76,13 @@ _notmuch_message_modify_property (notmuch_message_t *message, const char *key, c
|
||||||
notmuch_status_t
|
notmuch_status_t
|
||||||
notmuch_message_add_property (notmuch_message_t *message, const char *key, const char *value)
|
notmuch_message_add_property (notmuch_message_t *message, const char *key, const char *value)
|
||||||
{
|
{
|
||||||
return _notmuch_message_modify_property (message, key, value, FALSE);
|
return _notmuch_message_modify_property (message, key, value, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
notmuch_status_t
|
notmuch_status_t
|
||||||
notmuch_message_remove_property (notmuch_message_t *message, const char *key, const char *value)
|
notmuch_message_remove_property (notmuch_message_t *message, const char *key, const char *value)
|
||||||
{
|
{
|
||||||
return _notmuch_message_modify_property (message, key, value, TRUE);
|
return _notmuch_message_modify_property (message, key, value, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
notmuch_status_t
|
notmuch_status_t
|
||||||
|
|
|
@ -48,7 +48,7 @@ struct _notmuch_message {
|
||||||
unsigned long lazy_flags;
|
unsigned long lazy_flags;
|
||||||
|
|
||||||
/* Message document modified since last sync */
|
/* Message document modified since last sync */
|
||||||
notmuch_bool_t modified;
|
bool modified;
|
||||||
|
|
||||||
/* last view of database the struct is synced with */
|
/* last view of database the struct is synced with */
|
||||||
unsigned long last_view;
|
unsigned long last_view;
|
||||||
|
@ -62,16 +62,16 @@ struct _notmuch_message {
|
||||||
struct maildir_flag_tag {
|
struct maildir_flag_tag {
|
||||||
char flag;
|
char flag;
|
||||||
const char *tag;
|
const char *tag;
|
||||||
notmuch_bool_t inverse;
|
bool inverse;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ASCII ordered table of Maildir flags and associated tags */
|
/* ASCII ordered table of Maildir flags and associated tags */
|
||||||
static struct maildir_flag_tag flag2tag[] = {
|
static struct maildir_flag_tag flag2tag[] = {
|
||||||
{ 'D', "draft", FALSE},
|
{ 'D', "draft", false},
|
||||||
{ 'F', "flagged", FALSE},
|
{ 'F', "flagged", false},
|
||||||
{ 'P', "passed", FALSE},
|
{ 'P', "passed", false},
|
||||||
{ 'R', "replied", FALSE},
|
{ 'R', "replied", false},
|
||||||
{ 'S', "unread", TRUE }
|
{ 'S', "unread", true }
|
||||||
};
|
};
|
||||||
|
|
||||||
/* We end up having to call the destructor explicitly because we had
|
/* We end up having to call the destructor explicitly because we had
|
||||||
|
@ -270,7 +270,7 @@ _notmuch_message_create_for_message_id (notmuch_database_t *notmuch,
|
||||||
} catch (const Xapian::Error &error) {
|
} catch (const Xapian::Error &error) {
|
||||||
_notmuch_database_log(_notmuch_message_database (message), "A Xapian exception occurred creating message: %s\n",
|
_notmuch_database_log(_notmuch_message_database (message), "A Xapian exception occurred creating message: %s\n",
|
||||||
error.get_msg().c_str());
|
error.get_msg().c_str());
|
||||||
notmuch->exception_reported = TRUE;
|
notmuch->exception_reported = true;
|
||||||
*status_ret = NOTMUCH_PRIVATE_STATUS_XAPIAN_EXCEPTION;
|
*status_ret = NOTMUCH_PRIVATE_STATUS_XAPIAN_EXCEPTION;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -527,7 +527,7 @@ notmuch_message_get_header (notmuch_message_t *message, const char *header)
|
||||||
} catch (Xapian::Error &error) {
|
} catch (Xapian::Error &error) {
|
||||||
_notmuch_database_log(_notmuch_message_database (message), "A Xapian exception occurred when reading header: %s\n",
|
_notmuch_database_log(_notmuch_message_database (message), "A Xapian exception occurred when reading header: %s\n",
|
||||||
error.get_msg().c_str());
|
error.get_msg().c_str());
|
||||||
message->notmuch->exception_reported = TRUE;
|
message->notmuch->exception_reported = true;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -596,7 +596,7 @@ _notmuch_message_remove_terms (notmuch_message_t *message, const char *prefix)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
message->doc.remove_term ((*i));
|
message->doc.remove_term ((*i));
|
||||||
message->modified = TRUE;
|
message->modified = true;
|
||||||
} catch (const Xapian::InvalidArgumentError) {
|
} catch (const Xapian::InvalidArgumentError) {
|
||||||
/* Ignore failure to remove non-existent term. */
|
/* Ignore failure to remove non-existent term. */
|
||||||
}
|
}
|
||||||
|
@ -639,7 +639,7 @@ _notmuch_message_remove_indexed_terms (notmuch_message_t *message)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
message->doc.remove_term ((*i));
|
message->doc.remove_term ((*i));
|
||||||
message->modified = TRUE;
|
message->modified = true;
|
||||||
} catch (const Xapian::InvalidArgumentError) {
|
} catch (const Xapian::InvalidArgumentError) {
|
||||||
/* Ignore failure to remove non-existent term. */
|
/* Ignore failure to remove non-existent term. */
|
||||||
} catch (const Xapian::Error &error) {
|
} catch (const Xapian::Error &error) {
|
||||||
|
@ -648,7 +648,7 @@ _notmuch_message_remove_indexed_terms (notmuch_message_t *message)
|
||||||
if (!notmuch->exception_reported) {
|
if (!notmuch->exception_reported) {
|
||||||
_notmuch_database_log(_notmuch_message_database (message), "A Xapian exception occurred creating message: %s\n",
|
_notmuch_database_log(_notmuch_message_database (message), "A Xapian exception occurred creating message: %s\n",
|
||||||
error.get_msg().c_str());
|
error.get_msg().c_str());
|
||||||
notmuch->exception_reported = TRUE;
|
notmuch->exception_reported = true;
|
||||||
}
|
}
|
||||||
return NOTMUCH_PRIVATE_STATUS_XAPIAN_EXCEPTION;
|
return NOTMUCH_PRIVATE_STATUS_XAPIAN_EXCEPTION;
|
||||||
}
|
}
|
||||||
|
@ -703,7 +703,7 @@ _notmuch_message_add_folder_terms (notmuch_message_t *message,
|
||||||
|
|
||||||
talloc_free (folder);
|
talloc_free (folder);
|
||||||
|
|
||||||
message->modified = TRUE;
|
message->modified = true;
|
||||||
return NOTMUCH_STATUS_SUCCESS;
|
return NOTMUCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -905,7 +905,7 @@ void
|
||||||
_notmuch_message_clear_data (notmuch_message_t *message)
|
_notmuch_message_clear_data (notmuch_message_t *message)
|
||||||
{
|
{
|
||||||
message->doc.set_data ("");
|
message->doc.set_data ("");
|
||||||
message->modified = TRUE;
|
message->modified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1044,7 +1044,7 @@ notmuch_message_get_date (notmuch_message_t *message)
|
||||||
} catch (Xapian::Error &error) {
|
} catch (Xapian::Error &error) {
|
||||||
_notmuch_database_log(_notmuch_message_database (message), "A Xapian exception occurred when reading date: %s\n",
|
_notmuch_database_log(_notmuch_message_database (message), "A Xapian exception occurred when reading date: %s\n",
|
||||||
error.get_msg().c_str());
|
error.get_msg().c_str());
|
||||||
message->notmuch->exception_reported = TRUE;
|
message->notmuch->exception_reported = true;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1115,7 +1115,7 @@ _notmuch_message_set_header_values (notmuch_message_t *message,
|
||||||
Xapian::sortable_serialise (time_value));
|
Xapian::sortable_serialise (time_value));
|
||||||
message->doc.add_value (NOTMUCH_VALUE_FROM, from);
|
message->doc.add_value (NOTMUCH_VALUE_FROM, from);
|
||||||
message->doc.add_value (NOTMUCH_VALUE_SUBJECT, subject);
|
message->doc.add_value (NOTMUCH_VALUE_SUBJECT, subject);
|
||||||
message->modified = TRUE;
|
message->modified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Upgrade a message to support NOTMUCH_FEATURE_LAST_MOD. The caller
|
/* Upgrade a message to support NOTMUCH_FEATURE_LAST_MOD. The caller
|
||||||
|
@ -1125,7 +1125,7 @@ _notmuch_message_upgrade_last_mod (notmuch_message_t *message)
|
||||||
{
|
{
|
||||||
/* _notmuch_message_sync will update the last modification
|
/* _notmuch_message_sync will update the last modification
|
||||||
* revision; we just have to ask it to. */
|
* revision; we just have to ask it to. */
|
||||||
message->modified = TRUE;
|
message->modified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Synchronize changes made to message->doc out into the database. */
|
/* Synchronize changes made to message->doc out into the database. */
|
||||||
|
@ -1154,7 +1154,7 @@ _notmuch_message_sync (notmuch_message_t *message)
|
||||||
|
|
||||||
db = static_cast <Xapian::WritableDatabase *> (message->notmuch->xapian_db);
|
db = static_cast <Xapian::WritableDatabase *> (message->notmuch->xapian_db);
|
||||||
db->replace_document (message->doc_id, message->doc);
|
db->replace_document (message->doc_id, message->doc);
|
||||||
message->modified = FALSE;
|
message->modified = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Delete a message document from the database, leaving a ghost
|
/* Delete a message document from the database, leaving a ghost
|
||||||
|
@ -1170,7 +1170,7 @@ _notmuch_message_delete (notmuch_message_t *message)
|
||||||
notmuch_database_t *notmuch;
|
notmuch_database_t *notmuch;
|
||||||
notmuch_query_t *query;
|
notmuch_query_t *query;
|
||||||
unsigned int count = 0;
|
unsigned int count = 0;
|
||||||
notmuch_bool_t is_ghost;
|
bool is_ghost;
|
||||||
|
|
||||||
mid = notmuch_message_get_message_id (message);
|
mid = notmuch_message_get_message_id (message);
|
||||||
tid = notmuch_message_get_thread_id (message);
|
tid = notmuch_message_get_thread_id (message);
|
||||||
|
@ -1299,7 +1299,7 @@ _notmuch_message_add_term (notmuch_message_t *message,
|
||||||
return NOTMUCH_PRIVATE_STATUS_TERM_TOO_LONG;
|
return NOTMUCH_PRIVATE_STATUS_TERM_TOO_LONG;
|
||||||
|
|
||||||
message->doc.add_term (term, 0);
|
message->doc.add_term (term, 0);
|
||||||
message->modified = TRUE;
|
message->modified = true;
|
||||||
|
|
||||||
talloc_free (term);
|
talloc_free (term);
|
||||||
|
|
||||||
|
@ -1368,7 +1368,7 @@ _notmuch_message_remove_term (notmuch_message_t *message,
|
||||||
|
|
||||||
try {
|
try {
|
||||||
message->doc.remove_term (term);
|
message->doc.remove_term (term);
|
||||||
message->modified = TRUE;
|
message->modified = true;
|
||||||
} catch (const Xapian::InvalidArgumentError) {
|
} catch (const Xapian::InvalidArgumentError) {
|
||||||
/* We'll let the philosophers try to wrestle with the
|
/* We'll let the philosophers try to wrestle with the
|
||||||
* question of whether failing to remove that which was not
|
* question of whether failing to remove that which was not
|
||||||
|
@ -1387,10 +1387,10 @@ notmuch_private_status_t
|
||||||
_notmuch_message_has_term (notmuch_message_t *message,
|
_notmuch_message_has_term (notmuch_message_t *message,
|
||||||
const char *prefix_name,
|
const char *prefix_name,
|
||||||
const char *value,
|
const char *value,
|
||||||
notmuch_bool_t *result)
|
bool *result)
|
||||||
{
|
{
|
||||||
char *term;
|
char *term;
|
||||||
notmuch_bool_t out = FALSE;
|
bool out = false;
|
||||||
notmuch_private_status_t status = NOTMUCH_PRIVATE_STATUS_SUCCESS;
|
notmuch_private_status_t status = NOTMUCH_PRIVATE_STATUS_SUCCESS;
|
||||||
|
|
||||||
if (value == NULL)
|
if (value == NULL)
|
||||||
|
@ -1408,7 +1408,7 @@ _notmuch_message_has_term (notmuch_message_t *message,
|
||||||
i.skip_to (term);
|
i.skip_to (term);
|
||||||
if (i != message->doc.termlist_end () &&
|
if (i != message->doc.termlist_end () &&
|
||||||
!strcmp ((*i).c_str (), term))
|
!strcmp ((*i).c_str (), term))
|
||||||
out = TRUE;
|
out = true;
|
||||||
} catch (Xapian::Error &error) {
|
} catch (Xapian::Error &error) {
|
||||||
status = NOTMUCH_PRIVATE_STATUS_XAPIAN_EXCEPTION;
|
status = NOTMUCH_PRIVATE_STATUS_XAPIAN_EXCEPTION;
|
||||||
}
|
}
|
||||||
|
@ -1516,7 +1516,7 @@ _filename_is_in_maildir (const char *filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_ensure_maildir_flags (notmuch_message_t *message, notmuch_bool_t force)
|
_ensure_maildir_flags (notmuch_message_t *message, bool force)
|
||||||
{
|
{
|
||||||
const char *flags;
|
const char *flags;
|
||||||
notmuch_filenames_t *filenames;
|
notmuch_filenames_t *filenames;
|
||||||
|
@ -1563,7 +1563,7 @@ _ensure_maildir_flags (notmuch_message_t *message, notmuch_bool_t force)
|
||||||
notmuch_bool_t
|
notmuch_bool_t
|
||||||
notmuch_message_has_maildir_flag (notmuch_message_t *message, char flag)
|
notmuch_message_has_maildir_flag (notmuch_message_t *message, char flag)
|
||||||
{
|
{
|
||||||
_ensure_maildir_flags (message, FALSE);
|
_ensure_maildir_flags (message, false);
|
||||||
return message->maildir_flags && (strchr (message->maildir_flags, flag) != NULL);
|
return message->maildir_flags && (strchr (message->maildir_flags, flag) != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1573,7 +1573,7 @@ notmuch_message_maildir_flags_to_tags (notmuch_message_t *message)
|
||||||
notmuch_status_t status;
|
notmuch_status_t status;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
_ensure_maildir_flags (message, TRUE);
|
_ensure_maildir_flags (message, true);
|
||||||
/* If none of the filenames have any maildir info field (not even
|
/* If none of the filenames have any maildir info field (not even
|
||||||
* an empty info with no flags set) then there's no information to
|
* an empty info with no flags set) then there's no information to
|
||||||
* go on, so do nothing. */
|
* go on, so do nothing. */
|
||||||
|
@ -1685,7 +1685,7 @@ _new_maildir_filename (void *ctx,
|
||||||
char *filename_new, *dir;
|
char *filename_new, *dir;
|
||||||
char flag_map[128];
|
char flag_map[128];
|
||||||
int flags_in_map = 0;
|
int flags_in_map = 0;
|
||||||
notmuch_bool_t flags_changed = FALSE;
|
bool flags_changed = false;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
char *s;
|
char *s;
|
||||||
|
|
||||||
|
@ -1726,7 +1726,7 @@ _new_maildir_filename (void *ctx,
|
||||||
if (flag_map[flag] == 0) {
|
if (flag_map[flag] == 0) {
|
||||||
flag_map[flag] = 1;
|
flag_map[flag] = 1;
|
||||||
flags_in_map++;
|
flags_in_map++;
|
||||||
flags_changed = TRUE;
|
flags_changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1735,7 +1735,7 @@ _new_maildir_filename (void *ctx,
|
||||||
if (flag_map[flag]) {
|
if (flag_map[flag]) {
|
||||||
flag_map[flag] = 0;
|
flag_map[flag] = 0;
|
||||||
flags_in_map--;
|
flags_in_map--;
|
||||||
flags_changed = TRUE;
|
flags_changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1953,7 +1953,7 @@ _notmuch_message_property_map (notmuch_message_t *message)
|
||||||
return message->property_map;
|
return message->property_map;
|
||||||
}
|
}
|
||||||
|
|
||||||
notmuch_bool_t
|
bool
|
||||||
_notmuch_message_frozen (notmuch_message_t *message)
|
_notmuch_message_frozen (notmuch_message_t *message)
|
||||||
{
|
{
|
||||||
return message->frozen;
|
return message->frozen;
|
||||||
|
|
|
@ -68,7 +68,7 @@ _notmuch_messages_create (notmuch_message_list_t *list)
|
||||||
if (unlikely (messages == NULL))
|
if (unlikely (messages == NULL))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
messages->is_of_list_type = TRUE;
|
messages->is_of_list_type = true;
|
||||||
messages->iterator = list->head;
|
messages->iterator = list->head;
|
||||||
|
|
||||||
return messages;
|
return messages;
|
||||||
|
@ -93,7 +93,7 @@ notmuch_bool_t
|
||||||
notmuch_messages_valid (notmuch_messages_t *messages)
|
notmuch_messages_valid (notmuch_messages_t *messages)
|
||||||
{
|
{
|
||||||
if (messages == NULL)
|
if (messages == NULL)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
if (! messages->is_of_list_type)
|
if (! messages->is_of_list_type)
|
||||||
return _notmuch_mset_messages_valid (messages);
|
return _notmuch_mset_messages_valid (messages);
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#ifndef _GNU_SOURCE
|
#ifndef _GNU_SOURCE
|
||||||
#define _GNU_SOURCE /* For getline and asprintf */
|
#define _GNU_SOURCE /* For getline and asprintf */
|
||||||
#endif
|
#endif
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
|
@ -282,7 +283,7 @@ notmuch_private_status_t
|
||||||
_notmuch_message_has_term (notmuch_message_t *message,
|
_notmuch_message_has_term (notmuch_message_t *message,
|
||||||
const char *prefix_name,
|
const char *prefix_name,
|
||||||
const char *value,
|
const char *value,
|
||||||
notmuch_bool_t *result);
|
bool *result);
|
||||||
|
|
||||||
notmuch_private_status_t
|
notmuch_private_status_t
|
||||||
_notmuch_message_gen_terms (notmuch_message_t *message,
|
_notmuch_message_gen_terms (notmuch_message_t *message,
|
||||||
|
@ -465,7 +466,7 @@ typedef struct _notmuch_message_list {
|
||||||
* ignorance of that here. (See notmuch_mset_messages_t in query.cc)
|
* ignorance of that here. (See notmuch_mset_messages_t in query.cc)
|
||||||
*/
|
*/
|
||||||
struct _notmuch_messages {
|
struct _notmuch_messages {
|
||||||
notmuch_bool_t is_of_list_type;
|
bool is_of_list_type;
|
||||||
notmuch_doc_id_set_t *excluded_doc_ids;
|
notmuch_doc_id_set_t *excluded_doc_ids;
|
||||||
notmuch_message_node_t *iterator;
|
notmuch_message_node_t *iterator;
|
||||||
};
|
};
|
||||||
|
@ -482,7 +483,7 @@ _notmuch_messages_create (notmuch_message_list_t *list);
|
||||||
|
|
||||||
/* query.cc */
|
/* query.cc */
|
||||||
|
|
||||||
notmuch_bool_t
|
bool
|
||||||
_notmuch_mset_messages_valid (notmuch_messages_t *messages);
|
_notmuch_mset_messages_valid (notmuch_messages_t *messages);
|
||||||
|
|
||||||
notmuch_message_t *
|
notmuch_message_t *
|
||||||
|
@ -491,7 +492,7 @@ _notmuch_mset_messages_get (notmuch_messages_t *messages);
|
||||||
void
|
void
|
||||||
_notmuch_mset_messages_move_to_next (notmuch_messages_t *messages);
|
_notmuch_mset_messages_move_to_next (notmuch_messages_t *messages);
|
||||||
|
|
||||||
notmuch_bool_t
|
bool
|
||||||
_notmuch_doc_id_set_contains (notmuch_doc_id_set_t *doc_ids,
|
_notmuch_doc_id_set_contains (notmuch_doc_id_set_t *doc_ids,
|
||||||
unsigned int doc_id);
|
unsigned int doc_id);
|
||||||
|
|
||||||
|
@ -591,9 +592,9 @@ _notmuch_string_map_get (notmuch_string_map_t *map, const char *key);
|
||||||
|
|
||||||
notmuch_string_map_iterator_t *
|
notmuch_string_map_iterator_t *
|
||||||
_notmuch_string_map_iterator_create (notmuch_string_map_t *map, const char *key,
|
_notmuch_string_map_iterator_create (notmuch_string_map_t *map, const char *key,
|
||||||
notmuch_bool_t exact);
|
bool exact);
|
||||||
|
|
||||||
notmuch_bool_t
|
bool
|
||||||
_notmuch_string_map_iterator_valid (notmuch_string_map_iterator_t *iter);
|
_notmuch_string_map_iterator_valid (notmuch_string_map_iterator_t *iter);
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
42
lib/query.cc
42
lib/query.cc
|
@ -29,7 +29,7 @@ struct _notmuch_query {
|
||||||
notmuch_sort_t sort;
|
notmuch_sort_t sort;
|
||||||
notmuch_string_list_t *exclude_terms;
|
notmuch_string_list_t *exclude_terms;
|
||||||
notmuch_exclude_t omit_excluded;
|
notmuch_exclude_t omit_excluded;
|
||||||
notmuch_bool_t parsed;
|
bool parsed;
|
||||||
Xapian::Query xapian_query;
|
Xapian::Query xapian_query;
|
||||||
std::set<std::string> terms;
|
std::set<std::string> terms;
|
||||||
};
|
};
|
||||||
|
@ -62,12 +62,12 @@ struct _notmuch_threads {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* We need this in the message functions so forward declare. */
|
/* We need this in the message functions so forward declare. */
|
||||||
static notmuch_bool_t
|
static bool
|
||||||
_notmuch_doc_id_set_init (void *ctx,
|
_notmuch_doc_id_set_init (void *ctx,
|
||||||
notmuch_doc_id_set_t *doc_ids,
|
notmuch_doc_id_set_t *doc_ids,
|
||||||
GArray *arr);
|
GArray *arr);
|
||||||
|
|
||||||
static notmuch_bool_t
|
static bool
|
||||||
_debug_query (void)
|
_debug_query (void)
|
||||||
{
|
{
|
||||||
char *env = getenv ("NOTMUCH_DEBUG_QUERY");
|
char *env = getenv ("NOTMUCH_DEBUG_QUERY");
|
||||||
|
@ -97,7 +97,7 @@ notmuch_query_create (notmuch_database_t *notmuch,
|
||||||
|
|
||||||
new (&query->xapian_query) Xapian::Query ();
|
new (&query->xapian_query) Xapian::Query ();
|
||||||
new (&query->terms) std::set<std::string> ();
|
new (&query->terms) std::set<std::string> ();
|
||||||
query->parsed = FALSE;
|
query->parsed = false;
|
||||||
|
|
||||||
talloc_set_destructor (query, _notmuch_query_destructor);
|
talloc_set_destructor (query, _notmuch_query_destructor);
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ _notmuch_query_ensure_parsed (notmuch_query_t *query)
|
||||||
t != query->xapian_query.get_terms_end (); ++t)
|
t != query->xapian_query.get_terms_end (); ++t)
|
||||||
query->terms.insert (*t);
|
query->terms.insert (*t);
|
||||||
|
|
||||||
query->parsed = TRUE;
|
query->parsed = true;
|
||||||
|
|
||||||
} catch (const Xapian::Error &error) {
|
} catch (const Xapian::Error &error) {
|
||||||
if (!query->notmuch->exception_reported) {
|
if (!query->notmuch->exception_reported) {
|
||||||
|
@ -144,7 +144,7 @@ _notmuch_query_ensure_parsed (notmuch_query_t *query)
|
||||||
_notmuch_database_log_append (query->notmuch,
|
_notmuch_database_log_append (query->notmuch,
|
||||||
"Query string was: %s\n",
|
"Query string was: %s\n",
|
||||||
query->query_string);
|
query->query_string);
|
||||||
query->notmuch->exception_reported = TRUE;
|
query->notmuch->exception_reported = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
|
return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
|
||||||
|
@ -261,7 +261,7 @@ _notmuch_query_search_documents (notmuch_query_t *query,
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
messages->base.is_of_list_type = FALSE;
|
messages->base.is_of_list_type = false;
|
||||||
messages->base.iterator = NULL;
|
messages->base.iterator = NULL;
|
||||||
messages->notmuch = notmuch;
|
messages->notmuch = notmuch;
|
||||||
new (&messages->iterator) Xapian::MSetIterator ();
|
new (&messages->iterator) Xapian::MSetIterator ();
|
||||||
|
@ -304,7 +304,7 @@ _notmuch_query_search_documents (notmuch_query_t *query,
|
||||||
|
|
||||||
mset = enquire.get_mset (0, notmuch->xapian_db->get_doccount ());
|
mset = enquire.get_mset (0, notmuch->xapian_db->get_doccount ());
|
||||||
|
|
||||||
GArray *excluded_doc_ids = g_array_new (FALSE, FALSE, sizeof (unsigned int));
|
GArray *excluded_doc_ids = g_array_new (false, false, sizeof (unsigned int));
|
||||||
|
|
||||||
for (iterator = mset.begin (); iterator != mset.end (); iterator++) {
|
for (iterator = mset.begin (); iterator != mset.end (); iterator++) {
|
||||||
unsigned int doc_id = *iterator;
|
unsigned int doc_id = *iterator;
|
||||||
|
@ -322,13 +322,13 @@ _notmuch_query_search_documents (notmuch_query_t *query,
|
||||||
|
|
||||||
switch (query->sort) {
|
switch (query->sort) {
|
||||||
case NOTMUCH_SORT_OLDEST_FIRST:
|
case NOTMUCH_SORT_OLDEST_FIRST:
|
||||||
enquire.set_sort_by_value (NOTMUCH_VALUE_TIMESTAMP, FALSE);
|
enquire.set_sort_by_value (NOTMUCH_VALUE_TIMESTAMP, false);
|
||||||
break;
|
break;
|
||||||
case NOTMUCH_SORT_NEWEST_FIRST:
|
case NOTMUCH_SORT_NEWEST_FIRST:
|
||||||
enquire.set_sort_by_value (NOTMUCH_VALUE_TIMESTAMP, TRUE);
|
enquire.set_sort_by_value (NOTMUCH_VALUE_TIMESTAMP, true);
|
||||||
break;
|
break;
|
||||||
case NOTMUCH_SORT_MESSAGE_ID:
|
case NOTMUCH_SORT_MESSAGE_ID:
|
||||||
enquire.set_sort_by_value (NOTMUCH_VALUE_MESSAGE_ID, FALSE);
|
enquire.set_sort_by_value (NOTMUCH_VALUE_MESSAGE_ID, false);
|
||||||
break;
|
break;
|
||||||
case NOTMUCH_SORT_UNSORTED:
|
case NOTMUCH_SORT_UNSORTED:
|
||||||
break;
|
break;
|
||||||
|
@ -359,13 +359,13 @@ _notmuch_query_search_documents (notmuch_query_t *query,
|
||||||
"Query string was: %s\n",
|
"Query string was: %s\n",
|
||||||
query->query_string);
|
query->query_string);
|
||||||
|
|
||||||
notmuch->exception_reported = TRUE;
|
notmuch->exception_reported = true;
|
||||||
talloc_free (messages);
|
talloc_free (messages);
|
||||||
return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
|
return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
notmuch_bool_t
|
bool
|
||||||
_notmuch_mset_messages_valid (notmuch_messages_t *messages)
|
_notmuch_mset_messages_valid (notmuch_messages_t *messages)
|
||||||
{
|
{
|
||||||
notmuch_mset_messages_t *mset_messages;
|
notmuch_mset_messages_t *mset_messages;
|
||||||
|
@ -415,7 +415,7 @@ _notmuch_mset_messages_get (notmuch_messages_t *messages)
|
||||||
|
|
||||||
if (messages->excluded_doc_ids &&
|
if (messages->excluded_doc_ids &&
|
||||||
_notmuch_doc_id_set_contains (messages->excluded_doc_ids, doc_id))
|
_notmuch_doc_id_set_contains (messages->excluded_doc_ids, doc_id))
|
||||||
notmuch_message_set_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED, TRUE);
|
notmuch_message_set_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED, true);
|
||||||
|
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
@ -430,7 +430,7 @@ _notmuch_mset_messages_move_to_next (notmuch_messages_t *messages)
|
||||||
mset_messages->iterator++;
|
mset_messages->iterator++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static notmuch_bool_t
|
static bool
|
||||||
_notmuch_doc_id_set_init (void *ctx,
|
_notmuch_doc_id_set_init (void *ctx,
|
||||||
notmuch_doc_id_set_t *doc_ids,
|
notmuch_doc_id_set_t *doc_ids,
|
||||||
GArray *arr)
|
GArray *arr)
|
||||||
|
@ -443,7 +443,7 @@ _notmuch_doc_id_set_init (void *ctx,
|
||||||
bitmap = talloc_zero_array (ctx, unsigned char, DOCIDSET_WORD(max) + 1);
|
bitmap = talloc_zero_array (ctx, unsigned char, DOCIDSET_WORD(max) + 1);
|
||||||
|
|
||||||
if (bitmap == NULL)
|
if (bitmap == NULL)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
doc_ids->bitmap = bitmap;
|
doc_ids->bitmap = bitmap;
|
||||||
doc_ids->bound = max + 1;
|
doc_ids->bound = max + 1;
|
||||||
|
@ -453,15 +453,15 @@ _notmuch_doc_id_set_init (void *ctx,
|
||||||
bitmap[DOCIDSET_WORD(doc_id)] |= 1 << DOCIDSET_BIT(doc_id);
|
bitmap[DOCIDSET_WORD(doc_id)] |= 1 << DOCIDSET_BIT(doc_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
notmuch_bool_t
|
bool
|
||||||
_notmuch_doc_id_set_contains (notmuch_doc_id_set_t *doc_ids,
|
_notmuch_doc_id_set_contains (notmuch_doc_id_set_t *doc_ids,
|
||||||
unsigned int doc_id)
|
unsigned int doc_id)
|
||||||
{
|
{
|
||||||
if (doc_id >= doc_ids->bound)
|
if (doc_id >= doc_ids->bound)
|
||||||
return FALSE;
|
return false;
|
||||||
return doc_ids->bitmap[DOCIDSET_WORD(doc_id)] & (1 << DOCIDSET_BIT(doc_id));
|
return doc_ids->bitmap[DOCIDSET_WORD(doc_id)] & (1 << DOCIDSET_BIT(doc_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -514,7 +514,7 @@ notmuch_query_search_threads (notmuch_query_t *query,
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
threads->doc_ids = g_array_new (FALSE, FALSE, sizeof (unsigned int));
|
threads->doc_ids = g_array_new (false, false, sizeof (unsigned int));
|
||||||
while (notmuch_messages_valid (messages)) {
|
while (notmuch_messages_valid (messages)) {
|
||||||
unsigned int doc_id = _notmuch_mset_messages_get_doc_id (messages);
|
unsigned int doc_id = _notmuch_mset_messages_get_doc_id (messages);
|
||||||
g_array_append_val (threads->doc_ids, doc_id);
|
g_array_append_val (threads->doc_ids, doc_id);
|
||||||
|
@ -546,7 +546,7 @@ notmuch_threads_valid (notmuch_threads_t *threads)
|
||||||
unsigned int doc_id;
|
unsigned int doc_id;
|
||||||
|
|
||||||
if (! threads)
|
if (! threads)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
while (threads->doc_id_pos < threads->doc_ids->len) {
|
while (threads->doc_id_pos < threads->doc_ids->len) {
|
||||||
doc_id = g_array_index (threads->doc_ids, unsigned int,
|
doc_id = g_array_index (threads->doc_ids, unsigned int,
|
||||||
|
|
|
@ -33,14 +33,14 @@ typedef struct _notmuch_string_pair_t {
|
||||||
} notmuch_string_pair_t;
|
} notmuch_string_pair_t;
|
||||||
|
|
||||||
struct _notmuch_string_map {
|
struct _notmuch_string_map {
|
||||||
notmuch_bool_t sorted;
|
bool sorted;
|
||||||
size_t length;
|
size_t length;
|
||||||
notmuch_string_pair_t *pairs;
|
notmuch_string_pair_t *pairs;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _notmuch_string_map_iterator {
|
struct _notmuch_string_map_iterator {
|
||||||
notmuch_string_pair_t *current;
|
notmuch_string_pair_t *current;
|
||||||
notmuch_bool_t exact;
|
bool exact;
|
||||||
const char *key;
|
const char *key;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ _notmuch_string_map_create (const void *ctx)
|
||||||
|
|
||||||
map->length = 0;
|
map->length = 0;
|
||||||
map->pairs = NULL;
|
map->pairs = NULL;
|
||||||
map->sorted = TRUE;
|
map->sorted = true;
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ _notmuch_string_map_append (notmuch_string_map_t *map,
|
||||||
{
|
{
|
||||||
|
|
||||||
map->length++;
|
map->length++;
|
||||||
map->sorted = FALSE;
|
map->sorted = false;
|
||||||
|
|
||||||
if (map->pairs)
|
if (map->pairs)
|
||||||
map->pairs = talloc_realloc (map, map->pairs, notmuch_string_pair_t, map->length + 1);
|
map->pairs = talloc_realloc (map, map->pairs, notmuch_string_pair_t, map->length + 1);
|
||||||
|
@ -103,11 +103,11 @@ _notmuch_string_map_sort (notmuch_string_map_t *map)
|
||||||
|
|
||||||
qsort (map->pairs, map->length, sizeof (notmuch_string_pair_t), cmppair);
|
qsort (map->pairs, map->length, sizeof (notmuch_string_pair_t), cmppair);
|
||||||
|
|
||||||
map->sorted = TRUE;
|
map->sorted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static notmuch_bool_t
|
static bool
|
||||||
string_cmp (const char *a, const char *b, notmuch_bool_t exact)
|
string_cmp (const char *a, const char *b, bool exact)
|
||||||
{
|
{
|
||||||
if (exact)
|
if (exact)
|
||||||
return (strcmp (a, b));
|
return (strcmp (a, b));
|
||||||
|
@ -116,7 +116,7 @@ string_cmp (const char *a, const char *b, notmuch_bool_t exact)
|
||||||
}
|
}
|
||||||
|
|
||||||
static notmuch_string_pair_t *
|
static notmuch_string_pair_t *
|
||||||
bsearch_first (notmuch_string_pair_t *array, size_t len, const char *key, notmuch_bool_t exact)
|
bsearch_first (notmuch_string_pair_t *array, size_t len, const char *key, bool exact)
|
||||||
{
|
{
|
||||||
size_t first = 0;
|
size_t first = 0;
|
||||||
size_t last = len - 1;
|
size_t last = len - 1;
|
||||||
|
@ -151,7 +151,7 @@ _notmuch_string_map_get (notmuch_string_map_t *map, const char *key)
|
||||||
/* this means that calling append invalidates iterators */
|
/* this means that calling append invalidates iterators */
|
||||||
_notmuch_string_map_sort (map);
|
_notmuch_string_map_sort (map);
|
||||||
|
|
||||||
pair = bsearch_first (map->pairs, map->length, key, TRUE);
|
pair = bsearch_first (map->pairs, map->length, key, true);
|
||||||
if (! pair)
|
if (! pair)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ _notmuch_string_map_get (notmuch_string_map_t *map, const char *key)
|
||||||
|
|
||||||
notmuch_string_map_iterator_t *
|
notmuch_string_map_iterator_t *
|
||||||
_notmuch_string_map_iterator_create (notmuch_string_map_t *map, const char *key,
|
_notmuch_string_map_iterator_create (notmuch_string_map_t *map, const char *key,
|
||||||
notmuch_bool_t exact)
|
bool exact)
|
||||||
{
|
{
|
||||||
notmuch_string_map_iterator_t *iter;
|
notmuch_string_map_iterator_t *iter;
|
||||||
|
|
||||||
|
@ -179,15 +179,15 @@ _notmuch_string_map_iterator_create (notmuch_string_map_t *map, const char *key,
|
||||||
return iter;
|
return iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
notmuch_bool_t
|
bool
|
||||||
_notmuch_string_map_iterator_valid (notmuch_string_map_iterator_t *iterator)
|
_notmuch_string_map_iterator_valid (notmuch_string_map_iterator_t *iterator)
|
||||||
{
|
{
|
||||||
if (iterator->current == NULL)
|
if (iterator->current == NULL)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
/* sentinel */
|
/* sentinel */
|
||||||
if (iterator->current->key == NULL)
|
if (iterator->current->key == NULL)
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
return (0 == string_cmp (iterator->key, iterator->current->key, iterator->exact));
|
return (0 == string_cmp (iterator->key, iterator->current->key, iterator->exact));
|
||||||
|
|
||||||
|
|
|
@ -59,12 +59,12 @@ _notmuch_thread_destructor (notmuch_thread_t *thread)
|
||||||
g_hash_table_unref (thread->message_hash);
|
g_hash_table_unref (thread->message_hash);
|
||||||
|
|
||||||
if (thread->authors_array) {
|
if (thread->authors_array) {
|
||||||
g_ptr_array_free (thread->authors_array, TRUE);
|
g_ptr_array_free (thread->authors_array, true);
|
||||||
thread->authors_array = NULL;
|
thread->authors_array = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (thread->matched_authors_array) {
|
if (thread->matched_authors_array) {
|
||||||
g_ptr_array_free (thread->matched_authors_array, TRUE);
|
g_ptr_array_free (thread->matched_authors_array, true);
|
||||||
thread->matched_authors_array = NULL;
|
thread->matched_authors_array = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,9 +156,9 @@ _resolve_thread_authors_string (notmuch_thread_t *thread)
|
||||||
first_non_matched_author = 0;
|
first_non_matched_author = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_ptr_array_free (thread->authors_array, TRUE);
|
g_ptr_array_free (thread->authors_array, true);
|
||||||
thread->authors_array = NULL;
|
thread->authors_array = NULL;
|
||||||
g_ptr_array_free (thread->matched_authors_array, TRUE);
|
g_ptr_array_free (thread->matched_authors_array, true);
|
||||||
thread->matched_authors_array = NULL;
|
thread->matched_authors_array = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,7 +239,7 @@ _thread_add_message (notmuch_thread_t *thread,
|
||||||
InternetAddress *address;
|
InternetAddress *address;
|
||||||
const char *from, *author;
|
const char *from, *author;
|
||||||
char *clean_author;
|
char *clean_author;
|
||||||
notmuch_bool_t message_excluded = FALSE;
|
bool message_excluded = false;
|
||||||
|
|
||||||
if (omit_exclude != NOTMUCH_EXCLUDE_FALSE) {
|
if (omit_exclude != NOTMUCH_EXCLUDE_FALSE) {
|
||||||
for (tags = notmuch_message_get_tags (message);
|
for (tags = notmuch_message_get_tags (message);
|
||||||
|
@ -254,7 +254,7 @@ _thread_add_message (notmuch_thread_t *thread,
|
||||||
{
|
{
|
||||||
/* Check for an empty string, and then ignore initial 'K'. */
|
/* Check for an empty string, and then ignore initial 'K'. */
|
||||||
if (*(term->string) && strcmp(tag, (term->string + 1)) == 0) {
|
if (*(term->string) && strcmp(tag, (term->string + 1)) == 0) {
|
||||||
message_excluded = TRUE;
|
message_excluded = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -310,7 +310,7 @@ _thread_add_message (notmuch_thread_t *thread,
|
||||||
|
|
||||||
/* Mark excluded messages. */
|
/* Mark excluded messages. */
|
||||||
if (message_excluded)
|
if (message_excluded)
|
||||||
notmuch_message_set_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED, TRUE);
|
notmuch_message_set_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in a new issue