Changes in / [6514d1f:a4419e7] in mainline


Ignore:
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/str.h

    r6514d1f ra4419e7  
    9797extern bool wstr_remove(wchar_t *str, size_t pos);
    9898
    99 extern int str_uint64_t(const char *, char **, unsigned int, bool, uint64_t *);
     99extern int str_uint64(const char *, char **, unsigned int, bool, uint64_t *);
    100100
    101101extern void order_suffix(const uint64_t, uint64_t *, char *);
  • kernel/generic/src/console/cmd.c

    r6514d1f ra4419e7  
    906906                   ((char *) argv->buffer)[0] <= '9') {
    907907                uint64_t value;
    908                 rc = str_uint64_t((char *) argv->buffer, NULL, 0, true, &value);
     908                rc = str_uint64((char *) argv->buffer, NULL, 0, true, &value);
    909909                if (rc == EOK)
    910910                        addr = (uintptr_t) value;
  • kernel/generic/src/console/kconsole.c

    r6514d1f ra4419e7  
    472472                /* It's a number - convert it */
    473473                uint64_t value;
    474                 int rc = str_uint64_t(text, NULL, 0, true, &value);
     474                int rc = str_uint64(text, NULL, 0, true, &value);
    475475                switch (rc) {
    476476                case EINVAL:
  • kernel/generic/src/lib/str.c

    r6514d1f ra4419e7  
    893893 *
    894894 */
    895 int str_uint64_t(const char *nptr, char **endptr, unsigned int base,
     895int str_uint64(const char *nptr, char **endptr, unsigned int base,
    896896    bool strict, uint64_t *result)
    897897{
  • kernel/generic/src/sysinfo/stats.c

    r6514d1f ra4419e7  
    474474        /* Parse the task ID */
    475475        task_id_t task_id;
    476         if (str_uint64_t(name, NULL, 0, true, &task_id) != EOK)
     476        if (str_uint64(name, NULL, 0, true, &task_id) != EOK)
    477477                return ret;
    478478       
     
    545545        /* Parse the thread ID */
    546546        thread_id_t thread_id;
    547         if (str_uint64_t(name, NULL, 0, true, &thread_id) != EOK)
     547        if (str_uint64(name, NULL, 0, true, &thread_id) != EOK)
    548548                return ret;
    549549       
     
    662662        /* Parse the exception number */
    663663        uint64_t excn;
    664         if (str_uint64_t(name, NULL, 0, true, &excn) != EOK)
     664        if (str_uint64(name, NULL, 0, true, &excn) != EOK)
    665665                return ret;
    666666       
  • uspace/app/bdsh/cmds/modules/touch/entry.h

    r6514d1f ra4419e7  
    77
    88#endif /* TOUCH_ENTRY_H */
     9
  • uspace/app/bdsh/cmds/modules/touch/touch.c

    r6514d1f ra4419e7  
    2727 */
    2828
    29 /*
    30  * TODO: Options that people would expect, such as specifying the access time,
    31  * etc.
    32  */
     29/* TODO: Options that people would expect, such as not creating the file if
     30 * it doesn't exist, specifying the access time, etc */
    3331
    3432#include <stdio.h>
     
    3937#include <sys/types.h>
    4038#include <str.h>
    41 #include <getopt.h>
    42 #include <sys/stat.h>
    43 #include <errno.h>
    4439
    4540#include "config.h"
     
    5247static const char *cmdname = "touch";
    5348
    54 static struct option const long_options[] = {
    55         { "no-create", no_argument, 0, 'c' },
    56         { 0, 0, 0, 0 }
    57 };
    58 
    5949/* Dispays help for touch in various levels */
    6050void help_cmd_touch(unsigned int level)
    6151{
    6252        if (level == HELP_SHORT) {
    63                 printf("`%s' updates access times of files\n", cmdname);
     53                printf("`%s' updates access times for files\n", cmdname);
    6454        } else {
    6555                help_cmd_touch(HELP_SHORT);
    66                 printf("Usage: `%s' [-c|--no-create] <file>...\n\n"
    67                     "If the file does not exist it will be created empty,\n"
    68                     "unless -c (--no-create) is supplied.\n\n"
    69                     "Options:\n"
    70                     "   -c, --no-create  Do not create new files\n",
    71                     cmdname);
     56                printf("  `%s' <file>, if the file does not exist it will be "
     57                                "created\n", cmdname);
    7258        }
    73        
     59
    7460        return;
    7561}
     
    7864int cmd_touch(char **argv)
    7965{
    80         unsigned int argc = cli_count_args(argv);
    81         unsigned int i = 0;
    82         unsigned int ret = 0;
    83         int c;
    84         int longind;
    85         bool no_create = false;
    86         struct stat file_stat;
    87         int fd = -1;
     66        unsigned int argc, i = 0, ret = 0;
     67        int fd;
    8868        char *buff = NULL;
    89        
     69
    9070        DIR *dirp;
    91        
    92         for (c = 0, optind = 0, longind = 0; c != -1; ) {
    93                 c = getopt_long(argc, argv, "c", long_options, &longind);
    94                 switch (c) {
    95                 case 'c':
    96                         no_create = true;
    97                         break;
    98                 }
    99         }
    100        
    101         if (argc - optind < 1) {
    102                 printf("%s: Incorrect number of arguments. Try `help %s extended'\n",
    103                     cmdname, cmdname);
     71
     72        argc = cli_count_args(argv);
     73
     74        if (argc == 1) {
     75                printf("%s - incorrect number of arguments. Try `help %s extended'\n",
     76                        cmdname, cmdname);
    10477                return CMD_FAILURE;
    10578        }
    106        
    107         for (i = optind; argv[i] != NULL; i++) {
     79
     80        for (i = 1; i < argc; i ++) {
    10881                buff = str_dup(argv[i]);
    109                 if (buff == NULL) {
    110                         cli_error(CL_ENOMEM, "Out of memory");
    111                         ret++;
     82                dirp = opendir(buff);
     83                if (dirp) {
     84                        cli_error(CL_ENOTSUP, "%s is a directory", buff);
     85                        closedir(dirp);
     86                        ret ++;
    11287                        continue;
    11388                }
    114                
    115                 dirp = opendir(buff);
    116                 if (dirp) {
    117                         cli_error(CL_ENOTSUP, "`%s' is a directory", buff);
    118                         closedir(dirp);
    119                         free(buff);
    120                         ret++;
     89
     90                fd = open(buff, O_RDWR | O_CREAT);
     91                if (fd < 0) {
     92                        cli_error(CL_EFAIL, "Could not update / create %s ", buff);
     93                        ret ++;
    12194                        continue;
    122                 }
    123                
    124                 /* Check whether file exists if -c (--no-create) option is given */
    125                 if ((!no_create) || ((no_create) && (stat(buff, &file_stat) == EOK)))
    126                         fd = open(buff, O_RDWR | O_CREAT);
    127                
    128                 if (fd < 0) {
    129                         cli_error(CL_EFAIL, "Could not update or create `%s'", buff);
    130                         free(buff);
    131                         ret++;
    132                         continue;
    133                 } else {
     95                } else
    13496                        close(fd);
    135                         fd = -1;
    136                 }
    137                
     97
    13898                free(buff);
    13999        }
    140        
     100
    141101        if (ret)
    142102                return CMD_FAILURE;
     
    144104                return CMD_SUCCESS;
    145105}
     106
  • uspace/app/bdsh/cmds/modules/touch/touch.h

    r6514d1f ra4419e7  
    44/* Prototypes for the touch command, excluding entry points */
    55
     6
    67#endif /* TOUCH_H */
     8
  • uspace/app/bdsh/cmds/modules/touch/touch_def.h

    r6514d1f ra4419e7  
    55        &help_cmd_touch,
    66},
     7
  • uspace/lib/c/generic/str.c

    r6514d1f ra4419e7  
    15351535 *
    15361536 */
    1537 int str_uint64_t(const char *nptr, char **endptr, unsigned int base,
     1537int str_uint64(const char *nptr, char **endptr, unsigned int base,
    15381538    bool strict, uint64_t *result)
    15391539{
  • uspace/lib/c/include/str.h

    r6514d1f ra4419e7  
    106106extern int str_uint16_t(const char *, char **, unsigned int, bool, uint16_t *);
    107107extern int str_uint32_t(const char *, char **, unsigned int, bool, uint32_t *);
    108 extern int str_uint64_t(const char *, char **, unsigned int, bool, uint64_t *);
     108extern int str_uint64(const char *, char **, unsigned int, bool, uint64_t *);
    109109extern int str_size_t(const char *, char **, unsigned int, bool, size_t *);
    110110
  • uspace/lib/usb/src/dev.c

    r6514d1f ra4419e7  
    122122        char *ptr;
    123123
    124         rc = str_uint64_t(path, &ptr, 10, false, &sid);
     124        rc = str_uint64(path, &ptr, 10, false, &sid);
    125125        if (rc != EOK) {
    126126                return false;
Note: See TracChangeset for help on using the changeset viewer.