unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
blob 9da21cb6190212c7d35746f6b88999d7cfae09fc 968 bytes (raw)
name: util/search-path.c 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
 
#include "search-path.h"
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>


notmuch_bool_t
test_for_executable (const char *exename)
{
    char *path = NULL, *save = NULL, *tok;
    notmuch_bool_t ret = FALSE;

    if (strchr (exename, '/')) {
	if (0 == access (exename, X_OK))
	    return TRUE;
	else
	    return FALSE;
    }

    path = getenv ("PATH");
    if (path)
	path = strdup (path);
    else {
	size_t n = confstr (_CS_PATH, NULL, 0);
	path = (char *) malloc (n);
	if (! path)
	    return FALSE;
	confstr (_CS_PATH, path, n);
    }

    tok = strtok_r (path, ":", &save);
    while (tok) {
	int dir_fd = open (tok, O_DIRECTORY | O_RDONLY);
	if (dir_fd != -1) {
	    int access = faccessat (dir_fd, exename, X_OK, 0);
	    close (dir_fd);
	    if (access == 0) {
		ret = TRUE;
		break;
	    }
	}
	tok = strtok_r (NULL, ":", &save);
    }
    if (path)
	free (path);
    return ret;
}

debug log:

solving 9da21cb ...
found 9da21cb in https://yhetil.org/notmuch/1455054725-952-1-git-send-email-dkg@fifthhorseman.net/ ||
	https://yhetil.org/notmuch/1467970047-8013-2-git-send-email-dkg@fifthhorseman.net/

applying [1/1] https://yhetil.org/notmuch/1455054725-952-1-git-send-email-dkg@fifthhorseman.net/
diff --git a/util/search-path.c b/util/search-path.c
new file mode 100644
index 0000000..9da21cb

Checking patch util/search-path.c...
Applied patch util/search-path.c cleanly.

skipping https://yhetil.org/notmuch/1467970047-8013-2-git-send-email-dkg@fifthhorseman.net/ for 9da21cb
index at:
100644 9da21cb6190212c7d35746f6b88999d7cfae09fc	util/search-path.c

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).