Changeset 4deb8b5 in mainline
- Timestamp:
- 2010-11-14T17:32:18Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a9db9b8
- Parents:
- d52b0044
- Location:
- uspace/app
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/help/help.c
rd52b0044 r4deb8b5 45 45 extern const char *progname; 46 46 47 #define HELP_IS_MODULE 1 48 #define HELP_IS_BUILTIN 0 49 #define HELP_IS_RUBBISH -1 47 #define HELP_IS_COMMANDS 2 48 #define HELP_IS_MODULE 1 49 #define HELP_IS_BUILTIN 0 50 #define HELP_IS_RUBBISH -1 50 51 51 52 volatile int mod_switch = -1; … … 55 56 { 56 57 int rc = HELP_IS_RUBBISH; 58 59 if (str_cmp(cmd, "commands") == 0) 60 return HELP_IS_COMMANDS; 57 61 58 62 rc = is_builtin(cmd); … … 90 94 } 91 95 92 int cmd_help(char *argv[])96 static void help_commands(void) 93 97 { 98 builtin_t *cmd; 94 99 module_t *mod; 95 builtin_t *cmd; 96 unsigned int i = 0; 97 int rc = 0; 98 int argc; 99 int level = HELP_SHORT; 100 unsigned int i; 100 101 101 argc = cli_count_args(argv); 102 103 if (argc > 3) { 104 printf("\nToo many arguments to `%s', try:\n", cmdname); 105 help_cmd_help(HELP_SHORT); 106 return CMD_FAILURE; 107 } 108 109 if (argc == 3) { 110 if (!str_cmp("extended", argv[2])) 111 level = HELP_LONG; 112 else 113 level = HELP_SHORT; 114 } 115 116 if (argc > 1) { 117 rc = is_mod_or_builtin(argv[1]); 118 switch (rc) { 119 case HELP_IS_RUBBISH: 120 printf("Invalid command %s\n", argv[1]); 121 return CMD_FAILURE; 122 case HELP_IS_MODULE: 123 help_module(mod_switch, level); 124 return CMD_SUCCESS; 125 case HELP_IS_BUILTIN: 126 help_builtin(mod_switch, level); 127 return CMD_SUCCESS; 128 } 129 } 130 131 printf("\n Available commands are:\n"); 102 printf("\n Bdsh built-in commands:\n"); 132 103 printf(" ------------------------------------------------------------\n"); 133 104 … … 154 125 printf("\n Try %s %s for more information on how `%s' works.\n\n", 155 126 cmdname, cmdname, cmdname); 127 } 128 129 /** Display survival tips. ('help' without arguments) */ 130 static void help_survival(void) 131 { 132 printf("Don't panic!\n\n"); 133 134 printf("This is Bdsh, the Brain dead shell, currently " 135 "the primary user interface to HelenOS. Bdsh allows you to enter " 136 "commands and supports history (Up, Down arrow keys), " 137 "line editing (Left Arrow, Right Arrow, Home, End, Backspace), " 138 "selection (Shift + movement keys), copy and paste (Ctrl-C, " 139 "Ctrl-V), similar to common desktop environments.\n\n"); 140 141 printf("The most basic filesystem commands are Bdsh builtins. Type " 142 "'help commands' [Enter] to see the list of Bdsh builtin commands. " 143 "Other commands are external executables located in the /app and " 144 "/srv directories. Type 'ls /app' [Enter] and 'ls /srv' [Enter] " 145 "to see their list. You can execute an external command simply " 146 "by entering its name (e.g. type 'tetris' [Enter]).\n\n"); 147 148 printf("HelenOS has virtual consoles (VCs). You can switch between " 149 "these using the F1-F11 keys.\n\n"); 150 151 printf("This is but a small glimpse of what you can do with HelenOS. " 152 "To learn more please point your browser to the HelenOS User's " 153 "Guide: http://trac.helenos.org/trac.fcgi/wiki/UsersGuide\n\n"); 154 } 155 156 int cmd_help(char *argv[]) 157 { 158 int rc = 0; 159 int argc; 160 int level = HELP_SHORT; 161 162 argc = cli_count_args(argv); 163 164 if (argc > 3) { 165 printf("\nToo many arguments to `%s', try:\n", cmdname); 166 help_cmd_help(HELP_SHORT); 167 return CMD_FAILURE; 168 } 169 170 if (argc == 3) { 171 if (!str_cmp("extended", argv[2])) 172 level = HELP_LONG; 173 else 174 level = HELP_SHORT; 175 } 176 177 if (argc > 1) { 178 rc = is_mod_or_builtin(argv[1]); 179 switch (rc) { 180 case HELP_IS_RUBBISH: 181 printf("Invalid topic %s\n", argv[1]); 182 return CMD_FAILURE; 183 case HELP_IS_COMMANDS: 184 help_commands(); 185 return CMD_SUCCESS; 186 case HELP_IS_MODULE: 187 help_module(mod_switch, level); 188 return CMD_SUCCESS; 189 case HELP_IS_BUILTIN: 190 help_builtin(mod_switch, level); 191 return CMD_SUCCESS; 192 } 193 } 194 195 help_survival(); 156 196 157 197 return CMD_SUCCESS; -
uspace/app/bdsh/scli.c
rd52b0044 r4deb8b5 89 89 exit(EXIT_FAILURE); 90 90 91 printf("Welcome to %s - %s\nType `help' at any time for usage information.\n",92 progname, PACKAGE_STRING);93 94 91 while (!cli_quit) { 95 92 get_input(&usr); -
uspace/app/getterm/Makefile
rd52b0044 r4deb8b5 34 34 SOURCES = \ 35 35 getterm.c \ 36 version.c 36 version.c \ 37 welcome.c 37 38 38 39 include $(USPACE_PREFIX)/Makefile.common -
uspace/app/getterm/getterm.c
rd52b0044 r4deb8b5 43 43 #include <errno.h> 44 44 #include "version.h" 45 #include "welcome.h" 45 46 46 47 #define APP_NAME "getterm" … … 48 49 static void usage(void) 49 50 { 50 printf("Usage: %s <terminal> <command> [<arguments...>]\n", APP_NAME);51 printf("Usage: %s <terminal> [-w] <command> [<arguments...>]\n", APP_NAME); 51 52 } 52 53 … … 79 80 int retval; 80 81 task_id_t id; 81 char *fname; 82 char *fname, *term; 83 char **cmd_args; 84 bool print_wmsg; 82 85 83 if (argc < 3) { 86 ++argv; --argc; 87 if (argc < 1) { 84 88 usage(); 85 89 return -1; 86 90 } 91 92 if (str_cmp(*argv, "-w") == 0) { 93 print_wmsg = true; 94 ++argv; --argc; 95 } else { 96 print_wmsg = false; 97 } 98 99 if (argc < 2) { 100 usage(); 101 return -1; 102 } 103 104 term = *argv++; 105 fname = *argv; 106 cmd_args = argv; 87 107 88 reopen(&stdin, 0, argv[1], O_RDONLY, "r");89 reopen(&stdout, 1, argv[1], O_WRONLY, "w");90 reopen(&stderr, 2, argv[1], O_WRONLY, "w");108 reopen(&stdin, 0, term, O_RDONLY, "r"); 109 reopen(&stdout, 1, term, O_WRONLY, "w"); 110 reopen(&stderr, 2, term, O_WRONLY, "w"); 91 111 92 112 /* … … 105 125 return -4; 106 126 107 version_print(argv[1]); 108 fname = argv[2]; 109 110 rc = task_spawnv(&id, fname, (const char * const *) &argv[2]); 127 version_print(term); 128 if (print_wmsg) 129 welcome_msg_print(); 130 131 rc = task_spawnv(&id, fname, (const char * const *) cmd_args); 111 132 if (rc != EOK) { 112 133 printf("%s: Error spawning %s (%s)\n", APP_NAME, fname, -
uspace/app/init/init.c
rd52b0044 r4deb8b5 200 200 } 201 201 202 static void getterm(const char *dev, const char *app )202 static void getterm(const char *dev, const char *app, bool wmsg) 203 203 { 204 204 char term[DEVMAP_NAME_MAXLEN]; … … 218 218 } 219 219 220 rc = task_spawnl(NULL, APP_GETTERM, APP_GETTERM, term, app, NULL); 221 if (rc != EOK) { 222 printf("%s: Error spawning %s %s %s (%s)\n", NAME, 223 APP_GETTERM, term, app, str_error(rc)); 220 if (wmsg) { 221 rc = task_spawnl(NULL, APP_GETTERM, APP_GETTERM, "-w", term, 222 app, NULL); 223 if (rc != EOK) { 224 printf("%s: Error spawning %s -w %s %s (%s)\n", NAME, 225 APP_GETTERM, term, app, str_error(rc)); 226 } 227 } else { 228 rc = task_spawnl(NULL, APP_GETTERM, APP_GETTERM, term, app, 229 NULL); 230 if (rc != EOK) { 231 printf("%s: Error spawning %s %s %s (%s)\n", NAME, 232 APP_GETTERM, term, app, str_error(rc)); 233 } 224 234 } 225 235 } … … 295 305 #endif 296 306 297 getterm("term/vc0", "/app/bdsh" );298 getterm("term/vc1", "/app/bdsh" );299 getterm("term/vc2", "/app/bdsh" );300 getterm("term/vc3", "/app/bdsh" );301 getterm("term/vc4", "/app/bdsh" );302 getterm("term/vc5", "/app/bdsh" );303 getterm("term/vc6", "/app/klog" );307 getterm("term/vc0", "/app/bdsh", true); 308 getterm("term/vc1", "/app/bdsh", false); 309 getterm("term/vc2", "/app/bdsh", false); 310 getterm("term/vc3", "/app/bdsh", false); 311 getterm("term/vc4", "/app/bdsh", false); 312 getterm("term/vc5", "/app/bdsh", false); 313 getterm("term/vc6", "/app/klog", false); 304 314 305 315 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.