Changeset d752cf4 in mainline
- Timestamp:
- 2009-01-22T07:13:13Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 491af07
- Parents:
- 48c3d50
- Location:
- uspace/app/bdsh
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/builtin_cmds.c
r48c3d50 rd752cf4 40 40 41 41 extern volatile unsigned int cli_interactive; 42 43 int builtin_is_restricted(int pos)44 {45 builtin_t *cmd = builtins;46 cmd += pos;47 48 if (cli_interactive && cmd->restricted <= 0)49 return 0;50 if (!cli_interactive && cmd->restricted >= 0)51 return 0;52 53 return 1;54 }55 42 56 43 int is_builtin(const char *command) -
uspace/app/bdsh/cmds/builtins/builtin_aliases.h
r48c3d50 rd752cf4 5 5 6 6 char *builtin_aliases[] = { 7 "chdir", "cd",8 7 NULL, NULL 9 8 }; -
uspace/app/bdsh/cmds/builtins/cd/cd_def.h
r48c3d50 rd752cf4 4 4 &cmd_cd, 5 5 &help_cmd_cd, 6 -17 6 }, 8 {9 "chdir",10 NULL,11 &cmd_cd,12 &help_cmd_cd,13 -114 }, -
uspace/app/bdsh/cmds/cmds.h
r48c3d50 rd752cf4 37 37 mod_entry_t entry; /* Command (exec) entry function */ 38 38 mod_help_t help; /* Command (help) entry function */ 39 int restricted; /* Restricts to interactive/non-interactive only */40 39 } module_t; 41 40 -
uspace/app/bdsh/cmds/mod_cmds.c
r48c3d50 rd752cf4 53 53 54 54 extern volatile unsigned int cli_interactive; 55 56 int module_is_restricted(int pos)57 {58 /* Restriction Levels:59 * -1 -> Available only in interactive mode60 * 0 -> Available in any mode61 * 1 -> Available only in non-interactive mode */62 63 module_t *mod = modules;64 mod += pos;65 /* We're interactive, and the module is OK to run */66 if (cli_interactive && mod->restricted <= 0)67 return 0;68 /* We're not interactive, and the module is OK to run */69 if (!cli_interactive && mod->restricted >= 0)70 return 0;71 72 /* Anything else is just a big fat no :) */73 return 1;74 }75 55 76 56 /* Checks if an entry function matching command exists in modules[], if so -
uspace/app/bdsh/cmds/modules/cat/cat_def.h
r48c3d50 rd752cf4 4 4 &cmd_cat, 5 5 &help_cmd_cat, 6 07 6 }, 8 7 -
uspace/app/bdsh/cmds/modules/cp/cp_def.h
r48c3d50 rd752cf4 4 4 &cmd_cp, 5 5 &help_cmd_cp, 6 07 6 }, 8 7 -
uspace/app/bdsh/cmds/modules/help/help.c
r48c3d50 rd752cf4 134 134 /* First, show a list of built in commands that are available in this mode */ 135 135 for (cmd = builtins; cmd->name != NULL; cmd++, i++) { 136 if (!builtin_is_restricted(i)) {137 136 if (is_builtin_alias(cmd->name)) 138 137 printf(" %-16s\tAlias for `%s'\n", cmd->name, … … 140 139 else 141 140 printf(" %-16s\t%s\n", cmd->name, cmd->desc); 142 }143 141 } 144 142 … … 147 145 /* Now, show a list of module commands that are available in this mode */ 148 146 for (mod = modules; mod->name != NULL; mod++, i++) { 149 if (!module_is_restricted(i)) {150 147 if (is_module_alias(mod->name)) 151 148 printf(" %-16s\tAlias for `%s'\n", mod->name, … … 153 150 else 154 151 printf(" %-16s\t%s\n", mod->name, mod->desc); 155 }156 152 } 157 153 -
uspace/app/bdsh/cmds/modules/help/help_def.h
r48c3d50 rd752cf4 4 4 &cmd_help, 5 5 &help_cmd_help, 6 07 6 }, -
uspace/app/bdsh/cmds/modules/ls/ls_def.h
r48c3d50 rd752cf4 4 4 &cmd_ls, 5 5 &help_cmd_ls, 6 07 6 }, 8 9 {10 "dir",11 NULL,12 &cmd_ls,13 &help_cmd_ls,14 015 },16 -
uspace/app/bdsh/cmds/modules/mkdir/mkdir_def.h
r48c3d50 rd752cf4 4 4 &cmd_mkdir, 5 5 &help_cmd_mkdir, 6 07 6 }, 8 7 9 {10 "md",11 NULL,12 &cmd_mkdir,13 &help_cmd_mkdir,14 015 },16 8 -
uspace/app/bdsh/cmds/modules/module_aliases.h
r48c3d50 rd752cf4 13 13 14 14 char *mod_aliases[] = { 15 "exit", "quit",16 "md", "mkdir",17 "del", "rm",18 "dir", "ls",19 15 NULL, NULL 20 16 }; -
uspace/app/bdsh/cmds/modules/pwd/pwd_def.h
r48c3d50 rd752cf4 4 4 &cmd_pwd, 5 5 &help_cmd_pwd, 6 -17 6 }, -
uspace/app/bdsh/cmds/modules/quit/quit.c
r48c3d50 rd752cf4 35 35 #include "cmds.h" 36 36 37 static char *cmdname = " quit";37 static char *cmdname = "exit"; 38 38 39 39 extern volatile unsigned int cli_quit; -
uspace/app/bdsh/cmds/modules/quit/quit_def.h
r48c3d50 rd752cf4 1 1 { 2 " quit",3 "Exit the console",2 "exit", 3 "Exit the shell", 4 4 &cmd_quit, 5 5 &help_cmd_quit, 6 -17 6 }, 8 {9 "exit",10 NULL,11 &cmd_quit,12 &help_cmd_quit,13 -114 }, -
uspace/app/bdsh/cmds/modules/rm/rm_def.h
r48c3d50 rd752cf4 4 4 &cmd_rm, 5 5 &help_cmd_rm, 6 07 6 }, 8 7 9 {10 "del",11 NULL,12 &cmd_rm,13 &help_cmd_rm,14 015 },16 -
uspace/app/bdsh/cmds/modules/sleep/sleep_def.h
r48c3d50 rd752cf4 4 4 &cmd_sleep, 5 5 &help_cmd_sleep, 6 07 6 }, 8 7 -
uspace/app/bdsh/cmds/modules/touch/touch_def.h
r48c3d50 rd752cf4 4 4 &cmd_touch, 5 5 &help_cmd_touch, 6 07 6 }, 8 7 -
uspace/app/bdsh/input.c
r48c3d50 rd752cf4 73 73 tmp = cli_strdup(usr->line); 74 74 75 /* Break up what the user typed, space delimited */76 77 /* TODO: Protect things in quotes / ticks, expand wildcards */78 75 cmd[n] = cli_strtok(tmp, " "); 79 76 while (cmd[n] && n < WORD_MAX) { … … 87 84 } 88 85 89 /* Its a builtin command */86 /* Its a builtin command ? */ 90 87 if ((i = (is_builtin(cmd[0]))) > -1) { 91 /* Its not available in this mode, see what try_exec() thinks */92 if (builtin_is_restricted(i)) {93 rc = try_exec(cmd[0], cmd);94 if (rc)95 /* No external matching it could be found, tell the96 * user that the command does exist, but is not97 * available in this mode. */98 cli_restricted(cmd[0]);99 goto finit;100 }101 /* Its a builtin, its available, run it */102 88 rc = run_builtin(i, cmd, usr); 103 89 goto finit; 104 /* We repeat the same dance for modules*/90 /* Its a module ? */ 105 91 } else if ((i = (is_module(cmd[0]))) > -1) { 106 if (module_is_restricted(i)) {107 rc = try_exec(cmd[0], cmd);108 if (rc)109 cli_restricted(cmd[0]);110 goto finit;111 }112 92 rc = run_module(i, cmd); 113 93 goto finit; 114 } else {115 /* Its not a module or builtin, restricted or otherwise.116 * See what try_exec() thinks of it and just pass its return117 * value back to the caller */118 rc = try_exec(cmd[0], cmd);119 goto finit;120 94 } 95 96 /* See what try_exec thinks of it */ 97 rc = try_exec(cmd[0], cmd); 121 98 122 99 finit:
Note:
See TracChangeset
for help on using the changeset viewer.