Changeset 6514d1f in mainline
- Timestamp:
- 2012-03-24T20:01:34Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 30ac3c3
- Parents:
- a4419e7 (diff), 059a8e4 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/include/str.h
ra4419e7 r6514d1f 97 97 extern bool wstr_remove(wchar_t *str, size_t pos); 98 98 99 extern int str_uint64 (const char *, char **, unsigned int, bool, uint64_t *);99 extern int str_uint64_t(const char *, char **, unsigned int, bool, uint64_t *); 100 100 101 101 extern void order_suffix(const uint64_t, uint64_t *, char *); -
kernel/generic/src/console/cmd.c
ra4419e7 r6514d1f 906 906 ((char *) argv->buffer)[0] <= '9') { 907 907 uint64_t value; 908 rc = str_uint64 ((char *) argv->buffer, NULL, 0, true, &value);908 rc = str_uint64_t((char *) argv->buffer, NULL, 0, true, &value); 909 909 if (rc == EOK) 910 910 addr = (uintptr_t) value; -
kernel/generic/src/console/kconsole.c
ra4419e7 r6514d1f 472 472 /* It's a number - convert it */ 473 473 uint64_t value; 474 int rc = str_uint64 (text, NULL, 0, true, &value);474 int rc = str_uint64_t(text, NULL, 0, true, &value); 475 475 switch (rc) { 476 476 case EINVAL: -
kernel/generic/src/lib/str.c
ra4419e7 r6514d1f 893 893 * 894 894 */ 895 int str_uint64 (const char *nptr, char **endptr, unsigned int base,895 int str_uint64_t(const char *nptr, char **endptr, unsigned int base, 896 896 bool strict, uint64_t *result) 897 897 { -
kernel/generic/src/sysinfo/stats.c
ra4419e7 r6514d1f 474 474 /* Parse the task ID */ 475 475 task_id_t task_id; 476 if (str_uint64 (name, NULL, 0, true, &task_id) != EOK)476 if (str_uint64_t(name, NULL, 0, true, &task_id) != EOK) 477 477 return ret; 478 478 … … 545 545 /* Parse the thread ID */ 546 546 thread_id_t thread_id; 547 if (str_uint64 (name, NULL, 0, true, &thread_id) != EOK)547 if (str_uint64_t(name, NULL, 0, true, &thread_id) != EOK) 548 548 return ret; 549 549 … … 662 662 /* Parse the exception number */ 663 663 uint64_t excn; 664 if (str_uint64 (name, NULL, 0, true, &excn) != EOK)664 if (str_uint64_t(name, NULL, 0, true, &excn) != EOK) 665 665 return ret; 666 666 -
uspace/app/bdsh/cmds/modules/touch/entry.h
ra4419e7 r6514d1f 7 7 8 8 #endif /* TOUCH_ENTRY_H */ 9 -
uspace/app/bdsh/cmds/modules/touch/touch.c
ra4419e7 r6514d1f 27 27 */ 28 28 29 /* TODO: Options that people would expect, such as not creating the file if 30 * it doesn't exist, specifying the access time, etc */ 29 /* 30 * TODO: Options that people would expect, such as specifying the access time, 31 * etc. 32 */ 31 33 32 34 #include <stdio.h> … … 37 39 #include <sys/types.h> 38 40 #include <str.h> 41 #include <getopt.h> 42 #include <sys/stat.h> 43 #include <errno.h> 39 44 40 45 #include "config.h" … … 47 52 static const char *cmdname = "touch"; 48 53 54 static struct option const long_options[] = { 55 { "no-create", no_argument, 0, 'c' }, 56 { 0, 0, 0, 0 } 57 }; 58 49 59 /* Dispays help for touch in various levels */ 50 60 void help_cmd_touch(unsigned int level) 51 61 { 52 62 if (level == HELP_SHORT) { 53 printf("`%s' updates access times forfiles\n", cmdname);63 printf("`%s' updates access times of files\n", cmdname); 54 64 } else { 55 65 help_cmd_touch(HELP_SHORT); 56 printf(" `%s' <file>, if the file does not exist it will be " 57 "created\n", cmdname); 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); 58 72 } 59 73 60 74 return; 61 75 } … … 64 78 int cmd_touch(char **argv) 65 79 { 66 unsigned int argc, i = 0, ret = 0; 67 int fd; 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; 68 88 char *buff = NULL; 69 89 70 90 DIR *dirp; 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); 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); 77 104 return CMD_FAILURE; 78 105 } 79 80 for (i = 1; i < argc; i++) {106 107 for (i = optind; argv[i] != NULL; i++) { 81 108 buff = str_dup(argv[i]); 109 if (buff == NULL) { 110 cli_error(CL_ENOMEM, "Out of memory"); 111 ret++; 112 continue; 113 } 114 82 115 dirp = opendir(buff); 83 116 if (dirp) { 84 cli_error(CL_ENOTSUP, " %sis a directory", buff);117 cli_error(CL_ENOTSUP, "`%s' is a directory", buff); 85 118 closedir(dirp); 86 ret ++; 119 free(buff); 120 ret++; 87 121 continue; 88 122 } 89 90 fd = open(buff, O_RDWR | O_CREAT); 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 91 128 if (fd < 0) { 92 cli_error(CL_EFAIL, "Could not update / create %s ", buff); 93 ret ++; 129 cli_error(CL_EFAIL, "Could not update or create `%s'", buff); 130 free(buff); 131 ret++; 94 132 continue; 95 } else 133 } else { 96 134 close(fd); 97 135 fd = -1; 136 } 137 98 138 free(buff); 99 139 } 100 140 101 141 if (ret) 102 142 return CMD_FAILURE; … … 104 144 return CMD_SUCCESS; 105 145 } 106 -
uspace/app/bdsh/cmds/modules/touch/touch.h
ra4419e7 r6514d1f 4 4 /* Prototypes for the touch command, excluding entry points */ 5 5 6 7 6 #endif /* TOUCH_H */ 8 -
uspace/app/bdsh/cmds/modules/touch/touch_def.h
ra4419e7 r6514d1f 5 5 &help_cmd_touch, 6 6 }, 7 -
uspace/lib/c/generic/str.c
ra4419e7 r6514d1f 1535 1535 * 1536 1536 */ 1537 int str_uint64 (const char *nptr, char **endptr, unsigned int base,1537 int str_uint64_t(const char *nptr, char **endptr, unsigned int base, 1538 1538 bool strict, uint64_t *result) 1539 1539 { -
uspace/lib/c/include/str.h
ra4419e7 r6514d1f 106 106 extern int str_uint16_t(const char *, char **, unsigned int, bool, uint16_t *); 107 107 extern int str_uint32_t(const char *, char **, unsigned int, bool, uint32_t *); 108 extern int str_uint64 (const char *, char **, unsigned int, bool, uint64_t *);108 extern int str_uint64_t(const char *, char **, unsigned int, bool, uint64_t *); 109 109 extern int str_size_t(const char *, char **, unsigned int, bool, size_t *); 110 110 -
uspace/lib/usb/src/dev.c
ra4419e7 r6514d1f 122 122 char *ptr; 123 123 124 rc = str_uint64 (path, &ptr, 10, false, &sid);124 rc = str_uint64_t(path, &ptr, 10, false, &sid); 125 125 if (rc != EOK) { 126 126 return false;
Note:
See TracChangeset
for help on using the changeset viewer.