home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
High Voltage Shareware
/
high1.zip
/
high1
/
DIR24
/
BASH_112.ZIP
/
BASH-112.TAR
/
bash-1.12
/
usrcmdos2.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-02-28
|
1KB
|
54 lines
#include <stdio.h>
#include <string.h>
#include "alias.h"
/* This does the dirty work for find_path_file () and find_user_command ().
NAME is the name of the file to search for.
PATH_LIST is a colon separated list of directories to search.
FLAGS contains bit fields which control the files which are eligible.
Some values are:
FS_EXEC_ONLY: The file must be an executable to be found.
FS_EXEC_PREFERRED: If we can't find an executable, then the
the first file matching NAME will do.
FS_EXISTS: The first file found will do.
*/
char *
find_user_command_in_path (name, path_list, flags)
char *name;
char *path_list;
int flags;
{char tempPath[257];
char *altName;
int name_len;
altName = NULL;
if(!DosSearchPath(3, "PATH", name, tempPath, 256))
goto l2;
/* if input name does not end in .exe append this string to name and save
in altName
*/
name_len = strlen(name);
if(!strcmp(name+name_len-4, ".exe"))
return NULL;
else
{altName = xmalloc(name_len+5);
strcpy(altName, name);
strcat(altName, ".exe");
}
if(DosSearchPath(3, "PATH", altName, tempPath, 256))
{free(altName);
return NULL;
}
l2:
if(altName != NULL)
free(altName);
altName = xmalloc(strlen(tempPath)+1);
strcpy(altName, tempPath);
return altName;
}