X-Git-Url: https://git.cworth.org/git?p=notmuch;a=blobdiff_plain;f=hooks.c;h=ec89b22ec75497ee69a5d9cce888c6c2a1a95c81;hp=59c5807065fc4ee58974a7eec196c7335bcbb8e3;hb=HEAD;hpb=b23902a61158ecdbca2d9d96c6eaf509d6e3d205 diff --git a/hooks.c b/hooks.c index 59c58070..0cf72e74 100644 --- a/hooks.c +++ b/hooks.c @@ -24,19 +24,27 @@ #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; + const char *config_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; } + config_path = notmuch_config_path (notmuch); + if (setenv ("NOTMUCH_CONFIG", config_path, 1)) { + perror ("setenv"); + return 1; + } + /* Check access before fork() for speed and simplicity of error handling. */ if (access (hook_path, X_OK) == -1) { /* Ignore ENOENT. It's okay not to have a hook, hook dir, or even