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) 54 #define free(x) xfree(x) 60 #include <sys/types.h> 64 # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) 67 #ifdef HAVE_SYS_PARAM_H 68 # include <sys/param.h> 71 # define MAXPATHLEN 1024 82 static char *
dln_find_1(
const char *fname,
const char *path,
char *
buf,
size_t size,
int exe_flag);
91 if (path) path = envpath =
strdup(path);
96 path =
"/usr/local/bin;/usr/ucb;/usr/bin;/bin;.";
98 path =
"/usr/local/bin:/usr/ucb:/usr/bin:/bin:.";
102 if (envpath)
free(envpath);
109 if (!path) path =
".";
131 register const char *
dp;
132 register const char *ep;
135 size_t i, fnlen, fspace;
137 static const char extension[][5] = {
141 int is_abs = 0, has_path = 0;
144 const char *
p = fname;
146 static const char pathname_too_long[] =
"openpath: pathname too long (ignored)\n\ 147 \tDirectory \"%.*s\"%s\n\tFile \"%.*s\"%s\n";
148 #define PATHNAME_TOO_LONG() dln_warning(dln_warning_arg pathname_too_long, \ 149 ((bp - fbuf) > 100 ? 100 : (int)(bp - fbuf)), fbuf, \ 150 ((bp - fbuf) > 100 ? "..." : ""), \ 151 (fnlen > 100 ? 100 : (int)fnlen), fname, \ 152 (fnlen > 100 ? "..." : "")) 154 #define RETURN_IF(expr) if (expr) return (char *)fname; 160 "openpath: pathname too long (ignored)\n\tFile \"%.*s\"%s\n",
161 (fnlen > 100 ? 100 : (
int)fnlen), fname,
162 (fnlen > 100 ?
"..." :
""));
167 # define CharNext(p) ((p)+1) 169 # ifdef DOSISH_DRIVE_LETTER 170 if (((
p[0] | 0x20) -
'a') < 26 &&
p[1] ==
':') {
197 for (j = 0;
STRCASECMP(ext, extension[j]); ) {
198 if (++j ==
sizeof(extension) /
sizeof(extension[0])) {
211 if (
i + 1 >
size)
goto toolong;
212 fspace =
size -
i - 1;
215 memcpy(
fbuf, fname,
i + 1);
216 goto needs_extension;
221 if (*
p ==
'.' && *++
p ==
'.') ++
p;
227 for (
dp = path;;
dp = ++ep) {
248 if (*
dp ==
'~' && (l == 1 ||
288 memcpy(
bp, fname,
i + 1);
291 if (exe_flag && !ext) {
293 for (j = 0; j <
sizeof(extension) /
sizeof(extension[0]); j++) {
294 if (fspace <
strlen(extension[j])) {
307 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)
int eaccess(const char *path, int mode)
static void dln_loaderror(const char *format,...)
static char * dln_find_1(const char *fname, const char *path, char *buf, size_t size, int exe_flag)
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)
unsigned char buf[MIME_BUF_SIZE]
char * strchr(char *, char)
RUBY_EXTERN size_t strlcpy(char *, const char *, size_t)
static char fbuf[MAXPATHLEN]
#define STRCASECMP(s1, s2)
char * dln_find_file(const char *fname, const char *path)