Changeset ec7f8b1 in mainline for uspace/app/bdsh
- Timestamp:
- 2011-08-21T15:35:03Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- bb74dabe
- Parents:
- c4a8e4a (diff), 5935c079 (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/app/bdsh
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/Makefile
rc4a8e4a rec7f8b1 29 29 30 30 USPACE_PREFIX = ../.. 31 LIBS = $(LIBBLOCK_PREFIX)/libblock.a $(LIBCLUI_PREFIX)/libclui.a 32 EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX) -I$(LIBCLUI_PREFIX) -I. -Icmds/ \ 33 -Icmds/builtins -Icmds/modules 31 LIBS = $(LIBBLOCK_PREFIX)/libblock.a $(LIBCLUI_PREFIX)/libclui.a \ 32 $(LIBFMTUTIL_PREFIX)/libfmtutil.a 33 EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX) -I$(LIBCLUI_PREFIX) \ 34 -I$(LIBFMTUTIL_PREFIX) -I. -Icmds/ -Icmds/builtins -Icmds/modules 34 35 BINARY = bdsh 35 36 -
uspace/app/bdsh/cmds/modules/help/help.c
rc4a8e4a rec7f8b1 1 1 /* 2 2 * Copyright (c) 2008 Tim Post 3 * Copyright (c) 2011 Martin Sucha 3 4 * All rights reserved. 4 5 * … … 30 31 #include <stdlib.h> 31 32 #include <str.h> 33 #include <fmtutil.h> 32 34 33 35 #include "config.h" … … 128 130 static void help_survival(void) 129 131 { 130 printf("Don't panic!\n\n"); 131 132 printf("This is Bdsh, the Brain dead shell, currently " 132 print_wrapped_console( 133 "Don't panic!\n\n" 134 135 "This is Bdsh, the Brain dead shell, currently " 133 136 "the primary user interface to HelenOS. Bdsh allows you to enter " 134 137 "commands and supports history (Up, Down arrow keys), " 135 138 "line editing (Left Arrow, Right Arrow, Home, End, Backspace), " 136 139 "selection (Shift + movement keys), copy and paste (Ctrl-C, " 137 "Ctrl-V), similar to common desktop environments.\n\n" );138 139 printf("The most basic filesystem commands are Bdsh builtins. Type "140 "Ctrl-V), similar to common desktop environments.\n\n" 141 142 "The most basic filesystem commands are Bdsh builtins. Type " 140 143 "'help commands' [Enter] to see the list of Bdsh builtin commands. " 141 144 "Other commands are external executables located in the /app and " 142 145 "/srv directories. Type 'ls /app' [Enter] and 'ls /srv' [Enter] " 143 146 "to see their list. You can execute an external command simply " 144 "by entering its name (e.g. type 'tetris' [Enter]).\n\n" );145 146 printf("HelenOS has virtual consoles (VCs). You can switch between "147 "these using the F1-F11 keys.\n\n" );148 149 printf("This is but a small glimpse of what you can do with HelenOS. "147 "by entering its name (e.g. type 'tetris' [Enter]).\n\n" 148 149 "HelenOS has virtual consoles (VCs). You can switch between " 150 "these using the F1-F11 keys.\n\n" 151 152 "This is but a small glimpse of what you can do with HelenOS. " 150 153 "To learn more please point your browser to the HelenOS User's " 151 "Guide: http://trac.helenos.org/trac.fcgi/wiki/UsersGuide\n\n"); 154 "Guide: http://trac.helenos.org/wiki/UsersGuide\n\n", 155 ALIGN_LEFT); 152 156 } 153 157 -
uspace/app/bdsh/compl.c
rc4a8e4a rec7f8b1 90 90 { 91 91 compl_t *cs = NULL; 92 size_t pref_size;93 92 char *stext = NULL; 94 93 char *prefix = NULL; 95 94 char *dirname = NULL; 95 int retval; 96 97 token_t *tokens = calloc(WORD_MAX, sizeof(token_t)); 98 if (tokens == NULL) { 99 retval = ENOMEM; 100 goto error; 101 } 102 103 size_t pref_size; 96 104 char *rpath_sep; 97 105 static const char *dirlist_arg[] = { ".", NULL }; 98 int retval;99 106 tokenizer_t tok; 100 token_t tokens[WORD_MAX]; 101 unsigned int current_token; 107 ssize_t current_token; 102 108 size_t tokens_length; 103 109 104 110 cs = calloc(1, sizeof(compl_t)); 105 111 if (!cs) { … … 107 113 goto error; 108 114 } 109 115 110 116 /* Convert text buffer to string */ 111 117 stext = wstr_to_astr(text); … … 127 133 128 134 /* Find the current token */ 129 for (current_token = 0; current_token < tokens_length; current_token++) { 135 for (current_token = 0; current_token < (ssize_t) tokens_length; 136 current_token++) { 130 137 token_t *t = &tokens[current_token]; 131 138 size_t end = t->char_start + t->char_length; 132 /* Check if the caret lies inside the token or immediately 139 140 /* 141 * Check if the caret lies inside the token or immediately 133 142 * after it 134 143 */ … … 138 147 } 139 148 140 if (tokens[current_token].type != TOKTYPE_SPACE) { 149 if (tokens_length == 0) 150 current_token = -1; 151 152 if ((current_token >= 0) && (tokens[current_token].type != TOKTYPE_SPACE)) 141 153 *cstart = tokens[current_token].char_start; 142 } 143 else { 154 else 144 155 *cstart = pos; 145 }146 147 /* Extract the prefix being completed156 157 /* 158 * Extract the prefix being completed 148 159 * XXX: handle strings, etc. 149 160 */ … … 154 165 goto error; 155 166 } 156 157 str_ncpy(prefix, pref_size + 1, stext + 158 tokens[current_token].byte_start, pref_size); 167 prefix[pref_size] = 0; 168 169 if (current_token >= 0) { 170 str_ncpy(prefix, pref_size + 1, stext + 171 tokens[current_token].byte_start, pref_size); 172 } 159 173 160 174 /* … … 165 179 166 180 /* Skip any whitespace before current token */ 167 int prev_token = current_token - 1;168 if ( prev_token != -1 && tokens[prev_token].type == TOKTYPE_SPACE) {181 ssize_t prev_token = current_token - 1; 182 if ((prev_token >= 0) && (tokens[prev_token].type == TOKTYPE_SPACE)) 169 183 prev_token--; 170 } 171 184 172 185 /* 173 186 * It is a command if it is the first token or if it immediately 174 187 * follows a pipe token. 175 188 */ 176 if ( prev_token == -1 || tokens[prev_token].type == TOKTYPE_SPACE)189 if ((prev_token < 0) || (tokens[prev_token].type == TOKTYPE_SPACE)) 177 190 cs->is_command = true; 178 191 else … … 249 262 if (cs != NULL) 250 263 free(cs); 264 if (tokens != NULL) 265 free(tokens); 251 266 252 267 return retval; -
uspace/app/bdsh/input.c
rc4a8e4a rec7f8b1 67 67 int process_input(cliuser_t *usr) 68 68 { 69 token_t *tokens = calloc(WORD_MAX, sizeof(token_t)); 70 if (tokens == NULL) 71 return ENOMEM; 72 69 73 char *cmd[WORD_MAX]; 70 token_t tokens_space[WORD_MAX];71 token_t *tokens = tokens_space;72 74 int rc = 0; 73 75 tokenizer_t tok; … … 77 79 char *redir_to = NULL; 78 80 79 if (NULL == usr->line) 81 if (usr->line == NULL) { 82 free(tokens); 80 83 return CL_EFAIL; 84 } 81 85 82 86 rc = tok_init(&tok, usr->line, tokens, WORD_MAX); … … 209 213 } 210 214 tok_fini(&tok); 215 free(tokens); 211 216 212 217 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.