Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 3371 → Rev 3372

/trunk/uspace/app/bdsh/scli.h
10,7 → 10,7
char *line;
char *cwd;
char *prompt;
uint64_t lasterr;
int lasterr;
} cliuser_t;
 
extern unsigned int cli_set_prompt(cliuser_t *usr);
/trunk/uspace/app/bdsh/input.c
43,8 → 43,12
 
extern volatile unsigned int cli_interactive;
 
/* Not exposed in input.h */
static void cli_restricted(char *);
static void read_line(char *, int);
 
/* More than a macro than anything */
void cli_restricted(char *cmd)
static void cli_restricted(char *cmd)
{
printf("%s is not available in %s mode\n", cmd,
cli_interactive ? "interactive" : "non-interactive");
81,17 → 85,22
goto finit;
}
 
/* Check what kind of command argv[0] might be, TODO: move this to
* a function */
/* Its a builtin command */
if ((i = (is_builtin(cmd[0]))) > -1) {
/* Its not available in this mode, see what try_exec() thinks */
if (builtin_is_restricted(i)) {
rc = try_exec(cmd[0], cmd);
if (rc)
/* No external matching it could be found, tell the
* user that the command does exist, but is not
* available in this mode. */
cli_restricted(cmd[0]);
goto finit;
}
/* Its a builtin, its available, run it */
rc = run_builtin(i, cmd, usr);
goto finit;
/* We repeat the same dance for modules */
} else if ((i = (is_module(cmd[0]))) > -1) {
if (module_is_restricted(i)) {
rc = try_exec(cmd[0], cmd);
102,6 → 111,9
rc = run_module(i, cmd);
goto finit;
} else {
/* Its not a module or builtin, restricted or otherwise.
* See what try_exec() thinks of it and just pass its return
* value back to the caller */
rc = try_exec(cmd[0], cmd);
goto finit;
}
118,7 → 130,7
}
 
/* Borrowed from Jiri Svoboda's 'cli' uspace app */
void read_line(char *buffer, int n)
static void read_line(char *buffer, int n)
{
char c;
int chars;
144,6 → 156,9
buffer[chars] = '\0';
}
 
/* TODO:
* Implement something like editline() / readline(), if even
* just for command history and making arrows work. */
void get_input(cliuser_t *usr)
{
char line[INPUT_MAX];
/trunk/uspace/app/bdsh/input.h
4,9 → 4,8
#include "cmds/cmds.h"
 
/* prototypes */
 
extern void get_input(cliuser_t *);
extern int tok_input(cliuser_t *);
extern void get_input(cliuser_t *);
extern void cli_restricted(char *);
extern void read_line(char *, int);
 
#endif
/trunk/uspace/app/bdsh/exec.c
48,8 → 48,11
/* FIXME: Just have find_command() return an allocated string */
char *found;
 
static char *find_command(char *);
static unsigned int try_access(const char *);
 
/* work-around for access() */
unsigned int try_access(const char *f)
static unsigned int try_access(const char *f)
{
int fd;
 
63,7 → 66,7
 
/* Returns the full path of "cmd" if cmd is found, else just hand back
* cmd as it was presented */
char *find_command(char *cmd)
static char *find_command(char *cmd)
{
char *path_tok;
char *path[PATH_MAX];
/trunk/uspace/app/bdsh/exec.h
3,8 → 3,5
 
#include <task.h>
 
extern char *find_command(char *);
extern unsigned int try_exec(char *, char **);
extern unsigned int try_access(const char *);
 
#endif