* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
count_files (notmuch_query_t *query)
{
notmuch_messages_t *messages;
notmuch_message_t *message;
notmuch_filenames_t *filenames;
count_files (notmuch_query_t *query)
{
notmuch_messages_t *messages;
notmuch_message_t *message;
notmuch_filenames_t *filenames;
- messages = notmuch_query_search_messages (query);
- if (messages == NULL)
- return 0;
+ status = notmuch_query_search_messages (query, &messages);
+ if (print_status_query ("notmuch count", query, status))
+ return -1;
- const char **exclude_tags, size_t exclude_tags_length, int output)
+ const char **exclude_tags, size_t exclude_tags_length, int output, int print_lastmod)
query = notmuch_query_create (notmuch, query_str);
if (query == NULL) {
fprintf (stderr, "Out of memory\n");
query = notmuch_query_create (notmuch, query_str);
if (query == NULL) {
fprintf (stderr, "Out of memory\n");
- for (i = 0; i < exclude_tags_length; i++)
- notmuch_query_add_tag_exclude (query, exclude_tags[i]);
+ for (i = 0; i < exclude_tags_length; i++) {
+ status = notmuch_query_add_tag_exclude (query, exclude_tags[i]);
+ if (status && status != NOTMUCH_STATUS_IGNORED) {
+ print_status_query ("notmuch count", query, status);
+ return -1;
+ }
+ }
- printf ("%u\n", notmuch_query_count_messages (query));
+ status = notmuch_query_count_messages (query, &ucount);
+ if (print_status_query ("notmuch count", query, status))
+ return -1;
+ printf ("%u", ucount);
- printf ("%u\n", notmuch_query_count_threads (query));
+ status = notmuch_query_count_threads (query, &ucount);
+ if (print_status_query ("notmuch count", query, status))
+ return -1;
+ printf ("%u", ucount);
}
static int
count_file (notmuch_database_t *notmuch, FILE *input, const char **exclude_tags,
}
static int
count_file (notmuch_database_t *notmuch, FILE *input, const char **exclude_tags,
chomp_newline (line);
ret = print_count (notmuch, line, exclude_tags, exclude_tags_length,
chomp_newline (line);
ret = print_count (notmuch, line, exclude_tags, exclude_tags_length,
const char **search_exclude_tags = NULL;
size_t search_exclude_tags_length = 0;
notmuch_bool_t batch = FALSE;
const char **search_exclude_tags = NULL;
size_t search_exclude_tags_length = 0;
notmuch_bool_t batch = FALSE;
(notmuch_keyword_t []){ { "true", EXCLUDE_TRUE },
{ "false", EXCLUDE_FALSE },
{ 0, 0 } } },
(notmuch_keyword_t []){ { "true", EXCLUDE_TRUE },
{ "false", EXCLUDE_FALSE },
{ 0, 0 } } },
{ NOTMUCH_OPT_BOOLEAN, &batch, "batch", 0, 0 },
{ NOTMUCH_OPT_STRING, &input_file_name, "input", 'i', 0 },
{ NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 },
{ NOTMUCH_OPT_BOOLEAN, &batch, "batch", 0, 0 },
{ NOTMUCH_OPT_STRING, &input_file_name, "input", 'i', 0 },
{ NOTMUCH_OPT_INHERIT, (void *) ¬much_shared_options, NULL, 0, 0 },
if (batch && opt_index != argc) {
fprintf (stderr, "--batch and query string are not compatible\n");
if (batch && opt_index != argc) {
fprintf (stderr, "--batch and query string are not compatible\n");
- query_str = query_string_from_args (config, argc-opt_index, argv+opt_index);
+ notmuch_exit_if_unmatched_db_uuid (notmuch);
+
+ query_str = query_string_from_args (config, argc - opt_index, argv + opt_index);
if (batch)
ret = count_file (notmuch, input, search_exclude_tags,
if (batch)
ret = count_file (notmuch, input, search_exclude_tags,
else
ret = print_count (notmuch, query_str, search_exclude_tags,
else
ret = print_count (notmuch, query_str, search_exclude_tags,