]> git.notmuchmail.org Git - notmuch/blob - status.c
test: remove unused filter functions
[notmuch] / status.c
1 #include "notmuch-client.h"
2
3 notmuch_status_t
4 print_status_query (const char *loc,
5                     const notmuch_query_t *query,
6                     notmuch_status_t status)
7 {
8     if (status) {
9         const char *msg;
10         notmuch_database_t *notmuch;
11
12         fprintf (stderr, "%s: %s\n", loc,
13                  notmuch_status_to_string (status));
14
15         notmuch = notmuch_query_get_database (query);
16         msg = notmuch_database_status_string (notmuch);
17         if (msg)
18             fputs (msg, stderr);
19     }
20     return status;
21 }
22
23 notmuch_status_t
24 print_status_database (const char *loc,
25                     const notmuch_database_t *notmuch,
26                     notmuch_status_t status)
27 {
28     if (status) {
29         const char *msg;
30
31         fprintf (stderr, "%s: %s\n", loc,
32                  notmuch_status_to_string (status));
33         msg = notmuch_database_status_string (notmuch);
34         if (msg)
35             fputs (msg, stderr);
36     }
37     return status;
38 }
39
40 int
41 status_to_exit (notmuch_status_t status)
42 {
43     switch (status) {
44     case NOTMUCH_STATUS_SUCCESS:
45         return EXIT_SUCCESS;
46     case NOTMUCH_STATUS_OUT_OF_MEMORY:
47     case NOTMUCH_STATUS_XAPIAN_EXCEPTION:
48     case NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID:
49     case NOTMUCH_STATUS_FILE_ERROR:
50         return EX_TEMPFAIL;
51     default:
52         return EXIT_FAILURE;
53     }
54 }