1 /* notmuch - Not much of an email program, (just index and search)
3 * Copyright © 2009 Carl Worth
4 * Copyright © 2009 Jan Janak
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see http://www.gnu.org/licenses/ .
19 * Author: Jan Janak <jan@ryngle.com>
22 #include "notmuch-client.h"
25 list_all_tags (notmuch_database_t* db)
30 if ((tags = notmuch_database_get_all_tags (db)) == NULL) {
31 fprintf (stderr, "Error while obtaining tags from the database.\n");
35 while((t = notmuch_tags_get (tags))) {
37 notmuch_tags_advance (tags);
40 notmuch_tags_destroy (tags);
45 notmuch_search_tags_command (void *ctx, int argc, char *argv[])
47 notmuch_config_t *config;
48 notmuch_database_t *db;
53 if ((config = notmuch_config_open (ctx, NULL, NULL)) == NULL) {
57 db = notmuch_database_open (notmuch_config_get_database_path (config),
58 NOTMUCH_DATABASE_MODE_READ_ONLY);
63 if (list_all_tags (db) != 0) goto error;
65 notmuch_database_close (db);
69 if (db) notmuch_database_close (db);