14 #define dln_notimplement rb_notimplement
15 #define dln_memerror rb_memerror
16 #define dln_exit rb_exit
17 #define dln_loaderror rb_loaderror
18 #define dln_warning rb_warning
19 #define dln_warning_arg
21 #define dln_notimplement --->>> dln not implemented <<<---
22 #define dln_memerror abort
24 #define dln_warning fprintf
25 #define dln_warning_arg stderr,
38 #if defined(HAVE_ALLOCA_H)
52 #include <sys/types.h>
56 # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
59 #ifdef HAVE_SYS_PARAM_H
60 # include <sys/param.h>
63 # define MAXPATHLEN 1024
74 static char *
dln_find_1(
const char *fname,
const char *path,
char *
buf,
size_t size,
int exe_flag);
83 if (path) path = envpath =
strdup(path);
88 path =
"/usr/local/bin;/usr/ucb;/usr/bin;/bin;.";
90 path =
"/usr/local/bin:/usr/ucb:/usr/bin:/bin:.";
94 if (envpath)
free(envpath);
101 if (!path) path =
".";
123 register const char *
dp;
124 register const char *ep;
127 size_t i, fnlen, fspace;
129 static const char extension[][5] = {
133 int is_abs = 0, has_path = 0;
136 const char *
p = fname;
138 static const char pathname_too_long[] =
"openpath: pathname too long (ignored)\n\
139 \tDirectory \"%.*s\"%s\n\tFile \"%.*s\"%s\n";
140 #define PATHNAME_TOO_LONG() dln_warning(dln_warning_arg pathname_too_long, \
141 ((bp - fbuf) > 100 ? 100 : (int)(bp - fbuf)), fbuf, \
142 ((bp - fbuf) > 100 ? "..." : ""), \
143 (fnlen > 100 ? 100 : (int)fnlen), fname, \
144 (fnlen > 100 ? "..." : ""))
146 #define RETURN_IF(expr) if (expr) return (char *)fname;
152 "openpath: pathname too long (ignored)\n\tFile \"%.*s\"%s\n",
153 (fnlen > 100 ? 100 : (
int)fnlen), fname,
154 (fnlen > 100 ?
"..." :
""));
159 # define CharNext(p) ((p)+1)
161 # ifdef DOSISH_DRIVE_LETTER
162 if (((p[0] | 0x20) -
'a') < 26 && p[1] ==
':') {
189 for (j = 0;
STRCASECMP(ext, extension[j]); ) {
190 if (++j ==
sizeof(extension) /
sizeof(extension[0])) {
203 if (i + 1 > size)
goto toolong;
204 fspace = size - i - 1;
207 memcpy(fbuf, fname, i + 1);
208 goto needs_extension;
213 if (*p ==
'.' && *++p ==
'.') ++
p;
219 for (dp = path;; dp = ++ep) {
240 if (*dp ==
'~' && (l == 1 ||
280 memcpy(bp, fname, i + 1);
283 if (exe_flag && !ext) {
285 for (j = 0; j <
sizeof(extension) /
sizeof(extension[0]); j++) {
286 if (fspace <
strlen(extension[j])) {
290 strlcpy(bp + i, extension[j], fspace);
291 if (
stat(fbuf, &st) == 0)
298 if (
stat(fbuf, &st) == 0) {
299 if (exe_flag == 0)
return fbuf;
#define PATHNAME_TOO_LONG()
size_t strlen(const char *)
char * dln_find_file_r(const char *fname, const char *path, char *buf, size_t size)
static void dln_loaderror(const char *format,...)
RUBY_EXTERN size_t strlcpy(char *, const char *, size_t)
static char * dln_find_1(const char *fname, const char *path, char *buf, size_t size, int exe_flag)
#define STRCASECMP(s1, s2)
char * dln_find_exe_r(const char *fname, const char *path, char *buf, size_t size)
char * dln_find_exe(const char *fname, const char *path)
RUBY_EXTERN int eaccess(const char *, int)
unsigned char buf[MIME_BUF_SIZE]
char * strchr(char *, char)
static char fbuf[MAXPATHLEN]
char * dln_find_file(const char *fname, const char *path)