Changeset 9be9c4d in mainline for uspace/app
- Timestamp:
- 2011-07-13T19:54:05Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3e5c48c9
- Parents:
- 026793d
- Location:
- uspace/app
- Files:
-
- 2 added
- 10 edited
-
bdsh/Makefile (modified) (1 diff)
-
bdsh/compl.c (added)
-
bdsh/compl.h (added)
-
bdsh/config.h (modified) (1 diff)
-
bdsh/exec.c (modified) (4 diffs)
-
bdsh/exec.h (modified) (1 diff)
-
bdsh/input.c (modified) (4 diffs)
-
bdsh/scli.h (modified) (1 diff)
-
sbi/src/input.c (modified) (2 diffs)
-
sbi/src/os/helenos.c (modified) (2 diffs)
-
sbi/src/os/os.h (modified) (1 diff)
-
sbi/src/os/posix.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/Makefile
r026793d r9be9c4d 54 54 cmds/mod_cmds.c \ 55 55 cmds/builtin_cmds.c \ 56 compl.c \ 56 57 errors.c \ 57 58 input.c \ -
uspace/app/bdsh/config.h
r026793d r9be9c4d 40 40 #endif 41 41 42 /* Work around for getenv() */43 #define PATH "/srv:/app"44 #define PATH_DELIM ":"45 46 42 /* Used in many places */ 47 43 #define SMALL_BUFLEN 256 -
uspace/app/bdsh/exec.c
r026793d r9be9c4d 52 52 static int try_access(const char *); 53 53 54 const char *search_dir[] = { "app", "srv", NULL }; 55 54 56 /* work-around for access() */ 55 57 static int try_access(const char *f) … … 69 71 static char *find_command(char *cmd) 70 72 { 71 char *path_tok; 72 char *path[PATH_MAX]; 73 int n = 0, i = 0; 74 size_t x = str_size(cmd) + 2; 73 size_t i; 75 74 76 75 found = (char *)malloc(PATH_MAX); … … 81 80 } 82 81 83 path_tok = str_dup(PATH);84 85 /* Extract the PATH env to a path[] array */86 path[n] = strtok(path_tok, PATH_DELIM);87 while (NULL != path[n]) {88 if ((str_size(path[n]) + x ) > PATH_MAX) {89 cli_error(CL_ENOTSUP,90 "Segment %d of path is too large, search ends at segment %d",91 n, n-1);92 break;93 }94 path[++n] = strtok(NULL, PATH_DELIM);95 }96 97 82 /* We now have n places to look for the command */ 98 for (i =0; path[i]; i++) {83 for (i = 0; search_dir[i] != NULL; i++) { 99 84 memset(found, 0, sizeof(found)); 100 snprintf(found, PATH_MAX, "%s/%s", path[i], cmd);85 snprintf(found, PATH_MAX, "%s/%s", search_dir[i], cmd); 101 86 if (-1 != try_access(found)) { 102 free(path_tok);103 87 return (char *) found; 104 88 } … … 106 90 107 91 /* We didn't find it, just give it back as-is. */ 108 free(path_tok);109 92 return (char *) cmd; 110 93 } -
uspace/app/bdsh/exec.h
r026793d r9be9c4d 33 33 #include "scli.h" 34 34 35 extern const char *search_dir[]; 36 35 37 extern unsigned int try_exec(char *, char **, iostate_t *); 36 38 -
uspace/app/bdsh/input.c
r026793d r9be9c4d 1 1 /* 2 2 * Copyright (c) 2008 Tim Post 3 * Copyright (c) 2011 Jiri Svoboda 3 4 * All rights reserved. 4 5 * … … 43 44 44 45 #include "config.h" 46 #include "compl.h" 45 47 #include "util.h" 46 48 #include "scli.h" … … 226 228 int rc; 227 229 228 console_flush(tinput->console); 229 console_set_style(tinput->console, STYLE_EMPHASIS); 230 printf("%s", usr->prompt); 231 console_flush(tinput->console); 232 console_set_style(tinput->console, STYLE_NORMAL); 230 tinput_set_prompt(tinput, usr->prompt); 233 231 234 232 rc = tinput_read(tinput, &str); … … 263 261 } 264 262 263 tinput_set_compl_ops(tinput, &compl_ops); 264 265 265 return 0; 266 266 } -
uspace/app/bdsh/scli.h
r026793d r9be9c4d 32 32 #include "config.h" 33 33 #include <stdint.h> 34 #include <stdio.h> 34 35 35 36 typedef struct { -
uspace/app/sbi/src/input.c
r026793d r9be9c4d 176 176 int input_get_line(input_t *input, char **line) 177 177 { 178 const char *prompt; 178 179 const char *sp; 179 180 char *dp; … … 212 213 /* Interactive mode */ 213 214 if (input->line_no == 0) 214 pr intf("sbi> ");215 prompt = "sbi> "; 215 216 else 216 pr intf("... ");217 prompt = "... "; 217 218 218 219 fflush(stdout); 219 if (os_input_line( &line_p) != EOK)220 if (os_input_line(prompt, &line_p) != EOK) 220 221 return EIO; 221 222 -
uspace/app/sbi/src/os/helenos.c
r026793d r9be9c4d 210 210 * @param ptr Place to store pointer to new string. 211 211 */ 212 int os_input_line(c har **ptr)212 int os_input_line(const char *prompt, char **ptr) 213 213 { 214 214 char *line; … … 219 219 if (tinput == NULL) 220 220 return EIO; 221 222 tinput_set_prompt(tinput, prompt); 221 223 } 222 224 -
uspace/app/sbi/src/os/os.h
r026793d r9be9c4d 38 38 char *os_chr_to_astr(wchar_t chr); 39 39 void os_input_disp_help(void); 40 int os_input_line(c har **ptr);40 int os_input_line(const char *prompt, char **ptr); 41 41 int os_exec(char * const cmd[]); 42 42 -
uspace/app/sbi/src/os/posix.c
r026793d r9be9c4d 193 193 * @param ptr Place to store pointer to new string. 194 194 */ 195 int os_input_line(char **ptr) 196 { 195 int os_input_line(const char *prompt, char **ptr) 196 { 197 printf("%s", prompt); 198 197 199 if (fgets(os_input_buffer, OS_INPUT_BUFFER_SIZE, stdin) == NULL) 198 200 os_input_buffer[0] = '\0';
Note:
See TracChangeset
for help on using the changeset viewer.
