Changes in / [9e2e715:a9db9b8] in mainline


Ignore:
Location:
uspace/app
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/cmds/modules/help/help.c

    r9e2e715 ra9db9b8  
    4545extern const char *progname;
    4646
    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
    5051
    5152volatile int mod_switch = -1;
     
    5556{
    5657        int rc = HELP_IS_RUBBISH;
     58
     59        if (str_cmp(cmd, "commands") == 0)
     60                return HELP_IS_COMMANDS;
    5761
    5862        rc = is_builtin(cmd);
     
    9094}
    9195
    92 int cmd_help(char *argv[])
     96static void help_commands(void)
    9397{
     98        builtin_t *cmd;
    9499        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;
    100101
    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");
    132103        printf("  ------------------------------------------------------------\n");
    133104
     
    154125        printf("\n  Try %s %s for more information on how `%s' works.\n\n",
    155126                cmdname, cmdname, cmdname);
     127}
     128
     129/** Display survival tips. ('help' without arguments) */
     130static 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
     156int 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();
    156196
    157197        return CMD_SUCCESS;
  • uspace/app/bdsh/scli.c

    r9e2e715 ra9db9b8  
    8989                exit(EXIT_FAILURE);
    9090
    91         printf("Welcome to %s - %s\nType `help' at any time for usage information.\n",
    92                 progname, PACKAGE_STRING);
    93 
    9491        while (!cli_quit) {
    9592                get_input(&usr);
  • uspace/app/getterm/Makefile

    r9e2e715 ra9db9b8  
    3434SOURCES = \
    3535        getterm.c \
    36         version.c
     36        version.c \
     37        welcome.c
    3738
    3839include $(USPACE_PREFIX)/Makefile.common
  • uspace/app/getterm/getterm.c

    r9e2e715 ra9db9b8  
    4343#include <errno.h>
    4444#include "version.h"
     45#include "welcome.h"
    4546
    4647#define APP_NAME  "getterm"
     
    4849static void usage(void)
    4950{
    50         printf("Usage: %s <terminal> <path>\n", APP_NAME);
     51        printf("Usage: %s <terminal> [-w] <command> [<arguments...>]\n", APP_NAME);
    5152}
    5253
     
    7374}
    7475
    75 static task_id_t spawn(const char *fname)
    76 {
    77         task_id_t id;
    78         int rc;
    79        
    80         rc = task_spawnl(&id, fname, fname, NULL);
    81         if (rc != EOK) {
    82                 printf("%s: Error spawning %s (%s)\n", APP_NAME, fname,
    83                     str_error(rc));
    84                 return 0;
    85         }
    86        
    87         return id;
    88 }
    89 
    9076int main(int argc, char *argv[])
    9177{
    92         if (argc < 3) {
     78        int rc;
     79        task_exit_t texit;
     80        int retval;
     81        task_id_t id;
     82        char *fname, *term;
     83        char **cmd_args;
     84        bool print_wmsg;
     85
     86        ++argv; --argc;
     87        if (argc < 1) {
    9388                usage();
    9489                return -1;
    9590        }
     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;
    96107       
    97         reopen(&stdin, 0, argv[1], O_RDONLY, "r");
    98         reopen(&stdout, 1, argv[1], O_WRONLY, "w");
    99         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");
    100111       
    101112        /*
     
    114125                return -4;
    115126       
    116         version_print(argv[1]);
    117         task_id_t id = spawn(argv[2]);
    118        
    119         if (id != 0) {
    120                 task_exit_t texit;
    121                 int retval;
    122                 task_wait(id, &texit, &retval);
    123                
    124                 return 0;
     127        version_print(term);
     128        if (print_wmsg)
     129                welcome_msg_print();
     130
     131        rc = task_spawnv(&id, fname, (const char * const *) cmd_args);
     132        if (rc != EOK) {
     133                printf("%s: Error spawning %s (%s)\n", APP_NAME, fname,
     134                    str_error(rc));
     135                return -5;
    125136        }
    126        
    127         return -5;
     137
     138        rc = task_wait(id, &texit, &retval);
     139        if (rc != EOK) {
     140                printf("%s: Error waiting for %s (%s)\n", APP_NAME, fname,
     141                    str_error(rc));
     142                return -6;
     143        }
     144
     145        return 0;
    128146}
    129147
  • uspace/app/getterm/version.c

    r9e2e715 ra9db9b8  
    6161        printf("HelenOS release %s (%s)%s%s\n", release, name, revision, timestamp);
    6262        printf("Running on %s (%s)\n", arch, term);
    63         printf("Copyright (c) 2001-2009 HelenOS project\n\n");
     63        printf("Copyright (c) 2001-2010 HelenOS project\n\n");
    6464}
    6565
  • uspace/app/init/init.c

    r9e2e715 ra9db9b8  
    200200}
    201201
    202 static void getterm(const char *dev, const char *app)
     202static void getterm(const char *dev, const char *app, bool wmsg)
    203203{
    204204        char term[DEVMAP_NAME_MAXLEN];
     
    218218        }
    219219       
    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                }
    224234        }
    225235}
     
    295305#endif
    296306       
    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);
    304314       
    305315        return 0;
Note: See TracChangeset for help on using the changeset viewer.