[PATCH] configure: add --without-api-docs option
[notmuch-archives.git] / d4 / 5d13b5dabd92a4cb3af3b838014ccfe83461b3
1 Return-Path: <jani@nikula.org>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 68721429E38\r
6         for <notmuch@notmuchmail.org>; Fri,  2 Dec 2011 13:00:19 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.7\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
12         tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id 9ENq-8aRYdgR for <notmuch@notmuchmail.org>;\r
16         Fri,  2 Dec 2011 13:00:18 -0800 (PST)\r
17 Received: from mail-ww0-f45.google.com (mail-ww0-f45.google.com\r
18  [74.125.82.45])        (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
19  certificate requested) by olra.theworths.org (Postfix) with ESMTPS id\r
20  33515429E21    for <notmuch@notmuchmail.org>; Fri,  2 Dec 2011 13:00:18 -0800\r
21  (PST)\r
22 Received: by wgbds13 with SMTP id ds13so1494749wgb.2\r
23         for <notmuch@notmuchmail.org>; Fri, 02 Dec 2011 13:00:15 -0800 (PST)\r
24 Received: by 10.227.204.197 with SMTP id fn5mr7330144wbb.15.1322859612529;\r
25         Fri, 02 Dec 2011 13:00:12 -0800 (PST)\r
26 Received: from localhost (dsl-hkibrasgw4-fe5cdc00-23.dhcp.inet.fi.\r
27         [80.220.92.23])\r
28         by mx.google.com with ESMTPS id 28sm9183237wby.3.2011.12.02.13.00.07\r
29         (version=SSLv3 cipher=OTHER); Fri, 02 Dec 2011 13:00:08 -0800 (PST)\r
30 From: Jani Nikula <jani@nikula.org>\r
31 To: notmuch@notmuchmail.org\r
32 Subject: [PATCH 1/2] cli: add mechanism for running user configurable hooks\r
33 Date: Fri,  2 Dec 2011 23:00:05 +0200\r
34 Message-Id:\r
35  <7fbe6befcf31881a9bca672f55b93501249a220c.1322859389.git.jani@nikula.org>\r
36 X-Mailer: git-send-email 1.7.5.4\r
37 X-BeenThere: notmuch@notmuchmail.org\r
38 X-Mailman-Version: 2.1.13\r
39 Precedence: list\r
40 List-Id: "Use and development of the notmuch mail system."\r
41         <notmuch.notmuchmail.org>\r
42 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
43         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
44 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
45 List-Post: <mailto:notmuch@notmuchmail.org>\r
46 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
47 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
48         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
49 X-List-Received-Date: Fri, 02 Dec 2011 21:00:19 -0000\r
50 \r
51 Add support functions for running hooks configurable in the notmuch config\r
52 file. The hooks will be run using system(1).\r
53 \r
54 TODO:\r
55 \r
56 * Move notmuch_run_hook() out of notmuch-new.c. It's there and static only\r
57   because the first user will be there.\r
58 \r
59 * Consider merging this with the following patch, as this is slightly\r
60   artificial as it is.\r
61 \r
62 Signed-off-by: Jani Nikula <jani@nikula.org>\r
63 ---\r
64  notmuch-client.h |    7 +++++++\r
65  notmuch-config.c |   21 +++++++++++++++++++++\r
66  notmuch-new.c    |   25 +++++++++++++++++++++++++\r
67  3 files changed, 53 insertions(+), 0 deletions(-)\r
68 \r
69 diff --git a/notmuch-client.h b/notmuch-client.h\r
70 index b50cb38..5e2fed2 100644\r
71 --- a/notmuch-client.h\r
72 +++ b/notmuch-client.h\r
73 @@ -87,6 +87,10 @@ typedef struct notmuch_show_params {\r
74      int decrypt;\r
75  } notmuch_show_params_t;\r
76  \r
77 +typedef enum {\r
78 +    NOTMUCH_HOOK_PLACEHOLDER,\r
79 +} notmuch_hook_t;\r
80 +\r
81  /* There's no point in continuing when we've detected that we've done\r
82   * something wrong internally (as opposed to the user passing in a\r
83   * bogus value).\r
84 @@ -235,6 +239,9 @@ void\r
85  notmuch_config_set_maildir_synchronize_flags (notmuch_config_t *config,\r
86                                               notmuch_bool_t synchronize_flags);\r
87  \r
88 +const char *\r
89 +notmuch_config_get_hook (notmuch_config_t *config, notmuch_hook_t hook);\r
90 +\r
91  notmuch_bool_t\r
92  debugger_is_active (void);\r
93  \r
94 diff --git a/notmuch-config.c b/notmuch-config.c\r
95 index 1a7ed58..8f1a038 100644\r
96 --- a/notmuch-config.c\r
97 +++ b/notmuch-config.c\r
98 @@ -608,6 +608,27 @@ notmuch_config_set_new_tags (notmuch_config_t *config,\r
99      config->new_tags = NULL;\r
100  }\r
101  \r
102 +const char *\r
103 +notmuch_config_get_hook (notmuch_config_t *config, notmuch_hook_t hook)\r
104 +{\r
105 +    char *command;\r
106 +    const char *group, *key;\r
107 +\r
108 +    switch (hook) {\r
109 +    default:\r
110 +       INTERNAL_ERROR ("Unknown hook %d\n.", hook);\r
111 +    }\r
112 +\r
113 +    command = g_key_file_get_string (config->key_file, group, key, NULL);\r
114 +    if (command) {\r
115 +       char *p = command;\r
116 +       command = talloc_strdup (config, command);\r
117 +       free (p);\r
118 +    }\r
119 +\r
120 +    return command;\r
121 +}\r
122 +\r
123  /* Given a configuration item of the form <group>.<key> return the\r
124   * component group and key. If any error occurs, print a message on\r
125   * stderr and return 1. Otherwise, return 0.\r
126 diff --git a/notmuch-new.c b/notmuch-new.c\r
127 index 81a9350..0c70e64 100644\r
128 --- a/notmuch-new.c\r
129 +++ b/notmuch-new.c\r
130 @@ -795,6 +795,31 @@ _remove_directory (void *ctx,\r
131      notmuch_directory_destroy (directory);\r
132  }\r
133  \r
134 +static int\r
135 +notmuch_run_hook (notmuch_config_t *config, notmuch_hook_t hook)\r
136 +{\r
137 +    const char *command;\r
138 +    int r;\r
139 +\r
140 +    command = notmuch_config_get_hook (config, hook);\r
141 +    if (!command)\r
142 +       return NOTMUCH_STATUS_SUCCESS; /* It's okay not to have a hook */\r
143 +\r
144 +    r = system(command);\r
145 +    if (r) {\r
146 +       if (WIFSIGNALED(r))\r
147 +           fprintf(stderr, "hook '%s' terminated with signal %d\n",\r
148 +                   command, WTERMSIG(r));\r
149 +       else\r
150 +           fprintf(stderr, "hook '%s' failed with status %d\n",\r
151 +                   command, WEXITSTATUS(r));\r
152 +\r
153 +       r = NOTMUCH_STATUS_FILE_ERROR; /* FIXME */\r
154 +    }\r
155 +\r
156 +    return r;\r
157 +}\r
158 +\r
159  int\r
160  notmuch_new_command (void *ctx, int argc, char *argv[])\r
161  {\r
162 -- \r
163 1.7.5.4\r
164 \r