void *children; /* talloc_context */
};
-static const char * _notmuch_config_key_to_string (notmuch_config_key_t key);
+static const char *_notmuch_config_key_to_string (notmuch_config_key_t key);
static int
_notmuch_config_list_destroy (notmuch_config_list_t *list)
const char *key,
char **value)
{
- const char* stored_val;
+ const char *stored_val;
notmuch_status_t status;
if (! notmuch->config) {
if (! stored_val) {
/* XXX in principle this API should be fixed so empty string
* is distinguished from not found */
- *value = strdup("");
+ *value = strdup ("");
} else {
*value = strdup (stored_val);
}
talloc_set_destructor (list, _notmuch_config_list_destroy);
} 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 ());
notmuch->exception_reported = true;
status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
if (status != NOTMUCH_STATUS_XAPIAN_EXCEPTION)
_notmuch_config_list_destroy (list);
}
- } else {
+ } else {
talloc_set_destructor (list, _notmuch_config_list_destroy);
}
return true;
}
-static inline char * _key_from_iterator (notmuch_config_list_t *list) {
+static inline char *
+_key_from_iterator (notmuch_config_list_t *list)
+{
return talloc_strdup (list, (*list->iterator).c_str () + CONFIG_PREFIX.length ());
}
if (notmuch->config == NULL)
notmuch->config = _notmuch_string_map_create (notmuch);
- if (unlikely(notmuch->config == NULL))
+ if (unlikely (notmuch->config == NULL))
return NOTMUCH_STATUS_OUT_OF_MEMORY;
status = notmuch_database_get_config_list (notmuch, "", &list);
goto DONE;
values = talloc (notmuch, notmuch_config_values_t);
- if (unlikely(! values))
+ if (unlikely (! values))
goto DONE;
values->children = talloc_new (values);
values->iterator = strsplit_len (values->string, ';', &(values->tok_len));
ok = true;
- DONE:
- if (!ok) {
+ DONE:
+ if (! ok) {
if (values)
- talloc_free(values);
+ talloc_free (values);
return NULL;
}
return values;
}
notmuch_bool_t
-notmuch_config_values_valid (notmuch_config_values_t *values) {
+notmuch_config_values_valid (notmuch_config_values_t *values)
+{
if (! values)
return false;
}
const char *
-notmuch_config_values_get (notmuch_config_values_t *values) {
+notmuch_config_values_get (notmuch_config_values_t *values)
+{
return talloc_strndup (values, values->iterator, values->tok_len);
}
void
-notmuch_config_values_start (notmuch_config_values_t *values) {
+notmuch_config_values_start (notmuch_config_values_t *values)
+{
if (values == NULL)
return;
if (values->children) {
}
void
-notmuch_config_values_move_to_next (notmuch_config_values_t *values) {
+notmuch_config_values_move_to_next (notmuch_config_values_t *values)
+{
values->iterator += values->tok_len;
values->iterator = strsplit_len (values->iterator, ';', &(values->tok_len));
}
void
-notmuch_config_values_destroy (notmuch_config_values_t *values) {
+notmuch_config_values_destroy (notmuch_config_values_t *values)
+{
talloc_free (values);
}
if (notmuch->config == NULL)
notmuch->config = _notmuch_string_map_create (notmuch);
- if (unlikely(notmuch->config == NULL)) {
+ if (unlikely (notmuch->config == NULL)) {
status = NOTMUCH_STATUS_OUT_OF_MEMORY;
goto DONE;
}
for (groups = g_key_file_get_groups (file, NULL); *groups; groups++) {
for (keys = g_key_file_get_keys (file, *groups, NULL, NULL); *keys; keys++) {
- char *absolute_key = talloc_asprintf(notmuch, "%s.%s", *groups, *keys);
+ char *absolute_key = talloc_asprintf (notmuch, "%s.%s", *groups, *keys);
val = g_key_file_get_value (file, *groups, *keys, NULL);
if (! val) {
status = NOTMUCH_STATUS_FILE_ERROR;
}
}
- DONE:
+ DONE:
return status;
}
}
static const char *
-_notmuch_config_key_to_string (notmuch_config_key_t key) {
+_notmuch_config_key_to_string (notmuch_config_key_t key)
+{
switch (key) {
case NOTMUCH_CONFIG_DATABASE_PATH:
return "database.path";
}
static const char *
-_notmuch_config_default (void *ctx, notmuch_config_key_t key) {
+_notmuch_config_default (void *ctx, notmuch_config_key_t key)
+{
char *path;
switch (key) {
default:
case NOTMUCH_CONFIG_LAST:
INTERNAL_ERROR ("illegal key enum %d", key);
- }
+ }
}
notmuch_status_t
-_notmuch_config_load_defaults (notmuch_database_t *notmuch) {
+_notmuch_config_load_defaults (notmuch_database_t *notmuch)
+{
notmuch_config_key_t key;
+
for (key = NOTMUCH_CONFIG_FIRST;
key < NOTMUCH_CONFIG_LAST;
- key = notmuch_config_key_t(key + 1)) {
+ key = notmuch_config_key_t (key + 1)) {
const char *val = notmuch_config_get (notmuch, key);
const char *key_string = _notmuch_config_key_to_string (key);
val = _notmuch_string_map_get (notmuch->config, key_string);
if (! val) {
- _notmuch_string_map_set (notmuch->config, key_string, _notmuch_config_default (notmuch, key));
+ _notmuch_string_map_set (notmuch->config, key_string, _notmuch_config_default (notmuch,
+ key));
}
}
return NOTMUCH_STATUS_SUCCESS;
}
const char *
-notmuch_config_get (notmuch_database_t *notmuch, notmuch_config_key_t key) {
+notmuch_config_get (notmuch_database_t *notmuch, notmuch_config_key_t key)
+{
return _notmuch_string_map_get (notmuch->config, _notmuch_config_key_to_string (key));
}
notmuch_status_t
-notmuch_config_set (notmuch_database_t *notmuch, notmuch_config_key_t key, const char *val) {
+notmuch_config_set (notmuch_database_t *notmuch, notmuch_config_key_t key, const char *val)
+{
return notmuch_database_set_config (notmuch, _notmuch_config_key_to_string (key), val);
}
void
-_notmuch_config_cache (notmuch_database_t *notmuch, notmuch_config_key_t key, const char *val) {
+_notmuch_config_cache (notmuch_database_t *notmuch, notmuch_config_key_t key, const char *val)
+{
_notmuch_string_map_set (notmuch->config, _notmuch_config_key_to_string (key), val);
}
#define LOG_XAPIAN_EXCEPTION(message, error) _log_xapian_exception (__location__, message, error)
static void
-_log_xapian_exception (const char *where, notmuch_database_t *notmuch, const Xapian::Error error) {
+_log_xapian_exception (const char *where, notmuch_database_t *notmuch, const Xapian::Error error)
+{
_notmuch_database_log (notmuch,
"A Xapian exception occurred at %s: %s\n",
where,
} catch (const Xapian::Error &error) {
status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
if (! notmuch->exception_reported) {
- _notmuch_database_log (notmuch, "Error: A Xapian exception occurred closing database: %s\n",
+ _notmuch_database_log (notmuch,
+ "Error: A Xapian exception occurred closing database: %s\n",
error.get_msg ().c_str ());
}
}
notmuch_database_compact_db (notmuch_database_t *notmuch,
const char *backup_path,
notmuch_compact_status_cb_t status_cb,
- void *closure) {
+ void *closure)
+{
void *local;
char *notmuch_path, *xapian_path, *compact_xapian_path;
- const char* path;
+ const char *path;
notmuch_status_t ret = NOTMUCH_STATUS_SUCCESS;
struct stat statbuf;
bool keep_backup;
try {
NotmuchCompactor compactor (status_cb, closure);
- notmuch->xapian_db->compact (compact_xapian_path, Xapian::DBCOMPACT_NO_RENUMBER, 0, compactor);
+ notmuch->xapian_db->compact (compact_xapian_path, Xapian::DBCOMPACT_NO_RENUMBER, 0,
+ compactor);
} catch (const Xapian::Error &error) {
_notmuch_database_log (notmuch, "Error while compacting: %s\n", error.get_msg ().c_str ());
ret = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
*/
notmuch_status_t
notmuch_database_upgrade (notmuch_database_t *notmuch,
- void (*progress_notify) (void *closure,
- double progress),
+ void (*progress_notify)(void *closure,
+ double progress),
void *closure)
{
void *local = talloc_new (NULL);
if (private_status) {
_notmuch_database_log (notmuch,
"Upgrade failed while creating ghost messages.\n");
- status = COERCE_STATUS (private_status, "Unexpected status from _notmuch_message_initialize_ghost");
+ status = COERCE_STATUS (private_status,
+ "Unexpected status from _notmuch_message_initialize_ghost");
goto DONE;
}
status = NOTMUCH_STATUS_OUT_OF_MEMORY;
}
} 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 ());
notmuch->exception_reported = true;
status = NOTMUCH_STATUS_XAPIAN_EXCEPTION;
#define LOG_XAPIAN_EXCEPTION(directory, error) _log_xapian_exception (__location__, directory, error)
static void
-_log_xapian_exception (const char *where, notmuch_directory_t *dir, const Xapian::Error error) {
+_log_xapian_exception (const char *where, notmuch_directory_t *dir, const Xapian::Error error)
+{
notmuch_database_t *notmuch = dir->notmuch;
+
_notmuch_database_log (notmuch,
"A Xapian exception occurred at %s: %s\n",
where,
*/
_notmuch_features
_notmuch_database_parse_features (const void *ctx, const char *features, unsigned int version,
- char mode, char **incompat_out)
+ char mode, char **incompat_out)
{
_notmuch_features res = static_cast<_notmuch_features>(0);
unsigned int namelen, i;
.value_table = NULL,
};
- type = g_type_register_static (GMIME_TYPE_FILTER, "NotmuchFilterDiscardNonTerm", &info, (GTypeFlags) 0);
+ type = g_type_register_static (GMIME_TYPE_FILTER, "NotmuchFilterDiscardNonTerm", &info,
+ (GTypeFlags) 0);
}
filter = (NotmuchFilterDiscardNonTerm *) g_object_new (type, NULL);
msg_crypto->decryption_status == NOTMUCH_MESSAGE_DECRYPTED_FULL) {
toindex = _notmuch_repair_crypto_payload_skip_legacy_display (child);
if (toindex != child)
- notmuch_message_add_property (message, "index.repaired", "skip-protected-headers-legacy-display");
+ notmuch_message_add_property (message, "index.repaired",
+ "skip-protected-headers-legacy-display");
}
_index_mime_part (message, indexopts, toindex, msg_crypto);
}
mime_message = g_mime_message_part_get_message (GMIME_MESSAGE_PART (part));
- _index_mime_part (message, indexopts, g_mime_message_get_mime_part (mime_message), msg_crypto);
+ _index_mime_part (message, indexopts, g_mime_message_get_mime_part (mime_message),
+ msg_crypto);
goto DONE;
}
bool attempted = false;
GMimeDecryptResult *decrypt_result = NULL;
bool get_sk = (notmuch_indexopts_get_decrypt_policy (indexopts) == NOTMUCH_DECRYPT_TRUE);
+
clear = _notmuch_crypto_decrypt (&attempted, notmuch_indexopts_get_decrypt_policy (indexopts),
message, encrypted_data, get_sk ? &decrypt_result : NULL, &err);
if (! attempted)
notmuch_status_to_string (status));
if (get_sk) {
status = notmuch_message_add_property (message, "session-key",
- g_mime_decrypt_result_get_session_key (decrypt_result));
+ g_mime_decrypt_result_get_session_key (
+ decrypt_result));
if (status)
_notmuch_database_log (notmuch, "failed to add session-key "
"property (%d)\n", status);
g_object_unref (decrypt_result);
}
GMimeObject *toindex = clear;
- if (_notmuch_message_crypto_potential_payload (msg_crypto, clear, encrypted_data, GMIME_MULTIPART_ENCRYPTED_CONTENT) &&
+
+ if (_notmuch_message_crypto_potential_payload (msg_crypto, clear, encrypted_data,
+ GMIME_MULTIPART_ENCRYPTED_CONTENT) &&
msg_crypto->decryption_status == NOTMUCH_MESSAGE_DECRYPTED_FULL) {
toindex = _notmuch_repair_crypto_payload_skip_legacy_display (clear);
if (toindex != clear)
- notmuch_message_add_property (message, "index.repaired", "skip-protected-headers-legacy-display");
+ notmuch_message_add_property (message, "index.repaired",
+ "skip-protected-headers-legacy-display");
}
_index_mime_part (message, indexopts, toindex, msg_crypto);
g_object_unref (clear);
if (p7type == GMIME_SECURE_MIME_TYPE_SIGNED_DATA) {
sigs = g_mime_application_pkcs7_mime_verify (pkcs7, GMIME_VERIFY_NONE, &mimeobj, &err);
if (sigs == NULL) {
- _notmuch_database_log (notmuch, "Failed to verify PKCS#7 SignedData during indexing. (%d:%d) [%s]\n",
+ _notmuch_database_log (notmuch,
+ "Failed to verify PKCS#7 SignedData during indexing. (%d:%d) [%s]\n",
err->domain, err->code, err->message);
g_error_free (err);
goto DONE;
msg_crypto->decryption_status == NOTMUCH_MESSAGE_DECRYPTED_FULL) {
toindex = _notmuch_repair_crypto_payload_skip_legacy_display (mimeobj);
if (toindex != mimeobj)
- notmuch_message_add_property (message, "index.repaired", "skip-protected-headers-legacy-display");
+ notmuch_message_add_property (message, "index.repaired",
+ "skip-protected-headers-legacy-display");
}
_index_mime_part (message, indexopts, toindex, msg_crypto);
} else if (p7type == GMIME_SECURE_MIME_TYPE_ENVELOPED_DATA) {
_notmuch_database_log (notmuch, "Cannot currently handle PKCS#7 smime-type '%s'\n",
g_mime_object_get_content_type_parameter (part, "smime-type"));
}
- DONE:
+ DONE:
if (mimeobj)
g_object_unref (mimeobj);
if (sigs)
char *decrypt_policy;
notmuch_status_t err = notmuch_database_get_config (db, "index.decrypt", &decrypt_policy);
+
if (err)
return NULL;
return NULL;
const char *prefix = notmuch_database_get_path (notmuch);
+
if (prefix == NULL)
goto FAIL;
if (*filename == '/') {
- if (strncmp (filename, prefix, strlen(prefix)) != 0) {
+ if (strncmp (filename, prefix, strlen (prefix)) != 0) {
_notmuch_database_log (notmuch, "Error opening %s: path outside mail root\n",
filename);
errno = 0;
}
message->filename = talloc_strdup (message, filename);
} else {
- message->filename = talloc_asprintf(message, "%s/%s", prefix, filename);
+ message->filename = talloc_asprintf (message, "%s/%s", prefix, filename);
}
if (message->filename == NULL)
return NOTMUCH_STATUS_NULL_POINTER;
notmuch_string_map_t *map;
+
map = _notmuch_message_property_map (message);
if (! map)
return NOTMUCH_STATUS_NULL_POINTER;
notmuch_string_map_iterator_t *matcher = _notmuch_string_map_iterator_create (map, key, true);
+
if (! matcher)
return NOTMUCH_STATUS_OUT_OF_MEMORY;
#define LOG_XAPIAN_EXCEPTION(message, error) _log_xapian_exception (__location__, message, error)
static void
-_log_xapian_exception (const char *where, notmuch_message_t *message, const Xapian::Error error) {
+_log_xapian_exception (const char *where, notmuch_message_t *message, const Xapian::Error error)
+{
notmuch_database_t *notmuch = notmuch_message_get_database (message);
+
_notmuch_database_log (notmuch,
"A Xapian exception occurred at %s: %s\n",
where,
doc_id = _notmuch_database_generate_doc_id (notmuch);
} catch (const Xapian::Error &error) {
- _notmuch_database_log (notmuch_message_get_database (message), "A Xapian exception occurred creating message: %s\n",
+ _notmuch_database_log (notmuch_message_get_database (message),
+ "A Xapian exception occurred creating message: %s\n",
error.get_msg ().c_str ());
notmuch->exception_reported = true;
*status_ret = NOTMUCH_PRIVATE_STATUS_XAPIAN_EXCEPTION;
return NULL;
const std::string &term = *i;
+
if (strncmp (term.c_str (), prefix, prefix_len))
return NULL;
{
notmuch_status_t status;
notmuch_bool_t ret;
+
status = notmuch_message_has_maildir_flag_st (message, flag, &ret);
if (status)
return FALSE;
notmuch_bool_t *is_set)
{
notmuch_status_t status;
-
+
if (! is_set)
return NOTMUCH_STATUS_NULL_POINTER;
status = _ensure_maildir_flags (message, false);
if (status)
return status;
-
+
*is_set = message->maildir_flags && (strchr (message->maildir_flags, flag) != NULL);
return NOTMUCH_STATUS_SUCCESS;
}
private_status = _notmuch_message_remove_term (message, "tag", tag);
if (private_status) {
return COERCE_STATUS (private_status,
- "_notmuch_message_remove_term return unexpected value: %d\n",
- private_status);
+ "_notmuch_message_remove_term return unexpected value: %d\n",
+ private_status);
}
}
orig_thread_id = notmuch_message_get_thread_id (message);
if (! orig_thread_id) {
/* the following is correct as long as there is only one reason
- n_m_get_thread_id returns NULL
- */
+ * n_m_get_thread_id returns NULL
+ */
return NOTMUCH_STATUS_XAPIAN_EXCEPTION;
}
/* config.cc */
notmuch_status_t
-_notmuch_config_load_from_database (notmuch_database_t * db);
+_notmuch_config_load_from_database (notmuch_database_t *db);
notmuch_status_t
-_notmuch_config_load_from_file (notmuch_database_t * db, GKeyFile *file);
+_notmuch_config_load_from_file (notmuch_database_t *db, GKeyFile *file);
notmuch_status_t
-_notmuch_config_load_defaults (notmuch_database_t * db);
+_notmuch_config_load_defaults (notmuch_database_t *db);
void
-_notmuch_config_cache (notmuch_database_t *db, notmuch_config_key_t key, const char* val);
+_notmuch_config_cache (notmuch_database_t *db, notmuch_config_key_t key, const char *val);
NOTMUCH_END_DECLS
* @deprecated Deprecated as of libnotmuch 5.3 (notmuch 0.31). Please
* use notmuch_message_get_flag_st instead.
*/
-NOTMUCH_DEPRECATED(5,3)
+NOTMUCH_DEPRECATED (5, 3)
notmuch_bool_t
notmuch_message_get_flag (notmuch_message_t *message,
notmuch_message_flag_t flag);
* @returns FALSE in case of error
* @deprecated libnotmuch 5.3 (notmuch 0.31)
*/
-NOTMUCH_DEPRECATED(5, 3)
+NOTMUCH_DEPRECATED (5, 3)
notmuch_bool_t
notmuch_message_has_maildir_flag (notmuch_message_t *message, char flag);
* @since libnotmuch 4.4 (notmuch 0.23)
*/
notmuch_status_t
-notmuch_database_get_config_list (notmuch_database_t *db, const char *prefix, notmuch_config_list_t **out);
+notmuch_database_get_config_list (notmuch_database_t *db, const char *prefix,
+ notmuch_config_list_t **out);
/**
* Is 'config_list' iterator valid (i.e. _key, _value, _move_to_next can be called).
config = _xdg_dir (notmuch, "XDG_CONFIG_HOME", ".config", profile);
if (! config)
- return NOTMUCH_STATUS_PATH_ERROR;
+ return NOTMUCH_STATUS_PATH_ERROR;
hook_dir = talloc_asprintf (notmuch, "%s/hooks", config);
if (dir) {
path = talloc_asprintf (local, "%s/config", dir);
- if (access (path, R_OK) !=0)
+ if (access (path, R_OK) != 0)
path = NULL;
}
}
status = NOTMUCH_STATUS_NO_CONFIG;
}
-DONE:
+ DONE:
talloc_free (local);
return status;
}
{
notmuch_status_t status;
- status =_load_key_file (config_path, profile, key_file);
+ status = _load_key_file (config_path, profile, key_file);
if (status) {
*message = strdup ("Error: cannot load config file.\n");
return status;
notmuch->term_gen = new Xapian::TermGenerator;
notmuch->term_gen->set_stemmer (Xapian::Stem ("english"));
notmuch->value_range_processor = new Xapian::NumberRangeProcessor (NOTMUCH_VALUE_TIMESTAMP);
- notmuch->date_range_processor = new ParseTimeRangeProcessor (NOTMUCH_VALUE_TIMESTAMP, "date:");
- notmuch->last_mod_range_processor = new Xapian::NumberRangeProcessor (NOTMUCH_VALUE_LAST_MOD, "lastmod:");
+ notmuch->date_range_processor = new ParseTimeRangeProcessor (NOTMUCH_VALUE_TIMESTAMP,
+ "date:");
+ notmuch->last_mod_range_processor = new Xapian::NumberRangeProcessor (NOTMUCH_VALUE_LAST_MOD,
+ "lastmod:");
notmuch->query_parser->set_default_op (Xapian::Query::OP_AND);
notmuch->query_parser->set_database (*notmuch->xapian_db);
notmuch->query_parser->set_stemmer (Xapian::Stem ("english"));
if (time (&now) == (time_t) -1)
throw Xapian::QueryParserError ("unable to get current time");
- if (!begin.empty ()) {
+ if (! begin.empty ()) {
if (parse_time_string (begin.c_str (), &parsed_time, &now, PARSE_TIME_ROUND_DOWN))
throw Xapian::QueryParserError ("Didn't understand date specification '" + begin + "'");
else
from = (double) parsed_time;
}
- if (!end.empty ()) {
+ if (! end.empty ()) {
if (end == "!" && ! begin.empty ())
str = begin;
else
Xapian::FieldProcessor *fp;
if (STRNCMP_LITERAL (prefix->name, "date") == 0)
- fp = (new DateFieldProcessor(NOTMUCH_VALUE_TIMESTAMP))->release ();
- else if (STRNCMP_LITERAL(prefix->name, "query") == 0)
+ fp = (new DateFieldProcessor (NOTMUCH_VALUE_TIMESTAMP))->release ();
+ else if (STRNCMP_LITERAL (prefix->name, "query") == 0)
fp = (new QueryFieldProcessor (*notmuch->query_parser, notmuch))->release ();
else if (STRNCMP_LITERAL (prefix->name, "thread") == 0)
fp = (new ThreadFieldProcessor (*notmuch->query_parser, notmuch))->release ();
_notmuch_string_map_sort (map);
pair = bsearch_first (map->pairs, map->length, key, true);
if (! pair)
- _notmuch_string_map_append (map, key, val);
+ _notmuch_string_map_append (map, key, val);
else {
- talloc_free (pair->value);
- pair->value = talloc_strdup (map->pairs, val);
+ talloc_free (pair->value);
+ pair->value = talloc_strdup (map->pairs, val);
}
}
std::set<std::string> terms;
if (! subquery)
- throw Xapian::QueryParserError ("failed to create subquery for '" + subquery_str + "'");
+ throw Xapian::QueryParserError ("failed to create subquery for '" + subquery_str +
+ "'");
status = notmuch_query_search_messages (subquery, &messages);
if (status)
- throw Xapian::QueryParserError ("failed to search messages for '" + subquery_str + "'");
+ throw Xapian::QueryParserError ("failed to search messages for '" + subquery_str +
+ "'");
for (; notmuch_messages_valid (messages); notmuch_messages_move_to_next (messages)) {
std::string term = thread_prefix;
notmuch_messages_valid (roots);
notmuch_messages_move_to_next (roots)) {
notmuch_message_t *message = notmuch_messages_get (roots);
- if (_notmuch_messages_has_next (roots) || ! _notmuch_message_list_empty (thread->toplevel_list))
+ if (_notmuch_messages_has_next (roots) || ! _notmuch_message_list_empty (
+ thread->toplevel_list))
_parent_or_toplevel (thread, message);
else
_notmuch_message_list_add_message (thread->toplevel_list, message);