#include "config.h"
#include <stdio.h>
-#include <ctype.h>
+#include "chartypes.h"
#include "bashtypes.h"
#ifndef _MINIX
# include <sys/file.h>
# include <unistd.h>
#endif
-#if defined (HAVE_LIMITS_H)
-# include <limits.h>
-#endif
-
#include "bashansi.h"
#include "memalloc.h"
#include "hashlib.h"
#include "pathexp.h"
#include "hashcmd.h"
+#include "findcmd.h" /* matching prototypes and declarations */
extern int posixly_correct;
/* Static functions defined and used in this file. */
-static char *find_user_command_internal (), *find_user_command_in_path ();
-static char *find_in_path_element (), *find_absolute_program ();
+static char *_find_user_command_internal __P((const char *, int));
+static char *find_user_command_internal __P((const char *, int));
+static char *find_user_command_in_path __P((const char *, char *, int));
+static char *find_in_path_element __P((const char *, char *, int, int, struct stat *));
+static char *find_absolute_program __P((const char *, int));
+
+static char *get_next_path_element __P((char *, int *));
/* The file name which we would try to execute, except that it isn't
possible to execute it. This is the first file that matches the
Zero is returned if the file is not found. */
int
file_status (name)
- char *name;
+ const char *name;
{
struct stat finfo;
what an executable file is. */
int
executable_file (file)
- char *file;
+ const char *file;
{
int s;
int
is_directory (file)
- char *file;
+ const char *file;
{
return (file_status (file) & FS_DIRECTORY);
}
int
executable_or_directory (file)
- char *file;
+ const char *file;
{
int s;
and that is the only match, then return that. */
char *
find_user_command (name)
- char *name;
+ const char *name;
{
return (find_user_command_internal (name, FS_EXEC_PREFERRED|FS_NODIRS));
}
returns the first file found. */
char *
find_path_file (name)
- char *name;
+ const char *name;
{
return (find_user_command_internal (name, FS_EXISTS));
}
static char *
_find_user_command_internal (name, flags)
- char *name;
+ const char *name;
int flags;
{
char *path_list, *cmd;
static char *
find_user_command_internal (name, flags)
- char *name;
+ const char *name;
int flags;
{
#ifdef __WIN32__
char *res, *dotexe;
- dotexe = xmalloc (strlen (name) + 5);
+ dotexe = (char *)xmalloc (strlen (name) + 5);
strcpy (dotexe, name);
strcat (dotexe, ".exe");
res = _find_user_command_internal (dotexe, flags);
in $PATH. Returns a newly-allocated string. */
char *
search_for_command (pathname)
- char *pathname;
+ const char *pathname;
{
char *hashed_file, *command;
int temp_path, st;
else
command = find_user_command (pathname);
if (command && hashing_enabled && temp_path == 0)
- remember_filename (pathname, command, dot_found_in_search, 1);
+ remember_filename ((char *)pathname, command, dot_found_in_search, 1); /* XXX fix const later */
}
return (command);
}
char *
user_command_matches (name, flags, state)
- char *name;
+ const char *name;
int flags, state;
{
register int i;
static char *
find_absolute_program (name, flags)
- char *name;
+ const char *name;
int flags;
{
int st;
if ((flags & FS_EXISTS) || ((flags & FS_EXEC_ONLY) && (st & FS_EXECABLE)))
return (savestring (name));
- return ((char *)NULL);
+ return (NULL);
}
static char *
find_in_path_element (name, path, flags, name_len, dotinfop)
- char *name, *path;
+ const char *name;
+ char *path;
int flags, name_len;
struct stat *dotinfop;
{
*/
static char *
find_user_command_in_path (name, path_list, flags)
- char *name;
+ const char *name;
char *path_list;
int flags;
{