Changeset 1433ecda in mainline for uspace/app/bdsh/cmds


Ignore:
Timestamp:
2018-04-04T15:42:37Z (6 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2c4e1cc
Parents:
47b2d7e3
Message:

Fix cstyle: make ccheck-fix and commit only files where all the changes are good.

Location:
uspace/app/bdsh/cmds
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/cmds/builtin_cmds.c

    r47b2d7e3 r1433ecda  
    6464                return -1;
    6565
    66         for(i=0; builtin_aliases[i] != NULL; i+=2) {
     66        for (i = 0; builtin_aliases[i] != NULL; i += 2) {
    6767                if (!str_cmp(builtin_aliases[i], command))
    6868                        return 1;
     
    7979                return (char *)NULL;
    8080
    81         for(i=0; builtin_aliases[i] != NULL; i+=2) {
     81        for (i = 0; builtin_aliases[i] != NULL; i += 2) {
    8282                if (!str_cmp(builtin_aliases[i], command))
    83                         return (char *)builtin_aliases[i+1];
     83                        return (char *)builtin_aliases[i + 1];
    8484        }
    8585
  • uspace/app/bdsh/cmds/builtins/batch/batch.c

    r47b2d7e3 r1433ecda  
    4848        if (level == HELP_SHORT) {
    4949                printf(
    50                 "\n  batch [filename] [-c]\n"
    51                 "  Issues commands stored in the file.\n"
    52                 "  Each command must correspond to the single line in the file.\n\n");
     50                    "\n  batch [filename] [-c]\n"
     51                    "  Issues commands stored in the file.\n"
     52                    "  Each command must correspond to the single line in the file.\n\n");
    5353        } else {
    5454                printf(
    55                 "\n  `batch' - issues a batch of commands\n"
    56                 "  Issues commands stored in the file. Each command must correspond\n"
    57                 "  to the single line in the file. Empty lines can be used to visually\n"
    58                 "  separate groups of commands. There is no support for comments,\n"
    59                 "  variables, recursion or other programming constructs - the `batch'\n"
    60                 "  command is indeed very trivial.\n"
    61                 "  If the filename is followed by -c, execution continues even if some\n"
    62                 "  of the commands failed.\n\n");
     55                    "\n  `batch' - issues a batch of commands\n"
     56                    "  Issues commands stored in the file. Each command must correspond\n"
     57                    "  to the single line in the file. Empty lines can be used to visually\n"
     58                    "  separate groups of commands. There is no support for comments,\n"
     59                    "  variables, recursion or other programming constructs - the `batch'\n"
     60                    "  command is indeed very trivial.\n"
     61                    "  If the filename is followed by -c, execution continues even if some\n"
     62                    "  of the commands failed.\n\n");
    6363        }
    6464
  • uspace/app/bdsh/cmds/builtins/builtins.h

    r47b2d7e3 r1433ecda  
    1212#include "cd/cd_def.inc"
    1313#include "exit/exit_def.inc"
    14         {NULL, NULL, NULL, NULL, 0}
     14        { NULL, NULL, NULL, NULL, 0 }
    1515};
    1616
  • uspace/app/bdsh/cmds/builtins/cd/cd.c

    r47b2d7e3 r1433ecda  
    7272        } else {
    7373                printf(
    74                 "  %s <directory>\n"
    75                 "  Change directory to <directory>, e.g `%s /sbin'\n",
    76                         cmdname, cmdname);
     74                    "  %s <directory>\n"
     75                    "  Change directory to <directory>, e.g `%s /sbin'\n",
     76                    cmdname, cmdname);
    7777        }
    7878
     
    113113        if (argc < 2) {
    114114                printf("%s - no directory specified. Try `help %s extended'\n",
    115                         cmdname, cmdname);
     115                    cmdname, cmdname);
    116116                return CMD_FAILURE;
    117117        }
  • uspace/app/bdsh/cmds/cmds.h

    r47b2d7e3 r1433ecda  
    5252
    5353/* Types for module command entry and help */
    54 typedef int (* mod_entry_t)(char **);
    55 typedef void (* mod_help_t)(unsigned int);
     54typedef int (*mod_entry_t)(char **);
     55typedef void (*mod_help_t)(unsigned int);
    5656
    5757/* Built-in commands need to be able to modify cliuser_t */
    58 typedef int (* builtin_entry_t)(char **, cliuser_t *);
    59 typedef void (* builtin_help_t)(unsigned int);
     58typedef int (*builtin_entry_t)(char **, cliuser_t *);
     59typedef void (*builtin_help_t)(unsigned int);
    6060
    6161/* Module structure */
  • uspace/app/bdsh/cmds/mod_cmds.c

    r47b2d7e3 r1433ecda  
    8080                return -1;
    8181
    82         for(i=0; mod_aliases[i] != NULL; i+=2) {
     82        for (i = 0; mod_aliases[i] != NULL; i += 2) {
    8383                if (!str_cmp(mod_aliases[i], command))
    8484                        return 1;
     
    9696                return (char *)NULL;
    9797
    98         for(i=0; mod_aliases[i] != NULL; i+=2) {
     98        for (i = 0; mod_aliases[i] != NULL; i += 2) {
    9999                if (!str_cmp(mod_aliases[i], command))
    100                         return (char *)mod_aliases[i+1];
     100                        return (char *)mod_aliases[i + 1];
    101101        }
    102102
  • uspace/app/bdsh/cmds/modules/cat/cat.c

    r47b2d7e3 r1433ecda  
    8888                help_cmd_cat(HELP_SHORT);
    8989                printf(
    90                 "Usage:  %s [options] <file1> [file2] [...]\n"
    91                 "Options:\n"
    92                 "  -h, --help       A short option summary\n"
    93                 "  -v, --version    Print version information and exit\n"
    94                 "  -H, --head ##    Print only the first ## bytes\n"
    95                 "  -t, --tail ##    Print only the last ## bytes\n"
    96                 "  -b, --buffer ##  Set the read buffer size to ##\n"
    97                 "  -m, --more       Pause after each screen full\n"
    98                 "  -x, --hex        Print bytes as hex values\n"
    99                 "  -s, --stdin      Treat `-' in file list as standard input\n"
    100                 "  -n, --number     Number all output lines\n"
    101                 "Currently, %s is under development, some options don't work.\n",
    102                 cmdname, cmdname);
     90                    "Usage:  %s [options] <file1> [file2] [...]\n"
     91                    "Options:\n"
     92                    "  -h, --help       A short option summary\n"
     93                    "  -v, --version    Print version information and exit\n"
     94                    "  -H, --head ##    Print only the first ## bytes\n"
     95                    "  -t, --tail ##    Print only the last ## bytes\n"
     96                    "  -b, --buffer ##  Set the read buffer size to ##\n"
     97                    "  -m, --more       Pause after each screen full\n"
     98                    "  -x, --hex        Print bytes as hex values\n"
     99                    "  -s, --stdin      Treat `-' in file list as standard input\n"
     100                    "  -n, --number     Number all output lines\n"
     101                    "Currently, %s is under development, some options don't work.\n",
     102                    cmdname, cmdname);
    103103        }
    104104
     
    108108static void waitprompt(void)
    109109{
    110         console_set_pos(console, 0, console_rows-1);
     110        console_set_pos(console, 0, console_rows - 1);
    111111        console_set_color(console, COLOR_WHITE, COLOR_BLUE, 0);
    112112
    113113        printf("ENTER/SPACE/PAGE DOWN - next page, "
    114                "ESC/Q - quit, C - continue unpaged");
     114            "ESC/Q - quit, C - continue unpaged");
    115115        fflush(stdout);
    116116
     
    265265                        for (i = 0; i < bytes && !should_quit; i++) {
    266266                                if (hex) {
    267                                         paged_char(hexchars[((uint8_t)buff[i])/16]);
    268                                         paged_char(hexchars[((uint8_t)buff[i])%16]);
    269                                         paged_char(((count+i+1) & 0xf) == 0 ? '\n' : ' ');
    270                                 }
    271                                 else {
     267                                        paged_char(hexchars[((uint8_t)buff[i]) / 16]);
     268                                        paged_char(hexchars[((uint8_t)buff[i]) % 16]);
     269                                        paged_char(((count + i + 1) & 0xf) == 0 ? '\n' : ' ');
     270                                } else {
    272271                                        wchar_t c = str_decode(buff, &offset, bytes);
    273272                                        if (c == 0) {
     
    353352                        return CMD_SUCCESS;
    354353                case 'H':
    355                         if (!optarg || str_uint64_t(optarg, NULL, 10, false, &head) != EOK ) {
     354                        if (!optarg || str_uint64_t(optarg, NULL, 10, false, &head) != EOK) {
    356355                                puts("Invalid head size\n");
    357356                                return CMD_FAILURE;
     
    359358                        break;
    360359                case 't':
    361                         if (!optarg || str_uint64_t(optarg, NULL, 10, false, &tail) != EOK ) {
     360                        if (!optarg || str_uint64_t(optarg, NULL, 10, false, &tail) != EOK) {
    362361                                puts("Invalid tail size\n");
    363362                                return CMD_FAILURE;
     
    367366                        break;
    368367                case 'b':
    369                         if (!optarg || str_size_t(optarg, NULL, 10, false, &buffer) != EOK ) {
     368                        if (!optarg || str_size_t(optarg, NULL, 10, false, &buffer) != EOK) {
    370369                                puts("Invalid buffer size\n");
    371370                                return CMD_FAILURE;
     
    391390        if (argc < 1) {
    392391                printf("%s - incorrect number of arguments. Try `%s --help'\n",
    393                         cmdname, cmdname);
     392                    cmdname, cmdname);
    394393                return CMD_FAILURE;
    395394        }
  • uspace/app/bdsh/cmds/modules/cp/cp.c

    r47b2d7e3 r1433ecda  
    5353        { "buffer", required_argument, 0, 'b' },
    5454        { "force", no_argument, 0, 'f' },
    55         { "interactive", no_argument, 0, 'i'},
     55        { "interactive", no_argument, 0, 'i' },
    5656        { "recursive", no_argument, 0, 'r' },
    5757        { "help", no_argument, 0, 'h' },
     
    160160                }
    161161
    162                 switch(ev.ev.key.key) {
     162                switch (ev.ev.key.key) {
    163163                case KC_Y:
    164164                        printf("y\n");
     
    384384
    385385static int copy_file(const char *src, const char *dest,
    386         size_t blen, int vb)
     386    size_t blen, int vb)
    387387{
    388388        int fd1, fd2;
  • uspace/app/bdsh/cmds/modules/echo/echo.c

    r47b2d7e3 r1433ecda  
    5757        unsigned int argc;
    5858
    59         for (argc = 1; argv[argc] != NULL; argc ++) {
     59        for (argc = 1; argv[argc] != NULL; argc++) {
    6060                printf("%s ", argv[argc]);
    6161        }
  • uspace/app/bdsh/cmds/modules/help/help.c

    r47b2d7e3 r1433ecda  
    7979        if (level == HELP_SHORT) {
    8080                printf(
    81                 "\n  %s [command] <extended>\n"
    82                 "  Use help [command] extended for detailed help on [command] "
    83                 ", even `help'\n\n", cmdname);
     81                    "\n  %s [command] <extended>\n"
     82                    "  Use help [command] extended for detailed help on [command] "
     83                    ", even `help'\n\n", cmdname);
    8484        } else {
    8585                printf(
    86                 "\n  `%s' - shows help for commands\n"
    87                 "  Examples:\n"
    88                 "   %s [command]           Show help for [command]\n"
    89                 "   %s [command] extended  Show extended help for [command]\n"
    90                 "\n  If no argument is given to %s, a list of commands are shown\n\n",
    91                 cmdname, cmdname, cmdname, cmdname);
     86                    "\n  `%s' - shows help for commands\n"
     87                    "  Examples:\n"
     88                    "   %s [command]           Show help for [command]\n"
     89                    "   %s [command] extended  Show extended help for [command]\n"
     90                    "\n  If no argument is given to %s, a list of commands are shown\n\n",
     91                    cmdname, cmdname, cmdname, cmdname);
    9292        }
    9393
     
    105105        /* First, show a list of built in commands that are available in this mode */
    106106        for (cmd = builtins; cmd->name != NULL; cmd++) {
    107                         if (is_builtin_alias(cmd->name))
    108                                 printf("   %-16s\tAlias for `%s'\n", cmd->name,
    109                                         alias_for_builtin(cmd->name));
    110                         else
    111                                 printf("   %-16s\t%s\n", cmd->name, cmd->desc);
     107                if (is_builtin_alias(cmd->name))
     108                        printf("   %-16s\tAlias for `%s'\n", cmd->name,
     109                            alias_for_builtin(cmd->name));
     110                else
     111                        printf("   %-16s\t%s\n", cmd->name, cmd->desc);
    112112        }
    113113
    114114        /* Now, show a list of module commands that are available in this mode */
    115115        for (mod = modules; mod->name != NULL; mod++) {
    116                         if (is_module_alias(mod->name))
    117                                 printf("   %-16s\tAlias for `%s'\n", mod->name,
    118                                         alias_for_module(mod->name));
    119                         else
    120                                 printf("   %-16s\t%s\n", mod->name, mod->desc);
     116                if (is_module_alias(mod->name))
     117                        printf("   %-16s\tAlias for `%s'\n", mod->name,
     118                            alias_for_module(mod->name));
     119                else
     120                        printf("   %-16s\t%s\n", mod->name, mod->desc);
    121121        }
    122122
    123123        printf("\n  Try %s %s for more information on how `%s' works.\n\n",
    124                 cmdname, cmdname, cmdname);
     124            cmdname, cmdname, cmdname);
    125125}
    126126
  • uspace/app/bdsh/cmds/modules/ls/ls.c

    r47b2d7e3 r1433ecda  
    216216
    217217out:
    218         for(i = 0; i < nbdirs; i++)
     218        for (i = 0; i < nbdirs; i++)
    219219                free(tosort[i].name);
    220220        free(tosort);
     
    240240        struct dir_elem_t *dir_list;
    241241
    242         const char * const trailing_slash = "/";
     242        const char *const trailing_slash = "/";
    243243
    244244        nbdirs = 0;
     
    264264                if (str_size(subdir_path) + str_size(path) + 1 <= PATH_MAX)
    265265                        str_append(subdir_path, PATH_MAX, path);
    266                 if (path[str_size(path)-1] != '/' &&
     266                if (path[str_size(path) - 1] != '/' &&
    267267                    str_size(subdir_path) + str_size(trailing_slash) + 1 <= PATH_MAX)
    268268                        str_append(subdir_path, PATH_MAX, trailing_slash);
     
    328328                help_cmd_ls(HELP_SHORT);
    329329                printf(
    330                 "Usage:  %s [options] [path]\n"
    331                 "If not path is given, the current working directory is used.\n"
    332                 "Options:\n"
    333                 "  -h, --help       A short option summary\n"
    334                 "  -u, --unsort     Do not sort directory entries\n"
    335                 "  -r, --recursive  List subdirectories recursively\n",
    336                 cmdname);
     330                    "Usage:  %s [options] [path]\n"
     331                    "If not path is given, the current working directory is used.\n"
     332                    "Options:\n"
     333                    "  -h, --help       A short option summary\n"
     334                    "  -u, --unsort     Do not sort directory entries\n"
     335                    "  -r, --recursive  List subdirectories recursively\n",
     336                    cmdname);
    337337        }
    338338
  • uspace/app/bdsh/cmds/modules/mkfile/mkfile.c

    r47b2d7e3 r1433ecda  
    5353
    5454static struct option const long_options[] = {
    55         {"size", required_argument, 0, 's'},
    56         {"sparse", no_argument, 0, 'p'},
    57         {"help", no_argument, 0, 'h'},
    58         {0, 0, 0, 0}
     55        { "size", required_argument, 0, 's' },
     56        { "sparse", no_argument, 0, 'p' },
     57        { "help", no_argument, 0, 'h' },
     58        { 0, 0, 0, 0 }
    5959};
    6060
     
    6666                help_cmd_mkfile(HELP_SHORT);
    6767                printf(
    68                 "Usage:  %s [options] <path>\n"
    69                 "Options:\n"
    70                 "  -h, --help       A short option summary\n"
    71                 "  -s, --size sz    Size of the file\n"
    72                 "  -p, --sparse     Create a sparse file\n"
    73                 "\n"
    74                 "Size is a number followed by 'k', 'm' or 'g' for kB, MB, GB.\n"
    75                 "E.g. 100k, 2m, 1g.\n",
    76                 cmdname);
     68                    "Usage:  %s [options] <path>\n"
     69                    "Options:\n"
     70                    "  -h, --help       A short option summary\n"
     71                    "  -s, --size sz    Size of the file\n"
     72                    "  -p, --sparse     Create a sparse file\n"
     73                    "\n"
     74                    "Size is a number followed by 'k', 'm' or 'g' for kB, MB, GB.\n"
     75                    "E.g. 100k, 2m, 1g.\n",
     76                    cmdname);
    7777        }
    7878
     
    101101
    102102        if (ep[1] != '\0')
    103                     return EINVAL;
     103                return EINVAL;
    104104
    105105        switch (tolower(ep[0])) {
    106         case 'k': unit = 1024; break;
    107         case 'm': unit = 1024*1024; break;
    108         case 'g': unit = 1024*1024*1024; break;
    109         default: return EINVAL;
     106        case 'k':
     107                unit = 1024;
     108                break;
     109        case 'm':
     110                unit = 1024 * 1024;
     111                break;
     112        case 'g':
     113                unit = 1024 * 1024 * 1024;
     114                break;
     115        default:
     116                return EINVAL;
    110117        }
    111118
     
    162169        if (argc != 1) {
    163170                printf("%s: incorrect number of arguments. Try `%s --help'\n",
    164                         cmdname, cmdname);
     171                    cmdname, cmdname);
    165172                return CMD_FAILURE;
    166173        }
  • uspace/app/bdsh/cmds/modules/modules.h

    r47b2d7e3 r1433ecda  
    8787#include "cmp/cmp_def.inc"
    8888
    89         {NULL, NULL, NULL, NULL}
     89        { NULL, NULL, NULL, NULL }
    9090};
    9191
  • uspace/app/bdsh/cmds/modules/printf/printf.c

    r47b2d7e3 r1433ecda  
    6969 * @param arg string with data to print.
    7070 */
    71 static int print_arg(wchar_t ch, const char* arg)
     71static int print_arg(wchar_t ch, const char *arg)
    7272{
    73         switch(ch) {
     73        switch (ch) {
    7474        case 'd':
    7575                printf("%d", (int)(strtol(arg, NULL, 10)));
     
    9696static int process_ctl(wchar_t ch)
    9797{
    98         switch(ch) {
     98        switch (ch) {
    9999        case 'n':
    100100                printf("\n");
     
    120120{
    121121        unsigned int argc;
    122         char* fmt;
     122        char *fmt;
    123123        size_t pos, fmt_sz;
    124124        wchar_t ch;
     
    142142
    143143        while ((ch = str_decode(fmt, &pos, fmt_sz))) {
    144                 switch(ch) {
     144                switch (ch) {
    145145
    146146                case '\\':
  • uspace/app/bdsh/cmds/modules/pwd/pwd.c

    r47b2d7e3 r1433ecda  
    6161        if (vfs_cwd_get(buff, PATH_MAX) != EOK) {
    6262                cli_error(CL_EFAIL,
    63                         "Unable to determine the current working directory");
     63                    "Unable to determine the current working directory");
    6464                free(buff);
    6565                return CMD_FAILURE;
  • uspace/app/bdsh/cmds/modules/rm/rm.c

    r47b2d7e3 r1433ecda  
    175175        while ((dp = readdir(dirp))) {
    176176                int len = snprintf(buff, PATH_MAX - 1, "%s/%s", path, dp->d_name);
    177                 if (len > PATH_MAX-1) {
     177                if (len > PATH_MAX - 1) {
    178178                        // TODO: Do not enforce arbitrary static limits.
    179179                        cli_error(CL_EFAIL, "Path too long for %s/%s", path, dp->d_name);
     
    229229                help_cmd_rm(HELP_SHORT);
    230230                printf(
    231                 "Usage:  %s [options] <path>\n"
    232                 "Options:\n"
    233                 "  -h, --help       A short option summary\n"
    234                 "  -v, --version    Print version information and exit\n"
    235                 "  -r, --recursive  Recursively remove sub directories\n"
    236                 "  -f, --force      Do not prompt prior to removing files\n"
    237                 "  -s, --safe       Stop if directories change during removal\n\n"
    238                 "Currently, %s is under development, some options don't work.\n",
    239                 cmdname, cmdname);
     231                    "Usage:  %s [options] <path>\n"
     232                    "Options:\n"
     233                    "  -h, --help       A short option summary\n"
     234                    "  -v, --version    Print version information and exit\n"
     235                    "  -r, --recursive  Recursively remove sub directories\n"
     236                    "  -f, --force      Do not prompt prior to removing files\n"
     237                    "  -s, --safe       Stop if directories change during removal\n\n"
     238                    "Currently, %s is under development, some options don't work.\n",
     239                    cmdname, cmdname);
    240240        }
    241241        return;
     
    255255        if (argc < 2) {
    256256                cli_error(CL_EFAIL,
    257                         "%s: insufficient arguments. Try %s --help", cmdname, cmdname);
     257                    "%s: insufficient arguments. Try %s --help", cmdname, cmdname);
    258258                return CMD_FAILURE;
    259259        }
     
    293293        if ((unsigned) optind == argc) {
    294294                cli_error(CL_EFAIL,
    295                         "%s: insufficient arguments. Try %s --help", cmdname, cmdname);
     295                    "%s: insufficient arguments. Try %s --help", cmdname, cmdname);
    296296                rm_end(&rm);
    297297                return CMD_FAILURE;
     
    317317                        break;
    318318                case RM_DIR:
    319                         if (! rm.recursive) {
     319                        if (!rm.recursive) {
    320320                                printf("%s is a directory, use -r to remove it.\n", buff);
    321                                 ret ++;
     321                                ret++;
    322322                        } else {
    323323                                ret += rm_recursive(buff);
Note: See TracChangeset for help on using the changeset viewer.