- Timestamp:
- 2012-05-24T15:30:53Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fa3704d
- Parents:
- 15b794d (diff), df3f85f (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. - Location:
- uspace
- Files:
-
- 17 added
- 45 edited
- 32 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/Makefile
r15b794d r8ad5470 42 42 app/getterm \ 43 43 app/init \ 44 app/inet cfg\44 app/inet \ 45 45 app/kill \ 46 46 app/killall \ 47 47 app/klog \ 48 app/loc info\48 app/loc \ 49 49 app/lsusb \ 50 50 app/mkfat \ … … 70 70 app/nettest3 \ 71 71 app/ping \ 72 app/websrv \73 72 app/sysinfo \ 74 73 app/mkbd \ 74 app/websrv \ 75 75 srv/clipboard \ 76 srv/loc \76 srv/locsrv \ 77 77 srv/devman \ 78 78 srv/loader \ 79 79 srv/net/ethip \ 80 srv/net/inet \80 srv/net/inetsrv \ 81 81 srv/net/loopip \ 82 82 srv/net/tcp \ … … 140 140 endif 141 141 142 ifeq ($(CONFIG_MSIM),y) 143 DIRS += \ 144 app/msim 145 endif 146 142 147 ## Platform-specific hardware support 143 148 # -
uspace/app/bdsh/Makefile
r15b794d r8ad5470 48 48 cmds/modules/cp/cp.c \ 49 49 cmds/modules/mv/mv.c \ 50 cmds/modules/printf/printf.c \ 51 cmds/modules/echo/echo.c \ 50 52 cmds/modules/mount/mount.c \ 51 53 cmds/modules/unmount/unmount.c \ -
uspace/app/bdsh/TODO
r15b794d r8ad5470 30 30 * Add wrappers for signal, sigaction to make ports to modules easier 31 31 32 * Add 'echo' and 'printf' modules.33 34 32 Regarding POSIX: 35 33 ---------------- -
uspace/app/bdsh/cmds/builtins/cd/cd.c
r15b794d r8ad5470 41 41 static const char *cmdname = "cd"; 42 42 43 /* Previous directory variables. 44 * 45 * Declaring them static to avoid many "== NULL" checks. 46 * PATH_MAX is not that big to cause any problems with memory overhead. 47 */ 48 static char previous_directory[PATH_MAX] = ""; 49 static char previous_directory_tmp[PATH_MAX]; 50 static bool previous_directory_valid = true; 51 static bool previous_directory_set = false; 52 53 static int chdir_and_remember(const char *new_dir) { 54 55 char *ok = getcwd(previous_directory_tmp, PATH_MAX); 56 previous_directory_valid = ok != NULL; 57 previous_directory_set = true; 58 59 int rc = chdir(new_dir); 60 if (rc != EOK) { 61 return rc; 62 } 63 64 str_cpy(previous_directory, PATH_MAX, previous_directory_tmp); 65 return EOK; 66 } 67 43 68 void help_cmd_cd(unsigned int level) 44 69 { … … 55 80 } 56 81 82 57 83 /* This is a very rudamentary 'cd' command. It is not 'link smart' (yet) */ 58 84 … … 62 88 63 89 argc = cli_count_args(argv); 90 91 /* Handle cd -- -. Override to switch to a directory named '-' */ 92 bool hyphen_override = false; 93 char *target_directory = argv[1]; 94 if (argc == 3) { 95 if (!str_cmp(argv[1], "--")) { 96 hyphen_override = true; 97 argc--; 98 target_directory = argv[2]; 99 } 100 } 64 101 65 102 /* We don't yet play nice with whitespace, a getopt implementation should … … 79 116 } 80 117 81 /* We have the correct # of arguments 82 *TODO: handle tidle (~) expansion? */118 /* We have the correct # of arguments */ 119 // TODO: handle tidle (~) expansion? */ 83 120 84 rc = chdir(argv[1]); 121 /* Handle 'cd -' first. */ 122 if (!str_cmp(target_directory, "-") && !hyphen_override) { 123 if (!previous_directory_valid) { 124 cli_error(CL_EFAIL, "Cannot switch to previous directory"); 125 return CMD_FAILURE; 126 } 127 if (!previous_directory_set) { 128 cli_error(CL_EFAIL, "No previous directory to switch to"); 129 return CMD_FAILURE; 130 } 131 char *prev_dup = str_dup(previous_directory); 132 if (prev_dup == NULL) { 133 cli_error(CL_ENOMEM, "Cannot switch to previous directory"); 134 return CMD_FAILURE; 135 } 136 rc = chdir_and_remember(prev_dup); 137 free(prev_dup); 138 } else { 139 rc = chdir_and_remember(target_directory); 140 } 85 141 86 142 if (rc == 0) { … … 93 149 break; 94 150 case ENOENT: 95 cli_error(CL_ENOENT, "Invalid directory `%s'", argv[1]);151 cli_error(CL_ENOENT, "Invalid directory `%s'", target_directory); 96 152 break; 97 153 default: 98 cli_error(CL_EFAIL, "Unable to change to `%s'", argv[1]);154 cli_error(CL_EFAIL, "Unable to change to `%s'", target_directory); 99 155 break; 100 156 } -
uspace/app/bdsh/cmds/modules/cat/cat.h
r15b794d r8ad5470 4 4 /* Prototypes for the cat command, excluding entry points */ 5 5 6 static unsigned int cat_file(const char *, size_t, bool, off64_t, off64_t, bool);7 8 6 #endif /* CAT_H */ 9 7 -
uspace/app/bdsh/cmds/modules/cp/cp.c
r15b794d r8ad5470 30 30 #include <stdlib.h> 31 31 #include <unistd.h> 32 #include <io/console.h> 33 #include <io/keycode.h> 32 34 #include <getopt.h> 33 35 #include <str.h> … … 46 48 47 49 static const char *cmdname = "cp"; 50 static console_ctrl_t *con; 48 51 49 52 static struct option const long_options[] = { 50 53 { "buffer", required_argument, 0, 'b' }, 51 54 { "force", no_argument, 0, 'f' }, 55 { "interactive", no_argument, 0, 'i'}, 52 56 { "recursive", no_argument, 0, 'r' }, 53 57 { "help", no_argument, 0, 'h' }, … … 139 143 } 140 144 145 static bool get_user_decision(bool bdefault, const char *message, ...) 146 { 147 va_list args; 148 149 va_start(args, message); 150 vprintf(message, args); 151 va_end(args); 152 153 while (true) { 154 kbd_event_t ev; 155 console_flush(con); 156 console_get_kbd_event(con, &ev); 157 if ((ev.type != KEY_PRESS) 158 || (ev.mods & (KM_CTRL | KM_ALT)) != 0) { 159 continue; 160 } 161 162 switch(ev.key) { 163 case KC_Y: 164 printf("y\n"); 165 return true; 166 case KC_N: 167 printf("n\n"); 168 return false; 169 case KC_ENTER: 170 printf("%c\n", bdefault ? 'Y' : 'N'); 171 return bdefault; 172 default: 173 break; 174 } 175 } 176 } 177 141 178 static int64_t do_copy(const char *src, const char *dest, 142 size_t blen, int vb, int recursive, int force )179 size_t blen, int vb, int recursive, int force, int interactive) 143 180 { 144 181 int r = -1; … … 192 229 /* e.g. cp file_name existing_file */ 193 230 194 /* dest already exists, if force is set we will 195 * try to remove it. 231 /* dest already exists, 232 * if force is set we will try to remove it. 233 * if interactive is set user input is required. 196 234 */ 197 if (force ) {235 if (force && !interactive) { 198 236 if (unlink(dest_path)) { 199 237 printf("Unable to remove %s\n", … … 201 239 goto exit; 202 240 } 241 } else if (!force && interactive) { 242 bool overwrite = get_user_decision(false, 243 "File already exists: %s. Overwrite? [y/N]: ", 244 dest_path); 245 if (overwrite) { 246 printf("Overwriting file: %s\n", dest_path); 247 if (unlink(dest_path)) { 248 printf("Unable to remove %s\n", dest_path); 249 goto exit; 250 } 251 } else { 252 printf("Not overwriting file: %s\n", dest_path); 253 r = 0; 254 goto exit; 255 } 203 256 } else { 204 printf(" file already exists: %s\n", dest_path);257 printf("File already exists: %s\n", dest_path); 205 258 goto exit; 206 259 } … … 302 355 /* Recursively call do_copy() */ 303 356 r = do_copy(src_dent, dest_dent, blen, vb, recursive, 304 force );357 force, interactive); 305 358 if (r) 306 359 goto exit; … … 315 368 return r; 316 369 } 317 318 370 319 371 static int64_t copy_file(const char *src, const char *dest, … … 380 432 " -v, --version Print version information and exit\n" 381 433 " -V, --verbose Be annoyingly noisy about what's being done\n" 382 " -f, --force Do not complain when <dest> exists\n" 434 " -f, --force Do not complain when <dest> exists (overrides a previous -i)\n" 435 " -i, --interactive Ask what to do when <dest> exists (overrides a previous -f)\n" 383 436 " -r, --recursive Copy entire directories\n" 384 437 " -b, --buffer ## Set the read buffer size to ##\n"; … … 397 450 unsigned int argc, verbose = 0; 398 451 int buffer = 0, recursive = 0; 399 int force = 0 ;452 int force = 0, interactive = 0; 400 453 int c, opt_ind; 401 454 int64_t ret; 402 455 456 con = console_init(stdin, stdout); 403 457 argc = cli_count_args(argv); 404 458 405 459 for (c = 0, optind = 0, opt_ind = 0; c != -1;) { 406 c = getopt_long(argc, argv, "hvVf rb:", long_options, &opt_ind);460 c = getopt_long(argc, argv, "hvVfirb:", long_options, &opt_ind); 407 461 switch (c) { 408 462 case 'h': … … 416 470 break; 417 471 case 'f': 472 interactive = 0; 418 473 force = 1; 474 break; 475 case 'i': 476 force = 0; 477 interactive = 1; 419 478 break; 420 479 case 'r': … … 426 485 "(should be a number greater than zero)\n", 427 486 cmdname); 487 console_done(con); 428 488 return CMD_FAILURE; 429 489 } … … 442 502 printf("%s: invalid number of arguments. Try %s --help\n", 443 503 cmdname, cmdname); 504 console_done(con); 444 505 return CMD_FAILURE; 445 506 } 446 507 447 508 ret = do_copy(argv[optind], argv[optind + 1], buffer, verbose, 448 recursive, force); 509 recursive, force, interactive); 510 511 console_done(con); 449 512 450 513 if (ret == 0) -
uspace/app/bdsh/cmds/modules/help/help.h
r15b794d r8ad5470 3 3 4 4 /* Prototypes for the help command (excluding entry points) */ 5 static int is_mod_or_builtin(char *);6 5 7 6 #endif -
uspace/app/bdsh/cmds/modules/mkdir/mkdir.c
r15b794d r8ad5470 36 36 #include <stdarg.h> 37 37 #include <str.h> 38 #include <errno.h> 39 #include <str_error.h> 40 #include <vfs/vfs.h> 38 41 39 42 #include "config.h" … … 83 86 /* This is kind of clunky, but effective for now */ 84 87 static unsigned int 85 create_directory(const char * path, unsigned int p)88 create_directory(const char *user_path, bool create_parents) 86 89 { 87 DIR *dirp; 88 char *tmp = NULL, *buff = NULL, *wdp = NULL; 89 char *dirs[255]; 90 unsigned int absolute = 0, i = 0, ret = 0; 91 92 /* Its a good idea to allocate path, plus we (may) need a copy of 93 * path to tokenize if parents are specified */ 94 if (NULL == (tmp = str_dup(path))) { 90 /* Ensure we would always work with absolute and canonified path. */ 91 char *path = absolutize(user_path, NULL); 92 if (path == NULL) { 95 93 cli_error(CL_ENOMEM, "%s: path too big?", cmdname); 96 94 return 1; 97 95 } 98 96 99 if (NULL == (wdp = (char *) malloc(PATH_MAX))) { 100 cli_error(CL_ENOMEM, "%s: could not alloc cwd", cmdname); 101 free(tmp); 102 return 1; 103 } 104 105 /* The only reason for wdp is to be (optionally) verbose */ 106 getcwd(wdp, PATH_MAX); 107 108 /* Typical use without specifying the creation of parents */ 109 if (p == 0) { 110 dirp = opendir(tmp); 111 if (dirp) { 112 cli_error(CL_EEXISTS, "%s: can not create %s, try -p", cmdname, path); 113 closedir(dirp); 114 goto finit; 115 } 116 if (-1 == (mkdir(tmp, 0))) { 117 cli_error(CL_EFAIL, "%s: could not create %s", cmdname, path); 118 goto finit; 119 } 120 } 121 122 /* Parents need to be created, path has to be broken up */ 123 124 /* See if path[0] is a slash, if so we have to remember to append it */ 125 if (tmp[0] == '/') 126 absolute = 1; 127 128 /* TODO: Canonify the path prior to tokenizing it, see below */ 129 dirs[i] = strtok(tmp, "/"); 130 while (dirs[i] && i < 255) 131 dirs[++i] = strtok(NULL, "/"); 132 133 if (NULL == dirs[0]) 134 return 1; 135 136 if (absolute == 1) { 137 asprintf(&buff, "/%s", dirs[0]); 138 mkdir(buff, 0); 139 chdir(buff); 140 free(buff); 141 getcwd(wdp, PATH_MAX); 142 i = 1; 97 int rc; 98 int ret = 0; 99 100 if (!create_parents) { 101 rc = mkdir(path, 0); 102 if (rc != EOK) { 103 cli_error(CL_EFAIL, "%s: could not create %s (%s)", 104 cmdname, path, str_error(rc)); 105 ret = 1; 106 } 143 107 } else { 144 i = 0; 145 } 146 147 while (dirs[i] != NULL) { 148 /* Sometimes make or scripts conjoin odd paths. Account for something 149 * like this: ../../foo/bar/../foo/foofoo/./bar */ 150 if (!str_cmp(dirs[i], "..") || !str_cmp(dirs[i], ".")) { 151 if (0 != (chdir(dirs[i]))) { 152 cli_error(CL_EFAIL, "%s: impossible path: %s", 153 cmdname, path); 154 ret ++; 155 goto finit; 156 } 157 getcwd(wdp, PATH_MAX); 158 } else { 159 if (-1 == (mkdir(dirs[i], 0))) { 160 cli_error(CL_EFAIL, 161 "%s: failed at %s/%s", wdp, dirs[i]); 162 ret ++; 163 goto finit; 164 } 165 if (0 != (chdir(dirs[i]))) { 166 cli_error(CL_EFAIL, "%s: failed creating %s\n", 167 cmdname, dirs[i]); 168 ret ++; 108 /* Create the parent directories as well. */ 109 size_t off = 0; 110 while (1) { 111 size_t prev_off = off; 112 wchar_t cur_char = str_decode(path, &off, STR_NO_LIMIT); 113 if ((cur_char == 0) || (cur_char == U_SPECIAL)) { 169 114 break; 170 115 } 171 } 172 i++; 173 } 174 goto finit; 175 176 finit: 177 free(wdp); 178 free(tmp); 116 if (cur_char != '/') { 117 continue; 118 } 119 if (prev_off == 0) { 120 continue; 121 } 122 /* 123 * If we are here, it means that: 124 * - we found / 125 * - it is not the first / (no need to create root 126 * directory) 127 * 128 * We would now overwrite the / with 0 to terminate the 129 * string (that shall be okay because we are 130 * overwriting at the beginning of UTF sequence). 131 * That would allow us to create the directories 132 * in correct nesting order. 133 * 134 * Notice that we ignore EEXIST errors as some of 135 * the parent directories may already exist. 136 */ 137 char slash_char = path[prev_off]; 138 path[prev_off] = 0; 139 rc = mkdir(path, 0); 140 if (rc == EEXIST) { 141 rc = EOK; 142 } 143 144 if (rc != EOK) { 145 cli_error(CL_EFAIL, "%s: could not create %s (%s)", 146 cmdname, path, str_error(rc)); 147 ret = 1; 148 goto leave; 149 } 150 151 path[prev_off] = slash_char; 152 } 153 /* Create the final directory. */ 154 rc = mkdir(path, 0); 155 if (rc != EOK) { 156 cli_error(CL_EFAIL, "%s: could not create %s (%s)", 157 cmdname, path, str_error(rc)); 158 ret = 1; 159 } 160 } 161 162 leave: 163 free(path); 179 164 return ret; 180 165 } … … 182 167 int cmd_mkdir(char **argv) 183 168 { 184 unsigned int argc, create_parents = 0, i, ret = 0, follow= 0;185 unsigned int verbose = 0;169 unsigned int argc, i, ret = 0; 170 bool create_parents = false, follow = false, verbose = false; 186 171 int c, opt_ind; 187 char *cwd;188 172 189 173 argc = cli_count_args(argv); … … 193 177 switch (c) { 194 178 case 'p': 195 create_parents = 1;179 create_parents = true; 196 180 break; 197 181 case 'v': 198 verbose = 1;182 verbose = true; 199 183 break; 200 184 case 'h': … … 205 189 return CMD_SUCCESS; 206 190 case 'f': 207 follow = 1;191 follow = true; 208 192 break; 209 193 case 'm': … … 221 205 } 222 206 223 if (NULL == (cwd = (char *) malloc(PATH_MAX))) {224 cli_error(CL_ENOMEM, "%s: could not allocate cwd", cmdname);225 return CMD_FAILURE;226 }227 228 memset(cwd, 0, sizeof(cwd));229 getcwd(cwd, PATH_MAX);230 231 207 for (i = optind; argv[i] != NULL; i++) { 232 if (verbose == 1)208 if (verbose) 233 209 printf("%s: creating %s%s\n", 234 210 cmdname, argv[i], … … 237 213 } 238 214 239 if (follow == 0) 240 chdir(cwd); 241 242 free(cwd); 215 if (follow && (argv[optind] != NULL)) { 216 chdir(argv[optind]); 217 } 243 218 244 219 if (ret) -
uspace/app/bdsh/cmds/modules/mkdir/mkdir.h
r15b794d r8ad5470 4 4 /* Prototypes for the mkdir command, excluding entry points */ 5 5 6 static unsigned int create_directory(const char *, unsigned int);7 6 #endif /* MKDIR_H */ 8 7 -
uspace/app/bdsh/cmds/modules/modules.h
r15b794d r8ad5470 61 61 #include "unmount/entry.h" 62 62 #include "kcon/entry.h" 63 #include "printf/entry.h" 64 #include "echo/entry.h" 63 65 64 66 /* Each .def function fills the module_t struct with the individual name, entry … … 82 84 #include "unmount/unmount_def.h" 83 85 #include "kcon/kcon_def.h" 86 #include "printf/printf_def.h" 87 #include "echo/echo_def.h" 84 88 85 89 {NULL, NULL, NULL, NULL} -
uspace/app/bdsh/cmds/modules/rm/rm.c
r15b794d r8ad5470 46 46 #define RM_VERSION "0.0.1" 47 47 48 static rm_job_t rm;49 50 48 static struct option const long_options[] = { 51 49 { "help", no_argument, 0, 'h' }, … … 57 55 }; 58 56 57 /* Return values for rm_scope() */ 58 #define RM_BOGUS 0 59 #define RM_FILE 1 60 #define RM_DIR 2 61 62 /* Flags for rm_update() */ 63 #define _RM_ENTRY 0 64 #define _RM_ADVANCE 1 65 #define _RM_REWIND 2 66 #define _RM_EXIT 3 67 68 /* A simple job structure */ 69 typedef struct { 70 /* Options set at run time */ 71 unsigned int force; /* -f option */ 72 unsigned int recursive; /* -r option */ 73 unsigned int safe; /* -s option */ 74 75 /* Keeps track of the job in progress */ 76 int advance; /* How far deep we've gone since entering */ 77 DIR *entry; /* Entry point to the tree being removed */ 78 char *owd; /* Where we were when we invoked rm */ 79 char *cwd; /* Current directory being transversed */ 80 char *nwd; /* Next directory to be transversed */ 81 82 /* Counters */ 83 int f_removed; /* Number of files unlinked */ 84 int d_removed; /* Number of directories unlinked */ 85 } rm_job_t; 86 87 static rm_job_t rm; 88 89 static unsigned int rm_recursive(const char *); 90 59 91 static unsigned int rm_start(rm_job_t *rm) 60 92 { … … 95 127 if (NULL != rm->cwd) 96 128 free(rm->cwd); 129 } 130 131 static unsigned int rm_single(const char *path) 132 { 133 if (unlink(path)) { 134 cli_error(CL_EFAIL, "rm: could not remove file %s", path); 135 return 1; 136 } 137 return 0; 138 } 139 140 static unsigned int rm_scope(const char *path) 141 { 142 int fd; 143 DIR *dirp; 144 145 dirp = opendir(path); 146 if (dirp) { 147 closedir(dirp); 148 return RM_DIR; 149 } 150 151 fd = open(path, O_RDONLY); 152 if (fd > 0) { 153 close(fd); 154 return RM_FILE; 155 } 156 157 return RM_BOGUS; 97 158 } 98 159 … … 154 215 155 216 return ret + 1; 156 }157 158 static unsigned int rm_single(const char *path)159 {160 if (unlink(path)) {161 cli_error(CL_EFAIL, "rm: could not remove file %s", path);162 return 1;163 }164 return 0;165 }166 167 static unsigned int rm_scope(const char *path)168 {169 int fd;170 DIR *dirp;171 172 dirp = opendir(path);173 if (dirp) {174 closedir(dirp);175 return RM_DIR;176 }177 178 fd = open(path, O_RDONLY);179 if (fd > 0) {180 close(fd);181 return RM_FILE;182 }183 184 return RM_BOGUS;185 217 } 186 218 -
uspace/app/bdsh/cmds/modules/rm/rm.h
r15b794d r8ad5470 2 2 #define RM_H 3 3 4 /* Return values for rm_scope() */5 #define RM_BOGUS 06 #define RM_FILE 17 #define RM_DIR 28 9 /* Flags for rm_update() */10 #define _RM_ENTRY 011 #define _RM_ADVANCE 112 #define _RM_REWIND 213 #define _RM_EXIT 314 15 /* A simple job structure */16 typedef struct {17 /* Options set at run time */18 unsigned int force; /* -f option */19 unsigned int recursive; /* -r option */20 unsigned int safe; /* -s option */21 22 /* Keeps track of the job in progress */23 int advance; /* How far deep we've gone since entering */24 DIR *entry; /* Entry point to the tree being removed */25 char *owd; /* Where we were when we invoked rm */26 char *cwd; /* Current directory being transversed */27 char *nwd; /* Next directory to be transversed */28 29 /* Counters */30 int f_removed; /* Number of files unlinked */31 int d_removed; /* Number of directories unlinked */32 } rm_job_t;33 34 35 4 /* Prototypes for the rm command, excluding entry points */ 36 static unsigned int rm_start(rm_job_t *);37 static void rm_end(rm_job_t *rm);38 static unsigned int rm_recursive(const char *);39 static unsigned int rm_single(const char *);40 static unsigned int rm_scope(const char *);41 5 42 6 #endif /* RM_H */ -
uspace/app/bdsh/cmds/modules/sleep/sleep.c
r15b794d r8ad5470 27 27 */ 28 28 29 #include <errno.h> 29 30 #include <stdio.h> 30 31 #include <stdlib.h> 32 #include <unistd.h> 31 33 #include "config.h" 32 34 #include "util.h" … … 41 43 void help_cmd_sleep(unsigned int level) 42 44 { 43 printf("This is the %s help for '%s'.\n", 44 level ? EXT_HELP : SHORT_HELP, cmdname); 45 if (level == HELP_SHORT) { 46 printf("`%s' pauses for a given time interval\n", cmdname); 47 } else { 48 help_cmd_sleep(HELP_SHORT); 49 printf( 50 "Usage: %s <duration>\n" 51 "The duration is a decimal number of seconds.\n", 52 cmdname); 53 } 54 45 55 return; 56 } 57 58 /** Convert string containing decimal seconds to useconds_t. 59 * 60 * @param nptr Pointer to string. 61 * @param result Result of the conversion. 62 * @return EOK if conversion was successful. 63 */ 64 static int decimal_to_useconds(const char *nptr, useconds_t *result) 65 { 66 int ret; 67 uint64_t whole_seconds; 68 uint64_t frac_seconds; 69 char *endptr; 70 71 /* Check for whole seconds */ 72 if (*nptr == '.') { 73 whole_seconds = 0; 74 endptr = (char *)nptr; 75 } else { 76 ret = str_uint64_t(nptr, &endptr, 10, false, &whole_seconds); 77 if (ret != EOK) 78 return ret; 79 } 80 81 /* Check for fractional seconds */ 82 if (*endptr == '\0') { 83 frac_seconds = 0; 84 } else if (*endptr == '.' && endptr[1] == '\0') { 85 frac_seconds = 0; 86 } else if (*endptr == '.') { 87 nptr = endptr + 1; 88 ret = str_uint64_t(nptr, &endptr, 10, true, &frac_seconds); 89 if (ret != EOK) 90 return ret; 91 92 int ndigits = endptr - nptr; 93 for (; ndigits < 6; ndigits++) 94 frac_seconds *= 10; 95 for (; ndigits > 6; ndigits--) 96 frac_seconds /= 10; 97 } else { 98 return EINVAL; 99 } 100 101 /* Check for overflow */ 102 useconds_t total = whole_seconds * 1000000 + frac_seconds; 103 if (total / 1000000 != whole_seconds) 104 return EOVERFLOW; 105 106 *result = total; 107 108 return EOK; 46 109 } 47 110 … … 49 112 int cmd_sleep(char **argv) 50 113 { 114 int ret; 51 115 unsigned int argc; 52 u nsigned int i;116 useconds_t duration; 53 117 54 118 /* Count the arguments */ 55 for (argc = 0; argv[argc] != NULL; argc ++);119 argc = cli_count_args(argv); 56 120 57 printf("%s %s\n", TEST_ANNOUNCE, cmdname); 58 printf("%d arguments passed to %s", argc - 1, cmdname); 59 60 if (argc < 2) { 61 printf("\n"); 62 return CMD_SUCCESS; 121 if (argc != 2) { 122 printf("%s - incorrect number of arguments. Try `help %s'\n", 123 cmdname, cmdname); 124 return CMD_FAILURE; 63 125 } 64 126 65 printf(":\n"); 66 for (i = 1; i < argc; i++) 67 printf("[%d] -> %s\n", i, argv[i]); 127 ret = decimal_to_useconds(argv[1], &duration); 128 if (ret != EOK) { 129 printf("%s - invalid duration.\n", cmdname); 130 return CMD_FAILURE; 131 } 132 133 (void) usleep(duration); 68 134 69 135 return CMD_SUCCESS; -
uspace/app/edit/edit.c
r15b794d r8ad5470 118 118 static void key_handle_ctrl(kbd_event_t const *ev); 119 119 static void key_handle_shift(kbd_event_t const *ev); 120 static void key_handle_shift_ctrl(kbd_event_t const *ev); 120 121 static void key_handle_movement(unsigned int key, bool shift); 121 122 … … 139 140 static void caret_update(void); 140 141 static void caret_move(int drow, int dcolumn, enum dir_spec align_dir); 142 static void caret_move_word_left(void); 143 static void caret_move_word_right(void); 141 144 142 145 static bool selection_active(void); 143 146 static void selection_sel_all(void); 147 static void selection_sel_range(spt_t pa, spt_t pb); 148 static void selection_sel_prev_word(void); 149 static void selection_sel_next_word(void); 144 150 static void selection_get_points(spt_t *pa, spt_t *pb); 145 151 static void selection_delete(void); … … 149 155 static void pt_get_sof(spt_t *pt); 150 156 static void pt_get_eof(spt_t *pt); 157 static void pt_get_sol(spt_t *cpt, spt_t *spt); 158 static void pt_get_eol(spt_t *cpt, spt_t *ept); 159 static bool pt_is_word_beginning(spt_t *pt); 160 static bool pt_is_delimiter(spt_t *pt); 161 static bool pt_is_punctuation(spt_t *pt); 151 162 static int tag_cmp(tag_t const *a, tag_t const *b); 152 163 static int spt_cmp(spt_t const *a, spt_t const *b); … … 232 243 (ev.mods & KM_SHIFT) != 0) { 233 244 key_handle_shift(&ev); 245 } else if (((ev.mods & KM_ALT) == 0) && 246 ((ev.mods & KM_CTRL) != 0) && 247 (ev.mods & KM_SHIFT) != 0) { 248 key_handle_shift_ctrl(&ev); 234 249 } else if ((ev.mods & (KM_CTRL | KM_ALT | KM_SHIFT)) == 0) { 235 250 key_handle_unmod(&ev); … … 376 391 case KC_A: 377 392 selection_sel_all(); 393 break; 394 case KC_W: 395 if (selection_active()) 396 break; 397 selection_sel_prev_word(); 398 selection_delete(); 399 break; 400 case KC_RIGHT: 401 caret_move_word_right(); 402 break; 403 case KC_LEFT: 404 caret_move_word_left(); 405 break; 406 default: 407 break; 408 } 409 } 410 411 static void key_handle_shift_ctrl(kbd_event_t const *ev) 412 { 413 switch(ev->key) { 414 case KC_LEFT: 415 selection_sel_prev_word(); 416 break; 417 case KC_RIGHT: 418 selection_sel_next_word(); 378 419 break; 379 420 default: … … 970 1011 /* Clamp coordinates. */ 971 1012 if (drow < 0 && coord.row < 1) coord.row = 1; 972 if (dcolumn < 0 && coord.column < 1) coord.column = 1; 1013 if (dcolumn < 0 && coord.column < 1) { 1014 if (coord.row < 2) 1015 coord.column = 1; 1016 else { 1017 coord.row--; 1018 sheet_get_row_width(&doc.sh, coord.row, &coord.column); 1019 } 1020 } 973 1021 if (drow > 0) { 974 1022 sheet_get_num_rows(&doc.sh, &num_rows); … … 998 1046 } 999 1047 1048 static void caret_move_word_left(void) 1049 { 1050 spt_t pt; 1051 1052 do { 1053 caret_move(0, -1, dir_before); 1054 1055 tag_get_pt(&pane.caret_pos, &pt); 1056 1057 sheet_remove_tag(&doc.sh, &pane.sel_start); 1058 sheet_place_tag(&doc.sh, &pt, &pane.sel_start); 1059 } while (!pt_is_word_beginning(&pt)); 1060 1061 pane.rflags |= REDRAW_TEXT; 1062 } 1063 1064 static void caret_move_word_right(void) 1065 { 1066 spt_t pt; 1067 1068 do { 1069 caret_move(0, 0, dir_after); 1070 1071 tag_get_pt(&pane.caret_pos, &pt); 1072 1073 sheet_remove_tag(&doc.sh, &pane.sel_start); 1074 sheet_place_tag(&doc.sh, &pt, &pane.sel_start); 1075 } while (!pt_is_word_beginning(&pt)); 1076 1077 pane.rflags |= REDRAW_TEXT; 1078 } 1079 1000 1080 /** Check for non-empty selection. */ 1001 1081 static bool selection_active(void) … … 1045 1125 } 1046 1126 1127 /** Select all text in the editor */ 1047 1128 static void selection_sel_all(void) 1048 1129 { … … 1051 1132 pt_get_sof(&spt); 1052 1133 pt_get_eof(&ept); 1134 1135 selection_sel_range(spt, ept); 1136 } 1137 1138 /** Select select all text in a given range with the given direction */ 1139 static void selection_sel_range(spt_t pa, spt_t pb) 1140 { 1053 1141 sheet_remove_tag(&doc.sh, &pane.sel_start); 1054 sheet_place_tag(&doc.sh, & spt, &pane.sel_start);1142 sheet_place_tag(&doc.sh, &pa, &pane.sel_start); 1055 1143 sheet_remove_tag(&doc.sh, &pane.caret_pos); 1056 sheet_place_tag(&doc.sh, & ept, &pane.caret_pos);1144 sheet_place_tag(&doc.sh, &pb, &pane.caret_pos); 1057 1145 1058 1146 pane.rflags |= REDRAW_TEXT; 1059 1147 caret_update(); 1148 } 1149 1150 /** Add the previous word to the selection */ 1151 static void selection_sel_prev_word(void) 1152 { 1153 spt_t cpt, wpt, spt, ept; 1154 1155 selection_get_points(&spt, &ept); 1156 1157 tag_get_pt(&pane.caret_pos, &cpt); 1158 caret_move_word_left(); 1159 tag_get_pt(&pane.caret_pos, &wpt); 1160 1161 if (spt_cmp(&spt, &cpt) == 0) 1162 selection_sel_range(ept, wpt); 1163 else 1164 selection_sel_range(spt, wpt); 1165 } 1166 1167 /** Add the next word to the selection */ 1168 static void selection_sel_next_word(void) 1169 { 1170 spt_t cpt, wpt, spt, ept; 1171 1172 selection_get_points(&spt, &ept); 1173 1174 tag_get_pt(&pane.caret_pos, &cpt); 1175 caret_move_word_right(); 1176 tag_get_pt(&pane.caret_pos, &wpt); 1177 1178 if (spt_cmp(&ept, &cpt) == 0) 1179 selection_sel_range(spt, wpt); 1180 else 1181 selection_sel_range(ept, wpt); 1060 1182 } 1061 1183 … … 1117 1239 1118 1240 sheet_get_cell_pt(&doc.sh, &coord, dir_after, pt); 1241 } 1242 1243 /** Get start-of-line s-point for given s-point cpt */ 1244 static void pt_get_sol(spt_t *cpt, spt_t *spt) 1245 { 1246 coord_t coord; 1247 1248 spt_get_coord(cpt, &coord); 1249 coord.column = 1; 1250 1251 sheet_get_cell_pt(&doc.sh, &coord, dir_before, spt); 1252 } 1253 1254 /** Get end-of-line s-point for given s-point cpt */ 1255 static void pt_get_eol(spt_t *cpt, spt_t *ept) 1256 { 1257 coord_t coord; 1258 int row_width; 1259 1260 spt_get_coord(cpt, &coord); 1261 sheet_get_row_width(&doc.sh, coord.row, &row_width); 1262 coord.column = row_width - 1; 1263 1264 sheet_get_cell_pt(&doc.sh, &coord, dir_after, ept); 1265 } 1266 1267 /** Check whether the spt is at a beginning of a word */ 1268 static bool pt_is_word_beginning(spt_t *pt) 1269 { 1270 spt_t lp, sfp, efp, slp, elp; 1271 coord_t coord; 1272 1273 pt_get_sof(&sfp); 1274 pt_get_eof(&efp); 1275 pt_get_sol(pt, &slp); 1276 pt_get_eol(pt, &elp); 1277 1278 /* the spt is at the beginning or end of the file or line */ 1279 if ((spt_cmp(&sfp, pt) == 0) || (spt_cmp(&efp, pt) == 0) 1280 || (spt_cmp(&slp, pt) == 0) || (spt_cmp(&elp, pt) == 0)) 1281 return true; 1282 1283 /* the spt is a delimiter */ 1284 if (pt_is_delimiter(pt)) 1285 return false; 1286 1287 spt_get_coord(pt, &coord); 1288 1289 coord.column -= 1; 1290 sheet_get_cell_pt(&doc.sh, &coord, dir_before, &lp); 1291 1292 return pt_is_delimiter(&lp) 1293 || (pt_is_punctuation(pt) && !pt_is_punctuation(&lp)) 1294 || (pt_is_punctuation(&lp) && !pt_is_punctuation(pt)); 1295 } 1296 1297 static wchar_t get_first_wchar(const char *str) 1298 { 1299 size_t offset = 0; 1300 return str_decode(str, &offset, str_size(str)); 1301 } 1302 1303 static bool pt_is_delimiter(spt_t *pt) 1304 { 1305 spt_t rp; 1306 coord_t coord; 1307 char *ch = NULL; 1308 1309 spt_get_coord(pt, &coord); 1310 1311 coord.column += 1; 1312 sheet_get_cell_pt(&doc.sh, &coord, dir_after, &rp); 1313 1314 ch = range_get_str(pt, &rp); 1315 if (ch == NULL) 1316 return false; 1317 1318 wchar_t first_char = get_first_wchar(ch); 1319 switch(first_char) { 1320 case ' ': 1321 case '\t': 1322 case '\n': 1323 return true; 1324 default: 1325 return false; 1326 } 1327 } 1328 1329 static bool pt_is_punctuation(spt_t *pt) 1330 { 1331 spt_t rp; 1332 coord_t coord; 1333 char *ch = NULL; 1334 1335 spt_get_coord(pt, &coord); 1336 1337 coord.column += 1; 1338 sheet_get_cell_pt(&doc.sh, &coord, dir_after, &rp); 1339 1340 ch = range_get_str(pt, &rp); 1341 if (ch == NULL) 1342 return false; 1343 1344 wchar_t first_char = get_first_wchar(ch); 1345 switch(first_char) { 1346 case ',': 1347 case '.': 1348 case ';': 1349 case ':': 1350 case '/': 1351 case '?': 1352 case '\\': 1353 case '|': 1354 case '_': 1355 case '+': 1356 case '-': 1357 case '*': 1358 case '=': 1359 case '<': 1360 case '>': 1361 return true; 1362 default: 1363 return false; 1364 } 1119 1365 } 1120 1366 -
uspace/app/edit/sheet.c
r15b794d r8ad5470 264 264 sheet_get_cell_pt(sh, &coord, dir_before, &pt); 265 265 spt_get_coord(&pt, &coord); 266 *length = coord.column - 1;266 *length = coord.column; 267 267 } 268 268 -
uspace/app/inet/Makefile
r15b794d r8ad5470 28 28 29 29 USPACE_PREFIX = ../.. 30 BINARY = inet cfg30 BINARY = inet 31 31 32 32 SOURCES = \ 33 inet cfg.c33 inet.c 34 34 35 35 include $(USPACE_PREFIX)/Makefile.common -
uspace/app/inet/inet.c
r15b794d r8ad5470 27 27 */ 28 28 29 /** @addtogroup inet cfg29 /** @addtogroup inet 30 30 * @{ 31 31 */ … … 43 43 #include <sys/types.h> 44 44 45 #define NAME "inet cfg"45 #define NAME "inet" 46 46 47 47 static void print_syntax(void) … … 187 187 rc = inetcfg_addr_create_static(aobj_name, &naddr, link_id, &addr_id); 188 188 if (rc != EOK) { 189 printf(NAME ": Failed creating static address '%s' (% d)\n",190 aobj_name, rc);189 printf(NAME ": Failed creating static address '%s' (%s)\n", 190 aobj_name, str_error(rc)); 191 191 return EIO; 192 192 } … … 345 345 346 346 printf("Configured addresses:\n"); 347 347 if (count > 0) 348 printf(" [Addr/Width] [Link-Name] [Addr-Name] [Def-MTU]\n"); 348 349 ainfo.name = linfo.name = astr = NULL; 349 350 … … 415 416 416 417 printf("Static routes:\n"); 418 if (count > 0) 419 printf(" [Dest/Width] [Router-Addr] [Route-Name]\n"); 417 420 418 421 srinfo.name = dest_str = router_str = NULL; -
uspace/app/init/init.c
r15b794d r8ad5470 307 307 spawn("/srv/loopip"); 308 308 spawn("/srv/ethip"); 309 spawn("/srv/inet ");309 spawn("/srv/inetsrv"); 310 310 spawn("/srv/tcp"); 311 311 spawn("/srv/udp"); -
uspace/app/killall/killall.c
r15b794d r8ad5470 36 36 #include <errno.h> 37 37 #include <stdio.h> 38 #include <unistd.h> 38 39 #include <task.h> 39 40 #include <stats.h> -
uspace/app/loc/Makefile
r15b794d r8ad5470 28 28 29 29 USPACE_PREFIX = ../.. 30 EXTRA_CFLAGS = -Iinclude 31 BINARY = locinfo 30 BINARY = loc 32 31 33 32 SOURCES = \ 34 loc info.c33 loc.c 35 34 36 35 include $(USPACE_PREFIX)/Makefile.common -
uspace/app/loc/loc.c
r15b794d r8ad5470 27 27 */ 28 28 29 /** @addtogroup loc info29 /** @addtogroup loc 30 30 * @{ 31 31 */ 32 /** @file loc info.c Print information from location service.32 /** @file loc.c Print information from location service. 33 33 */ 34 34 … … 41 41 #include <sys/typefmt.h> 42 42 43 #define NAME "loc info"43 #define NAME "loc" 44 44 45 int main(int argc, char *argv[]) 45 static int show_cat(const char *cat_name, category_id_t cat_id) 46 { 47 service_id_t *svc_ids; 48 size_t svc_cnt; 49 char *svc_name; 50 int rc; 51 size_t j; 52 53 printf("%s (%" PRIun "):\n", cat_name, cat_id); 54 55 rc = loc_category_get_svcs(cat_id, &svc_ids, &svc_cnt); 56 if (rc != EOK) { 57 printf(NAME ": Failed getting list of services in " 58 "category %s, skipping.\n", cat_name); 59 return rc; 60 } 61 62 for (j = 0; j < svc_cnt; j++) { 63 rc = loc_service_get_name(svc_ids[j], &svc_name); 64 if (rc != EOK) { 65 printf(NAME ": Unknown service name (SID %" 66 PRIun ").\n", svc_ids[j]); 67 continue; 68 } 69 printf("\t%s (%" PRIun ")\n", svc_name, svc_ids[j]); 70 free(svc_name); 71 } 72 73 free(svc_ids); 74 return EOK; 75 } 76 77 static int list_svcs_by_cat(void) 46 78 { 47 79 category_id_t *cat_ids; 48 80 size_t cat_cnt; 49 service_id_t *svc_ids;50 size_t svc_cnt;51 81 52 size_t i , j;82 size_t i; 53 83 char *cat_name; 54 char *svc_name;55 84 int rc; 56 85 … … 58 87 if (rc != EOK) { 59 88 printf(NAME ": Error getting list of categories.\n"); 60 return 1;89 return rc; 61 90 } 62 91 … … 68 97 if (cat_name == NULL) { 69 98 printf(NAME ": Error allocating memory.\n"); 70 return 1; 99 free(cat_ids); 100 return rc; 71 101 } 72 102 73 printf("%s (%" PRIun "):\n", cat_name, cat_ids[i]); 103 rc = show_cat(cat_name, cat_ids[i]); 104 (void) rc; 74 105 75 rc = loc_category_get_svcs(cat_ids[i], &svc_ids, &svc_cnt);76 if (rc != EOK) {77 printf(NAME ": Failed getting list of services in "78 "category %s, skipping.\n", cat_name);79 free(cat_name);80 continue;81 }82 83 for (j = 0; j < svc_cnt; j++) {84 rc = loc_service_get_name(svc_ids[j], &svc_name);85 if (rc != EOK) {86 printf(NAME ": Unknown service name (SID %"87 PRIun ").\n", svc_ids[j]);88 continue;89 }90 printf("\t%s (%" PRIun ")\n", svc_name, svc_ids[j]);91 free(svc_name);92 }93 94 free(svc_ids);95 106 free(cat_name); 96 107 } 97 108 98 109 free(cat_ids); 110 return EOK; 111 } 112 113 static void print_syntax(void) 114 { 115 printf("syntax:\n" 116 "\t" NAME " List categories and services " 117 "they contain\n" 118 "\t" NAME " show-cat <category> List services in category\n"); 119 } 120 121 int main(int argc, char *argv[]) 122 { 123 int rc; 124 char *cmd; 125 char *cat_name; 126 category_id_t cat_id; 127 128 if (argc <= 1) { 129 rc = list_svcs_by_cat(); 130 if (rc != EOK) 131 return 1; 132 return 0; 133 } 134 135 cmd = argv[1]; 136 if (str_cmp(cmd, "show-cat") == 0) { 137 if (argc < 3) { 138 printf("Argument missing.\n"); 139 print_syntax(); 140 return 1; 141 } 142 143 cat_name = argv[2]; 144 rc = loc_category_get_id(cat_name, &cat_id, 0); 145 if (rc != EOK) { 146 printf("Error looking up category '%s'.\n", cat_name); 147 return 1; 148 } 149 150 rc = show_cat(cat_name, cat_id); 151 if (rc != EOK) 152 return 1; 153 } else { 154 printf("Invalid command '%s'\n", cmd); 155 print_syntax(); 156 return 1; 157 } 158 99 159 return 0; 100 160 } -
uspace/app/nettest1/nettest1.c
r15b794d r8ad5470 40 40 #include <malloc.h> 41 41 #include <stdio.h> 42 #include <unistd.h> 42 43 #include <str.h> 43 44 #include <task.h> -
uspace/app/nettest2/nettest2.c
r15b794d r8ad5470 40 40 #include <malloc.h> 41 41 #include <stdio.h> 42 #include <unistd.h> 42 43 #include <str.h> 43 44 #include <task.h> -
uspace/app/sbi/src/mytypes.h
r15b794d r8ad5470 51 51 /** Error return codes. */ 52 52 #include <errno.h> 53 /** We need NULL defined. */ 54 #include <unistd.h> 53 55 #define EOK 0 54 56 -
uspace/app/sbi/src/stype.c
r15b794d r8ad5470 652 652 assert(iface_ti->tic == tic_tobject); 653 653 iface = iface_ti->u.tobject->csi; 654 assert(iface->cc = csi_interface);654 assert(iface->cc == csi_interface); 655 655 656 656 #ifdef DEBUG_TYPE_TRACE -
uspace/app/sysinfo/sysinfo.c
r15b794d r8ad5470 36 36 #include <errno.h> 37 37 #include <stdio.h> 38 #include <unistd.h> 38 39 #include <sysinfo.h> 39 40 #include <malloc.h> -
uspace/app/websrv/websrv.c
r15b794d r8ad5470 1 1 /* 2 * Copyright (c) 201 1Jiri Svoboda2 * Copyright (c) 2012 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 36 36 #include <bool.h> 37 37 #include <errno.h> 38 #include <assert.h> 38 39 #include <stdio.h> 39 40 #include <sys/types.h> … … 41 42 #include <stdlib.h> 42 43 #include <fcntl.h> 44 #include <task.h> 43 45 44 46 #include <net/in.h> … … 71 73 72 74 static char fbuf[BUFFER_SIZE]; 75 76 static bool verbose = false; 73 77 74 78 /** Responses to send to client. */ … … 187 191 size_t response_size = str_size(msg); 188 192 189 fprintf(stderr, "Sending response\n"); 193 if (verbose) 194 fprintf(stderr, "Sending response\n"); 195 190 196 ssize_t rc = send(conn_sd, (void *) msg, response_size, 0); 191 197 if (rc < 0) { … … 251 257 } 252 258 253 fprintf(stderr, "Request: %s", lbuf); 259 if (verbose) 260 fprintf(stderr, "Request: %s", lbuf); 254 261 255 262 if (str_lcmp(lbuf, "GET ", 4) != 0) { … … 266 273 267 274 *end_uri = '\0'; 268 fprintf(stderr, "Requested URI: %s\n", uri); 275 if (verbose) 276 fprintf(stderr, "Requested URI: %s\n", uri); 269 277 270 278 if (!uri_is_valid(uri)) { … … 287 295 "\n" 288 296 "-h | --help\n" 289 "\tShow this application help.\n"); 297 "\tShow this application help.\n" 298 "-v | --verbose\n" 299 "\tVerbose mode\n"); 290 300 } 291 301 … … 306 316 307 317 port = (uint16_t) value; 318 break; 319 case 'v': 320 verbose = true; 308 321 break; 309 322 /* Long options with double dash */ … … 318 331 319 332 port = (uint16_t) value; 333 } else if (str_cmp(argv[*index] +2, "verbose") == 0) { 334 verbose = true; 320 335 } else { 321 336 usage(); … … 358 373 } 359 374 360 fprintf(stderr, "Creating socket\n"); 375 printf("%s: HelenOS web server\n", NAME); 376 377 if (verbose) 378 fprintf(stderr, "Creating socket\n"); 361 379 362 380 int listen_sd = socket(PF_INET, SOCK_STREAM, 0); … … 380 398 } 381 399 382 fprintf(stderr, "Listening for connections at port %" PRIu16 "\n", 383 port); 400 fprintf(stderr, "%s: Listening for connections at port %" PRIu16 "\n", 401 NAME, port); 402 403 task_retval(0); 404 384 405 while (true) { 385 406 struct sockaddr_in raddr; … … 393 414 } 394 415 395 fprintf(stderr, "Connection accepted (sd=%d), " 396 "waiting for request\n", conn_sd); 416 if (verbose) { 417 fprintf(stderr, "Connection accepted (sd=%d), " 418 "waiting for request\n", conn_sd); 419 } 397 420 398 421 rbuf_out = 0; … … 412 435 } 413 436 414 fprintf(stderr, "Connection closed\n"); 437 if (verbose) 438 fprintf(stderr, "Connection closed\n"); 415 439 } 416 440 -
uspace/drv/bus/usb/ohci/utils/malloc32.h
r15b794d r8ad5470 37 37 #include <assert.h> 38 38 #include <malloc.h> 39 #include <unistd.h> 39 40 #include <errno.h> 40 41 #include <mem.h> -
uspace/drv/bus/usb/uhci/utils/malloc32.h
r15b794d r8ad5470 36 36 37 37 #include <assert.h> 38 #include <unistd.h> 38 39 #include <errno.h> 39 40 #include <malloc.h> -
uspace/lib/c/generic/stacktrace.c
r15b794d r8ad5470 38 38 #include <sys/types.h> 39 39 #include <errno.h> 40 #include <unistd.h> 40 41 41 42 static int stacktrace_read_uintptr(void *arg, uintptr_t addr, uintptr_t *data); -
uspace/lib/c/generic/stats.c
r15b794d r8ad5470 40 40 #include <inttypes.h> 41 41 #include <malloc.h> 42 #include <unistd.h> 42 43 43 44 #define SYSINFO_STATS_MAX_PATH 64 -
uspace/lib/c/generic/sysinfo.c
r15b794d r8ad5470 39 39 #include <malloc.h> 40 40 #include <bool.h> 41 #include <unistd.h> 41 42 42 43 /** Get sysinfo keys size -
uspace/lib/c/generic/time.c
r15b794d r8ad5470 43 43 #include <ddi.h> 44 44 #include <libc.h> 45 #include <unistd.h> 45 46 46 47 /** Pointer to kernel shared variables with time */ -
uspace/lib/c/include/errno.h
r15b794d r8ad5470 37 37 38 38 #include <abi/errno.h> 39 #include <fibril.h>40 39 41 40 #define errno (*(__errno())) -
uspace/lib/c/include/stdarg.h
r15b794d r8ad5470 43 43 #define va_arg(ap, type) __builtin_va_arg(ap, type) 44 44 #define va_end(ap) __builtin_va_end(ap) 45 #define va_copy(dst, src) __builtin_va_copy(dst, src) 45 46 46 47 #endif -
uspace/lib/c/include/stdio.h
r15b794d r8ad5470 39 39 #include <stdarg.h> 40 40 #include <str.h> 41 #include <adt/list.h>42 41 43 42 #ifndef NVERIFY_PRINTF -
uspace/lib/c/include/unistd.h
r15b794d r8ad5470 58 58 #define getpagesize() (PAGE_SIZE) 59 59 60 extern int dup2(int oldfd, int newfd);60 extern int dup2(int, int); 61 61 62 62 extern ssize_t write(int, const void *, size_t); … … 73 73 extern int unlink(const char *); 74 74 75 extern char *getcwd(char * buf, size_t);75 extern char *getcwd(char *, size_t); 76 76 extern int rmdir(const char *); 77 77 extern int chdir(const char *); -
uspace/lib/clui/tinput.h
r15b794d r8ad5470 37 37 #define LIBCLUI_TINPUT_H_ 38 38 39 #include <adt/list.h>40 #include <async.h>41 39 #include <inttypes.h> 42 40 #include <io/console.h> -
uspace/lib/drv/generic/logbuf.c
r15b794d r8ad5470 35 35 #include <ddf/log.h> 36 36 #include <assert.h> 37 #include <unistd.h> 37 38 38 39 /** Formatting string for printing number of not-printed items. */ -
uspace/lib/drv/include/ddf/interrupt.h
r15b794d r8ad5470 36 36 #define DDF_INTERRUPT_H_ 37 37 38 #include <libarch/common.h> 39 #include <libarch/types.h> 38 40 #include <abi/ddi/irq.h> 39 41 #include <adt/list.h> -
uspace/lib/posix/Makefile
r15b794d r8ad5470 43 43 fcntl.c \ 44 44 fnmatch.c \ 45 getopt.c \ 45 46 locale.c \ 46 47 math.c \ -
uspace/lib/posix/errno.h
r15b794d r8ad5470 66 66 #undef errno 67 67 #define errno (*__posix_errno()) 68 69 #include "unistd.h" 68 70 69 71 extern int *__posix_errno(void); -
uspace/lib/posix/pwd.c
r15b794d r8ad5470 38 38 #include "string.h" 39 39 #include "errno.h" 40 #include "assert.h" 40 41 41 42 static bool entry_read = false; -
uspace/lib/posix/stdbool.h
r15b794d r8ad5470 37 37 38 38 #ifdef LIBC_BOOL_H_ 39 #error "You can't include bool.h and stdbool.h at the same time." 39 #if (!defined(POSIX_STDIO_H_)) \ 40 && (!defined(POSIX_STDLIB_H_)) \ 41 && (!defined(POSIX_STRING_H_)) 42 #error "You can't include bool.h and stdbool.h at the same time." 40 43 #endif 44 #endif 45 41 46 #define LIBC_BOOL_H_ 42 47 -
uspace/lib/posix/stdio.h
r15b794d r8ad5470 37 37 #define POSIX_STDIO_H_ 38 38 39 #include "stddef.h" 40 #include "unistd.h" 39 41 #include "libc/stdio.h" 40 42 #include "sys/types.h" -
uspace/lib/posix/time.c
r15b794d r8ad5470 45 45 #include "errno.h" 46 46 #include "signal.h" 47 #include "assert.h" 47 48 48 49 #include "libc/malloc.h" -
uspace/lib/posix/unistd.c
r15b794d r8ad5470 49 49 /* Array of environment variable strings (NAME=VALUE). */ 50 50 char **posix_environ = NULL; 51 char *posix_optarg; 51 52 52 53 /** -
uspace/lib/posix/unistd.h
r15b794d r8ad5470 43 43 #define _exit exit 44 44 45 /* Option Arguments */ 46 extern char *optarg; 45 extern char *posix_optarg; 47 46 extern int optind, opterr, optopt; 48 extern int getopt(int, char * const [], const char *);47 extern int posix_getopt(int, char * const [], const char *); 49 48 50 49 /* Environment */ … … 144 143 145 144 #ifndef LIBPOSIX_INTERNAL 145 #define getopt posix_getopt 146 #define optarg posix_optarg 147 146 148 #define environ posix_environ 147 149 -
uspace/srv/fs/fat/fat_dentry.c
r15b794d r8ad5470 43 43 #include <byteorder.h> 44 44 #include <assert.h> 45 #include <unistd.h> 45 46 46 47 /** Compare path component with the name read from the dentry. -
uspace/srv/locsrv/Makefile
r15b794d r8ad5470 29 29 30 30 USPACE_PREFIX = ../.. 31 BINARY = loc 31 BINARY = locsrv 32 32 STATIC_NEEDED = y 33 33 34 34 SOURCES = \ 35 35 category.c \ 36 loc .c36 locsrv.c 37 37 38 38 include $(USPACE_PREFIX)/Makefile.common -
uspace/srv/locsrv/category.c
r15b794d r8ad5470 40 40 41 41 #include "category.h" 42 #include "loc .h"42 #include "locsrv.h" 43 43 44 44 /** Initialize category directory. */ -
uspace/srv/locsrv/category.h
r15b794d r8ad5470 37 37 38 38 #include <adt/list.h> 39 #include "loc .h"39 #include "locsrv.h" 40 40 41 41 typedef sysarg_t catid_t; -
uspace/srv/locsrv/locsrv.c
r15b794d r8ad5470 51 51 52 52 #include "category.h" 53 #include "loc .h"53 #include "locsrv.h" 54 54 55 55 #define NAME "loc" -
uspace/srv/locsrv/locsrv.h
r15b794d r8ad5470 33 33 */ 34 34 35 #ifndef LOC _H_36 #define LOC _H_35 #ifndef LOCSRV_H_ 36 #define LOCSRV_H_ 37 37 38 38 #include <ipc/loc.h> -
uspace/srv/net/inetsrv/Makefile
r15b794d r8ad5470 28 28 29 29 USPACE_PREFIX = ../../.. 30 BINARY = inet 30 BINARY = inetsrv 31 31 32 32 SOURCES = \ 33 33 addrobj.c \ 34 34 icmp.c \ 35 inet .c \35 inetsrv.c \ 36 36 inet_link.c \ 37 37 inet_util.c \ -
uspace/srv/net/inetsrv/addrobj.c
r15b794d r8ad5470 44 44 45 45 #include "addrobj.h" 46 #include "inet .h"46 #include "inetsrv.h" 47 47 #include "inet_link.h" 48 48 #include "inet_util.h" 49 50 static inet_addrobj_t *inet_addrobj_find_by_name_locked(const char *, inet_link_t *); 49 51 50 52 static FIBRIL_MUTEX_INITIALIZE(addr_list_lock); … … 77 79 } 78 80 79 void inet_addrobj_add(inet_addrobj_t *addr) 80 { 81 fibril_mutex_lock(&addr_list_lock); 81 int inet_addrobj_add(inet_addrobj_t *addr) 82 { 83 inet_addrobj_t *aobj; 84 85 fibril_mutex_lock(&addr_list_lock); 86 aobj = inet_addrobj_find_by_name_locked(addr->name, addr->ilink); 87 if (aobj != NULL) { 88 /* Duplicate address name */ 89 fibril_mutex_unlock(&addr_list_lock); 90 return EEXISTS; 91 } 92 82 93 list_append(&addr->addr_list, &addr_list); 83 94 fibril_mutex_unlock(&addr_list_lock); 95 96 return EOK; 84 97 } 85 98 … … 130 143 * @return Address object 131 144 */ 132 inet_addrobj_t *inet_addrobj_find_by_name(const char *name, inet_link_t *ilink) 133 { 134 log_msg(LVL_DEBUG, "inet_addrobj_find_by_name('%s', '%s')", 145 static inet_addrobj_t *inet_addrobj_find_by_name_locked(const char *name, inet_link_t *ilink) 146 { 147 assert(fibril_mutex_is_locked(&addr_list_lock)); 148 149 log_msg(LVL_DEBUG, "inet_addrobj_find_by_name_locked('%s', '%s')", 135 150 name, ilink->svc_name); 136 151 137 fibril_mutex_lock(&addr_list_lock);138 139 152 list_foreach(addr_list, link) { 140 153 inet_addrobj_t *naddr = list_get_instance(link, … … 142 155 143 156 if (naddr->ilink == ilink && str_cmp(naddr->name, name) == 0) { 144 fibril_mutex_unlock(&addr_list_lock); 145 log_msg(LVL_DEBUG, "inet_addrobj_find_by_name: found %p", 157 log_msg(LVL_DEBUG, "inet_addrobj_find_by_name_locked: found %p", 146 158 naddr); 147 159 return naddr; … … 149 161 } 150 162 151 log_msg(LVL_DEBUG, "inet_addrobj_find_by_name: Not found"); 152 fibril_mutex_unlock(&addr_list_lock); 163 log_msg(LVL_DEBUG, "inet_addrobj_find_by_name_locked: Not found"); 153 164 154 165 return NULL; 166 } 167 168 169 /** Find address object on a link, with a specific name. 170 * 171 * @param name Address object name 172 * @param ilink Inet link 173 * @return Address object 174 */ 175 inet_addrobj_t *inet_addrobj_find_by_name(const char *name, inet_link_t *ilink) 176 { 177 inet_addrobj_t *aobj; 178 179 log_msg(LVL_DEBUG, "inet_addrobj_find_by_name('%s', '%s')", 180 name, ilink->svc_name); 181 182 fibril_mutex_lock(&addr_list_lock); 183 aobj = inet_addrobj_find_by_name_locked(name, ilink); 184 fibril_mutex_unlock(&addr_list_lock); 185 186 return aobj; 155 187 } 156 188 -
uspace/srv/net/inetsrv/addrobj.h
r15b794d r8ad5470 39 39 40 40 #include <sys/types.h> 41 #include "inet .h"41 #include "inetsrv.h" 42 42 43 43 typedef enum { … … 50 50 extern inet_addrobj_t *inet_addrobj_new(void); 51 51 extern void inet_addrobj_delete(inet_addrobj_t *); 52 extern voidinet_addrobj_add(inet_addrobj_t *);52 extern int inet_addrobj_add(inet_addrobj_t *); 53 53 extern void inet_addrobj_remove(inet_addrobj_t *); 54 54 extern inet_addrobj_t *inet_addrobj_find(inet_addr_t *, inet_addrobj_find_t); -
uspace/srv/net/inetsrv/icmp.c
r15b794d r8ad5470 43 43 #include "icmp.h" 44 44 #include "icmp_std.h" 45 #include "inet .h"45 #include "inetsrv.h" 46 46 #include "inetping.h" 47 47 #include "pdu.h" -
uspace/srv/net/inetsrv/icmp.h
r15b794d r8ad5470 38 38 #define ICMP_H_ 39 39 40 #include "inet .h"40 #include "inetsrv.h" 41 41 42 42 extern int icmp_recv(inet_dgram_t *); -
uspace/srv/net/inetsrv/inet_link.c
r15b794d r8ad5470 45 45 46 46 #include "addrobj.h" 47 #include "inet .h"47 #include "inetsrv.h" 48 48 #include "inet_link.h" 49 49 #include "pdu.h" … … 207 207 addr->ilink = ilink; 208 208 addr->name = str_dup("v4a"); 209 inet_addrobj_add(addr); 209 rc = inet_addrobj_add(addr); 210 if (rc != EOK) { 211 log_msg(LVL_ERROR, "Failed setting IP address on internet link."); 212 inet_addrobj_delete(addr); 213 /* XXX Roll back */ 214 return rc; 215 } 210 216 211 217 iaddr.ipv4 = addr->naddr.ipv4; … … 213 219 if (rc != EOK) { 214 220 log_msg(LVL_ERROR, "Failed setting IP address on internet link."); 221 inet_addrobj_remove(addr); 222 inet_addrobj_delete(addr); 215 223 /* XXX Roll back */ 216 224 return rc; -
uspace/srv/net/inetsrv/inet_link.h
r15b794d r8ad5470 39 39 40 40 #include <sys/types.h> 41 #include "inet .h"41 #include "inetsrv.h" 42 42 43 43 extern int inet_link_discovery_start(void); -
uspace/srv/net/inetsrv/inetcfg.c
r15b794d r8ad5470 46 46 47 47 #include "addrobj.h" 48 #include "inet .h"48 #include "inetsrv.h" 49 49 #include "inet_link.h" 50 50 #include "inetcfg.h" … … 75 75 addr->ilink = ilink; 76 76 addr->name = str_dup(name); 77 inet_addrobj_add(addr); 77 rc = inet_addrobj_add(addr); 78 if (rc != EOK) { 79 log_msg(LVL_DEBUG, "Duplicate address name '%s'.", addr->name); 80 inet_addrobj_delete(addr); 81 return rc; 82 } 78 83 79 84 iaddr.ipv4 = addr->naddr.ipv4; -
uspace/srv/net/inetsrv/inetping.c
r15b794d r8ad5470 46 46 #include "icmp.h" 47 47 #include "icmp_std.h" 48 #include "inet .h"48 #include "inetsrv.h" 49 49 #include "inetping.h" 50 50 -
uspace/srv/net/inetsrv/inetsrv.c
r15b794d r8ad5470 50 50 #include "icmp.h" 51 51 #include "icmp_std.h" 52 #include "inet .h"52 #include "inetsrv.h" 53 53 #include "inetcfg.h" 54 54 #include "inetping.h" … … 57 57 #include "sroute.h" 58 58 59 #define NAME "inet "59 #define NAME "inetsrv" 60 60 61 61 static void inet_client_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg); -
uspace/srv/net/inetsrv/inetsrv.h
r15b794d r8ad5470 27 27 */ 28 28 29 /** @addtogroup inet 29 /** @addtogroup inetsrv 30 30 * @{ 31 31 */ … … 35 35 */ 36 36 37 #ifndef INET _H_38 #define INET _H_37 #ifndef INETSRV_H_ 38 #define INETSRV_H_ 39 39 40 40 #include <adt/list.h> -
uspace/srv/net/inetsrv/pdu.c
r15b794d r8ad5470 45 45 #include <stdlib.h> 46 46 47 #include "inet .h"47 #include "inetsrv.h" 48 48 #include "inet_std.h" 49 49 #include "pdu.h" -
uspace/srv/net/inetsrv/pdu.h
r15b794d r8ad5470 39 39 40 40 #include <sys/types.h> 41 #include "inet .h"41 #include "inetsrv.h" 42 42 43 43 #define INET_CHECKSUM_INIT 0xffff -
uspace/srv/net/inetsrv/reass.c
r15b794d r8ad5470 42 42 #include <stdlib.h> 43 43 44 #include "inet .h"44 #include "inetsrv.h" 45 45 #include "inet_std.h" 46 46 #include "reass.h" -
uspace/srv/net/inetsrv/reass.h
r15b794d r8ad5470 39 39 40 40 #include <sys/types.h> 41 #include "inet .h"41 #include "inetsrv.h" 42 42 43 43 extern int inet_reass_queue_packet(inet_packet_t *); -
uspace/srv/net/inetsrv/sroute.c
r15b794d r8ad5470 44 44 45 45 #include "sroute.h" 46 #include "inet .h"46 #include "inetsrv.h" 47 47 #include "inet_link.h" 48 48 #include "inet_util.h" -
uspace/srv/net/inetsrv/sroute.h
r15b794d r8ad5470 39 39 40 40 #include <sys/types.h> 41 #include "inet .h"41 #include "inetsrv.h" 42 42 43 43 extern inet_sroute_t *inet_sroute_new(void);
Note:
See TracChangeset
for help on using the changeset viewer.