238 char exec_tmp[MAX_PATH + FILENAME_MAX + 100];
239 char exec_tmp2[MAX_PATH + FILENAME_MAX + 100];
240 char buf[MAX_PATH + FILENAME_MAX + 100];
248 if ((execname[0] ==
'\\') || (execname[0] ==
'/'))
250 #if defined(__CYGWIN__) 251 strcpy(exec_tmp,execname);
253 exec_tmp[0] = ((char) (_getdrive() + ((int)
'A') - 1));
256 strcat(exec_tmp,execname);
258 Trace((
"/ -\nexec_tmp\t%s\nexecname\t%s\nexecpath\t%s\n",
259 exec_tmp,execname,execpath));
264 j += sprintf(buf + j,
" [%d]: %s\n",i+1,
exts[i]);
265 error(
"Couldn't locate %s\nI tried appending the following " 266 "extensions: \n%s",exec_tmp,buf);
274 else if ((strlen(execname) > 3) &&
275 (execname[1] ==
':') &&
276 ((execname[2] ==
'\\') || (execname[2] ==
'/')))
278 strcpy(exec_tmp,execname);
279 Trace((
"x: -\nexec_tmp\t%s\nexecname\t%s\nexecpath\t%s\n",
280 exec_tmp,execname,execpath));
285 j += sprintf(buf + j,
" [%d]: %s\n",i+1,
exts[i]);
286 error(
"Couldn't locate %s\nI tried appending the following " 287 "extensions: \n%s",exec_tmp,buf);
294 else if ((execname[0] ==
'.') &&
295 ((execname[1] ==
'\\') || (execname[1] ==
'/')))
297 if (((
char*) getcwd(exec_tmp,MAX_PATH))==
NULL)
298 error(
"can't find current working directory");
300 exts,NUM_EXTENSIONS) )
302 exts,NUM_EXTENSIONS) )
306 j += sprintf(buf + j,
" [%d]: %s\n",i+1,
exts[i]);
307 error(
"Couldn't locate %s\n" 308 "I looked in the following directories:\n [1]: %s\n [2]: %s\n" 309 "I also tried appending the following " 310 "extensions: \n%s",execname,exec_tmp,execpath,buf);
321 orig_pathlist =
getenv(
"PATH");
322 if ((pathlist =
malloc (strlen(orig_pathlist)
324 + strlen(execpath)+ 3)) ==
NULL)
325 error(
"internal error - out of memory");
326 strcpy(pathlist,
".");
328 strcat(pathlist,execpath);
330 strcat(pathlist,orig_pathlist);
335 strcpy(exec_tmp,execname);
336 strcat(exec_tmp,
exts[i]);
337 pfopen(exec_tmp2,exec_tmp,pathlist);
342 Trace((
"exec_tmp\t%s\npathlist\t%s\n",exec_tmp2,pathlist));
345 if (exec_tmp2[0] ==
'\0')
349 j += sprintf(buf + j,
" [%d]: %s\n",i+1,
exts[i]);
350 error(
"Couldn't find %s anywhere.\n" 351 "I even looked in the PATH \n" 352 "I also tried appending the following " 353 "extensions: \n%s",execname,buf);
360 #if defined(__CYGWIN__) 363 char sym_link_name[MAX_PATH+1];
364 char real_name[MAX_PATH+1];
365 char dummy[MAX_PATH+1];
367 strcpy(exec_tmp,exec_tmp2);
369 CYGWIN_CONV_TO_POSIX_PATH((exec_tmp,sym_link_name));
370 Trace((sym_link_name));
372 if (lstat(sym_link_name, &stbuf) == 0)
374 if ((stbuf.st_mode & S_IFLNK) == S_IFLNK)
376 if (readlink(sym_link_name, real_name,
sizeof(real_name)) == -1)
377 error(
"problem reading symbolic link for %s",exec_tmp);
381 if (real_name[0] ==
'/')
382 strcpy(exec_tmp2,real_name);
385 CYGWIN_SPLIT_PATH((sym_link_name,exec_tmp2,dummy));
388 strcat(exec_tmp2,real_name);
393 strcpy(exec_tmp2, sym_link_name);
396 error(
"can't locate executable - %s",sym_link_name);
398 CYGWIN_CONV_TO_FULL_WIN32_PATH((exec_tmp2,exec));
400 strcpy (exec, exec_tmp2);
const char * exts[NUM_EXTENSIONS]
int endsWith(const char *s1, const char *s2)
int fileExistsMulti(char *fullname, const char *path, const char *name_noext, const char *exts[], const int extcnt)
#define PATH_SEP_CHAR_STR
int status int void * buf
void * malloc(size_t size)
void error(char *fmt,...)
char * pfopen(char *retval, const char *name, const char *dirs)
int fileExists(char *fullname, const char *path, const char *name)