[PATCH] configure: add --without-api-docs option
[notmuch-archives.git] / f4 / 5f5cf1f29e1a532667dda4a452bcb074d0c2ba
1 Return-Path: <dkg@fifthhorseman.net>\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 arlo.cworth.org (Postfix) with ESMTP id CBB816DE1AE0\r
6  for <notmuch@notmuchmail.org>; Sun, 31 Jan 2016 12:40:10 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12  autolearn=disabled\r
13 Received: from arlo.cworth.org ([127.0.0.1])\r
14  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
15  with ESMTP id m5-TOeknAz40 for <notmuch@notmuchmail.org>;\r
16  Sun, 31 Jan 2016 12:40:09 -0800 (PST)\r
17 Received: from che.mayfirst.org (che.mayfirst.org [209.234.253.108])\r
18  by arlo.cworth.org (Postfix) with ESMTP id E597D6DE0FB1\r
19  for <notmuch@notmuchmail.org>; Sun, 31 Jan 2016 12:40:08 -0800 (PST)\r
20 Received: from fifthhorseman.net (ip-64-134-185-108.public.wayport.net\r
21  [64.134.185.108])\r
22  by che.mayfirst.org (Postfix) with ESMTPSA id B0C9CF997\r
23  for <notmuch@notmuchmail.org>; Sun, 31 Jan 2016 15:40:05 -0500 (EST)\r
24 Received: by fifthhorseman.net (Postfix, from userid 1000)\r
25  id 2B15B1FE52; Sun, 31 Jan 2016 15:40:06 -0500 (EST)\r
26 From: Daniel Kahn Gillmor <dkg@fifthhorseman.net>\r
27 To: Notmuch Mail <notmuch@notmuchmail.org>\r
28 Subject: [PATCH v3 01/16] add util/search-path.{c,\r
29  h} to test for executables in $PATH\r
30 Date: Sun, 31 Jan 2016 15:39:46 -0500\r
31 Message-Id: <1454272801-23623-2-git-send-email-dkg@fifthhorseman.net>\r
32 X-Mailer: git-send-email 2.7.0.rc3\r
33 In-Reply-To: <1454272801-23623-1-git-send-email-dkg@fifthhorseman.net>\r
34 References: <1454272801-23623-1-git-send-email-dkg@fifthhorseman.net>\r
35 X-BeenThere: notmuch@notmuchmail.org\r
36 X-Mailman-Version: 2.1.20\r
37 Precedence: list\r
38 List-Id: "Use and development of the notmuch mail system."\r
39  <notmuch.notmuchmail.org>\r
40 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
41  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
42 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
43 List-Post: <mailto:notmuch@notmuchmail.org>\r
44 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
45 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
46  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
47 X-List-Received-Date: Sun, 31 Jan 2016 20:40:10 -0000\r
48 \r
49 This is a utility function we can use to see whether an executable is\r
50 available.\r
51 ---\r
52  util/Makefile.local |  2 +-\r
53  util/search-path.c  | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++\r
54  util/search-path.h  | 24 +++++++++++++++++++++++\r
55  3 files changed, 80 insertions(+), 1 deletion(-)\r
56  create mode 100644 util/search-path.c\r
57  create mode 100644 util/search-path.h\r
58 \r
59 diff --git a/util/Makefile.local b/util/Makefile.local\r
60 index 905f237..8b2b91b 100644\r
61 --- a/util/Makefile.local\r
62 +++ b/util/Makefile.local\r
63 @@ -5,7 +5,7 @@ extra_cflags += -I$(srcdir)/$(dir)\r
64  \r
65  libutil_c_srcs := $(dir)/xutil.c $(dir)/error_util.c $(dir)/hex-escape.c \\r
66                   $(dir)/string-util.c $(dir)/talloc-extra.c $(dir)/zlib-extra.c \\r
67 -               $(dir)/util.c\r
68 +               $(dir)/util.c $(dir)/search-path.c\r
69  \r
70  libutil_modules := $(libutil_c_srcs:.c=.o)\r
71  \r
72 diff --git a/util/search-path.c b/util/search-path.c\r
73 new file mode 100644\r
74 index 0000000..5eac367\r
75 --- /dev/null\r
76 +++ b/util/search-path.c\r
77 @@ -0,0 +1,55 @@\r
78 +#include "search-path.h"\r
79 +#include <stdlib.h>\r
80 +#include <talloc.h>\r
81 +#include <unistd.h>\r
82 +#include <string.h>\r
83 +#include <sys/types.h>\r
84 +#include <sys/stat.h>\r
85 +#include <fcntl.h>\r
86 +\r
87 +\r
88 +notmuch_bool_t\r
89 +test_for_executable(const char* exename)\r
90 +{\r
91 +    char *c = NULL, *save = NULL, *tok;\r
92 +    size_t n;\r
93 +    int dfd = -1;\r
94 +    notmuch_bool_t ret = FALSE;\r
95 +\r
96 +    if (strchr(exename, '/')) {\r
97 +       if (0 == access(exename, X_OK))\r
98 +           return TRUE;\r
99 +       else\r
100 +           return FALSE;\r
101 +    }\r
102 +    \r
103 +    c = getenv("PATH");\r
104 +    if (c)\r
105 +       c = talloc_strdup(NULL, c);\r
106 +    else {\r
107 +       n = confstr(_CS_PATH, NULL, 0);\r
108 +       c = (char*)talloc_size(NULL, n);\r
109 +       if (!c)\r
110 +           return FALSE;\r
111 +       confstr(_CS_PATH, c, n);\r
112 +    }\r
113 +\r
114 +    tok = strtok_r(c, ":", &save);\r
115 +    while (tok) {\r
116 +       dfd = open(tok, O_DIRECTORY | O_RDONLY);\r
117 +       if (dfd != -1) {\r
118 +           if (!faccessat(dfd, exename, X_OK, 0)) {\r
119 +               ret = TRUE;\r
120 +               goto done;\r
121 +           }\r
122 +           close(dfd);\r
123 +       }\r
124 +       tok = strtok_r(NULL, ":", &save);\r
125 +    }\r
126 +done:\r
127 +    if (dfd != -1)\r
128 +       close(dfd);\r
129 +    if (c)\r
130 +       talloc_free(c);\r
131 +    return ret;\r
132 +}\r
133 diff --git a/util/search-path.h b/util/search-path.h\r
134 new file mode 100644\r
135 index 0000000..727d0b3\r
136 --- /dev/null\r
137 +++ b/util/search-path.h\r
138 @@ -0,0 +1,24 @@\r
139 +#ifndef _SEARCH_PATH_H\r
140 +#define _SEARCH_PATH_H\r
141 +\r
142 +#include "notmuch.h"\r
143 +\r
144 +/* can an executable be found with the given name?\r
145 + * \r
146 + * Return TRUE only if we can find something to execute with the\r
147 + * associated name.\r
148 + *\r
149 + * if the name has a '/' in it, we look for it directly with\r
150 + * access(exename, X_OK).\r
151 + * \r
152 + * otherwise, we look for it in $PATH (or in confstr(_CS_PATH), if\r
153 + * $PATH is unset).\r
154 + *\r
155 + * This should match the logic for execvp (as well as matching user\r
156 + * expectations, hopefully).\r
157 + */\r
158 +\r
159 +notmuch_bool_t\r
160 +test_for_executable(const char *exename);\r
161 +\r
162 +#endif\r
163 -- \r
164 2.7.0.rc3\r
165 \r