61 const char *suffix,
char *result,
85 if (!access(filename, F_OK))
return realpath(filename, executable_name);
89 const char *path_prefix;
93 if (*filename ==
'/')
return NULL;
96 path_prefix = path_list;
99 colon = strchr(path_prefix,
':');
108 path, &path[PATH_MAX - 1]);
109 if (failure)
return NULL;
114 if (!access(path, X_OK))
return realpath(path, executable_name);
117 path_prefix = (colon ? colon + 1 :
NULL);
142 strtcpy(
char *dest,
const char *src,
const int t,
char *dest_end)
147 if (dest > dest_end)
return 0;
156 const char *suffix,
char *result,
char *result_end)
161 end =
strtcpy(result, prefix, terminator, result_end);
165 if (*(end - 1) !=
'/') {
166 if (end > result_end)
return -1;
171 end =
strtcpy(end, suffix, 0, result_end);
175 if (end > result_end)
return -1;
static int assemble_fullpath(const char *prefix, const int terminator, const char *suffix, char *result, char *result_end)
static char * strtcpy(char *dest, const char *src, const int t, char *dest_end)
char * executable_path(const char *filename, const char *path_list, char *executable_name)