summaryrefslogtreecommitdiffstats
path: root/status.c
diff options
context:
space:
mode:
authorDavid Bremner <david@tethera.net>2015-09-06 10:15:45 -0300
committerDavid Bremner <david@tethera.net>2015-09-20 08:04:31 -0300
commit39c54df26dad01e3ec294f7c4a613d9ee71faf3e (patch)
treeff665f59381f72704a7bbee72054269c29b3a596 /status.c
parentd4321162ae1bd5cbbf620a8bc26cec5430acf90b (diff)
cli: add utility routine to print error status.
No attention to formatting here, initially just focus on getting the relevant strings out of the library.
Diffstat (limited to 'status.c')
-rw-r--r--status.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/status.c b/status.c
new file mode 100644
index 00000000..8fa81cbf
--- /dev/null
+++ b/status.c
@@ -0,0 +1,21 @@
+#include "notmuch-client.h"
+
+notmuch_status_t
+print_status_query (const char *loc,
+ const notmuch_query_t *query,
+ notmuch_status_t status)
+{
+ if (status) {
+ const char *msg;
+ notmuch_database_t *notmuch;
+
+ fprintf (stderr, "%s: %s\n", loc,
+ notmuch_status_to_string (status));
+
+ notmuch = notmuch_query_get_database (query);
+ msg = notmuch_database_status_string (notmuch);
+ if (msg)
+ fputs (msg, stderr);
+ }
+ return status;
+}