X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=notmuch-show.c;h=9f81ae161f1fa4975df8cf721630fbab818539c9;hp=b5db3df95aa2652be9e1f5ffa0f0d7f241894696;hb=d3349358c6a5048559bd2a4faebe476ebd222170;hpb=357aba3ec8177c11a7ce22cbe26d92482f6a5e53;ds=sidebyside diff --git a/notmuch-show.c b/notmuch-show.c index b5db3df9..9f81ae16 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -120,41 +120,40 @@ show_part(GMimeObject *part, int *part_count) int notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) { - void *local = talloc_new (ctx); - char *query_string; - notmuch_database_t *notmuch = NULL; - notmuch_query_t *query = NULL; + notmuch_config_t *config; + notmuch_database_t *notmuch; + notmuch_query_t *query; notmuch_messages_t *messages; notmuch_message_t *message; - int ret = 0; + char *query_string; const char *headers[] = { - "From", "To", "Cc", "Bcc", "Date" + "Subject", "From", "To", "Cc", "Bcc", "Date" }; const char *name, *value; unsigned int i; - notmuch = notmuch_database_open (NULL); - if (notmuch == NULL) { - ret = 1; - goto DONE; - } + config = notmuch_config_open (ctx, NULL, NULL); + if (config == NULL) + return 1; + + notmuch = notmuch_database_open (notmuch_config_get_database_path (config)); + if (notmuch == NULL) + return 1; - query_string = query_string_from_args (local, argc, argv); + query_string = query_string_from_args (ctx, argc, argv); if (query_string == NULL) { fprintf (stderr, "Out of memory\n"); - ret = 1; - goto DONE; + return 1; } query = notmuch_query_create (notmuch, query_string); if (query == NULL) { fprintf (stderr, "Out of memory\n"); - ret = 1; - goto DONE; + return 1; } - for (messages = notmuch_query_search_messages (query); + for (messages = notmuch_query_search_messages (query, 0, -1); notmuch_messages_has_more (messages); notmuch_messages_advance (messages)) { @@ -166,9 +165,7 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) printf ("\fheader{\n"); - printf ("%s\n", _get_one_line_summary (local, message)); - - printf ("%s\n", notmuch_message_get_header (message, "subject")); + printf ("%s\n", _get_one_line_summary (ctx, message)); for (i = 0; i < ARRAY_SIZE (headers); i++) { name = headers[i]; @@ -189,15 +186,8 @@ notmuch_show_command (void *ctx, unused (int argc), unused (char *argv[])) notmuch_message_destroy (message); } - DONE: - if (local) - talloc_free (local); - - if (query) - notmuch_query_destroy (query); - - if (notmuch) - notmuch_database_close (notmuch); + notmuch_query_destroy (query); + notmuch_database_close (notmuch); - return ret; + return 0; }