Changeset 4cc0c9ee in mainline
- Timestamp:
- 2009-01-22T14:22:12Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- bf226890
- Parents:
- fc11b8a
- Location:
- uspace/app/bdsh
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/AUTHORS
rfc11b8a r4cc0c9ee 9 9 * Based on the HelenOS testing sub-system written by Martin Decky 10 10 11 * cli_strtok() and cli_strtok_r() (util.c) were adapted from the FreeBSD12 strtok() and strtok_r() functions written by Wes Peters.13 14 11 * read_line() (input.c) was written by Jiri Svoboda 15 12 -
uspace/app/bdsh/cmds/modules/mkdir/mkdir.c
rfc11b8a r4cc0c9ee 94 94 /* Its a good idea to allocate path, plus we (may) need a copy of 95 95 * path to tokenize if parents are specified */ 96 if (NULL == (tmp = cli_strdup(path))) {96 if (NULL == (tmp = strdup(path))) { 97 97 cli_error(CL_ENOMEM, "%s: path too big?", cmdname); 98 98 return 1; … … 129 129 130 130 /* TODO: Canonify the path prior to tokenizing it, see below */ 131 dirs[i] = cli_strtok(tmp, "/");131 dirs[i] = strtok(tmp, "/"); 132 132 while (dirs[i] && i < 255) 133 dirs[++i] = cli_strtok(NULL, "/");133 dirs[++i] = strtok(NULL, "/"); 134 134 135 135 if (NULL == dirs[0]) -
uspace/app/bdsh/cmds/modules/touch/touch.c
rfc11b8a r4cc0c9ee 38 38 #include <dirent.h> 39 39 #include <sys/types.h> 40 #include <string.h> 40 41 41 42 #include "config.h" … … 80 81 81 82 for (i = 1; i < argc; i ++) { 82 buff = cli_strdup(argv[i]);83 buff = strdup(argv[i]); 83 84 dirp = opendir(buff); 84 85 if (dirp) { -
uspace/app/bdsh/exec.c
rfc11b8a r4cc0c9ee 81 81 } 82 82 83 path_tok = cli_strdup(PATH);83 path_tok = strdup(PATH); 84 84 85 85 /* Extract the PATH env to a path[] array */ 86 path[n] = cli_strtok(path_tok, PATH_DELIM);86 path[n] = strtok(path_tok, PATH_DELIM); 87 87 while (NULL != path[n]) { 88 88 if ((strlen(path[n]) + x ) > PATH_MAX) { … … 92 92 break; 93 93 } 94 path[++n] = cli_strtok(NULL, PATH_DELIM);94 path[++n] = strtok(NULL, PATH_DELIM); 95 95 } 96 96 … … 115 115 char *tmp; 116 116 117 tmp = cli_strdup(find_command(cmd));117 tmp = strdup(find_command(cmd)); 118 118 free(found); 119 119 -
uspace/app/bdsh/input.c
rfc11b8a r4cc0c9ee 58 58 return CL_EFAIL; 59 59 60 tmp = cli_strdup(usr->line);60 tmp = strdup(usr->line); 61 61 62 cmd[n] = cli_strtok(tmp, " ");62 cmd[n] = strtok(tmp, " "); 63 63 while (cmd[n] && n < WORD_MAX) { 64 cmd[++n] = cli_strtok(NULL, " ");64 cmd[++n] = strtok(NULL, " "); 65 65 } 66 66 … … 139 139 if (len == 0 || line[0] == '\n') 140 140 return; 141 usr->line = cli_strdup(line);141 usr->line = strdup(line); 142 142 143 143 return; -
uspace/app/bdsh/util.c
rfc11b8a r4cc0c9ee 1 /* Copyright (c) 2008, Tim Post <tinkertim@gmail.com> 2 * Copyright (C) 1998 by Wes Peters <wes@softweyr.com> 3 * Copyright (c) 1988, 1993 The Regents of the University of California. 4 * All rights reserved by all copyright holders. 1 /* Copyright (c) 2008, Tim Post <tinkertim@gmail.com> - All rights reserved 5 2 * 6 3 * Redistribution and use in source and binary forms, with or without … … 31 28 */ 32 29 33 /* NOTES:34 * 1 - Various functions were adapted from FreeBSD (copyright holders noted above)35 * these functions are identified with comments.36 *37 * 2 - Some of these have since appeared in libc. They remain here for various38 * reasons, such as the eventual integration of garbage collection for things39 * that allocate memory and don't automatically free it.40 *41 * 3 - Things that expect a pointer to an allocated string do _no_ sanity checking42 * if developing on a simulator with no debugger, take care :)43 */44 45 30 #include <stdio.h> 46 31 #include <string.h> … … 54 39 55 40 extern volatile int cli_errno; 56 57 /* some platforms do not have strdup, implement it here.58 * Returns a pointer to an allocated string or NULL on failure */59 char * cli_strdup(const char *s1)60 {61 size_t len = strlen(s1) + 1;62 void *ret = malloc(len);63 64 if (ret == NULL) {65 cli_errno = CL_ENOMEM;66 return (char *) NULL;67 }68 69 cli_errno = CL_EOK;70 return (char *) memcpy(ret, s1, len);71 }72 73 /* Ported from FBSD strtok.c 8.1 (Berkeley) 6/4/93 */74 char * cli_strtok_r(char *s, const char *delim, char **last)75 {76 char *spanp, *tok;77 int c, sc;78 79 if (s == NULL && (s = *last) == NULL) {80 cli_errno = CL_EFAIL;81 return (NULL);82 }83 84 cont:85 c = *s++;86 for (spanp = (char *)delim; (sc = *spanp++) != 0;) {87 if (c == sc)88 goto cont;89 }90 91 if (c == 0) { /* no non-delimiter characters */92 *last = NULL;93 return (NULL);94 }95 96 tok = s - 1;97 98 for (;;) {99 c = *s++;100 spanp = (char *)delim;101 do {102 if ((sc = *spanp++) == c) {103 if (c == 0)104 s = NULL;105 else106 s[-1] = '\0';107 *last = s;108 return (tok);109 }110 } while (sc != 0);111 }112 }113 114 /* Ported from FBSD strtok.c 8.1 (Berkeley) 6/4/93 */115 char * cli_strtok(char *s, const char *delim)116 {117 static char *last;118 119 return (cli_strtok_r(s, delim, &last));120 }121 41 122 42 /* Count and return the # of elements in an array */ -
uspace/app/bdsh/util.h
rfc11b8a r4cc0c9ee 3 3 4 4 #include "scli.h" 5 6 /* Internal string handlers */7 extern char * cli_strdup(const char *);8 extern char * cli_strtok_r(char *, const char *, char **);9 extern char * cli_strtok(char *, const char *);10 5 11 6 /* Utility functions */
Note:
See TracChangeset
for help on using the changeset viewer.