X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=hooks.c;h=ec89b22ec75497ee69a5d9cce888c6c2a1a95c81;hp=662629a951b309021cb86eebfbb0d0cca345e8d0;hb=2786aa4d548d28579c761e9358d44c84dfb29068;hpb=03680d10066f85887c1198925a7b297b27435919 diff --git a/hooks.c b/hooks.c index 662629a9..ec89b22e 100644 --- a/hooks.c +++ b/hooks.c @@ -15,7 +15,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Jani Nikula */ @@ -24,14 +24,15 @@ #include int -notmuch_run_hook (const char *db_path, const char *hook) +notmuch_run_hook (notmuch_database_t *notmuch, const char *hook) { char *hook_path; int status = 0; pid_t pid; - hook_path = talloc_asprintf (NULL, "%s/%s/%s/%s", db_path, ".notmuch", - "hooks", hook); + hook_path = talloc_asprintf (notmuch, "%s/%s", + notmuch_config_get (notmuch, NOTMUCH_CONFIG_HOOK_DIR), + hook); if (hook_path == NULL) { fprintf (stderr, "Out of memory\n"); return 1; @@ -53,7 +54,7 @@ notmuch_run_hook (const char *db_path, const char *hook) /* Flush any buffered output before forking. */ fflush (stdout); - pid = fork(); + pid = fork (); if (pid == -1) { fprintf (stderr, "Error: %s hook fork failed: %s\n", hook, strerror (errno)); @@ -78,7 +79,7 @@ notmuch_run_hook (const char *db_path, const char *hook) goto DONE; } - if (!WIFEXITED (status) || WEXITSTATUS (status)) { + if (! WIFEXITED (status) || WEXITSTATUS (status)) { if (WIFEXITED (status)) { fprintf (stderr, "Error: %s hook failed with status %d\n", hook, WEXITSTATUS (status));