Changeset 0c4f46a in mainline
- Timestamp:
- 2008-08-30T15:05:54Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 42a0607
- Parents:
- 43e02a6
- Location:
- uspace/app/bdsh
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/builtins/cd/cd.c
r43e02a6 r0c4f46a 87 87 88 88 if (rc == 0) { 89 cli_set_prompt(usr); 89 90 return CMD_SUCCESS; 90 91 } else { -
uspace/app/bdsh/scli.c
r43e02a6 r0c4f46a 57 57 static void cli_finit(cliuser_t *usr); 58 58 59 /* (re)allocates memory to store the current working directory, gets60 * and updates the current working directory, formats the prompt61 * string */62 unsigned int cli_set_prompt(cliuser_t *usr)63 {64 usr->prompt = (char *) realloc(usr->prompt, PATH_MAX);65 if (NULL == usr->prompt) {66 cli_error(CL_ENOMEM, "Can not allocate prompt");67 return 1;68 }69 memset(usr->prompt, 0, sizeof(usr->prompt));70 71 usr->cwd = (char *) realloc(usr->cwd, PATH_MAX);72 if (NULL == usr->cwd) {73 cli_error(CL_ENOMEM, "Can not allocate cwd");74 return 1;75 }76 memset(usr->cwd, 0, sizeof(usr->cwd));77 78 usr->cwd = getcwd(usr->cwd, PATH_MAX - 1);79 80 if (NULL == usr->cwd)81 snprintf(usr->cwd, PATH_MAX, "(unknown)");82 83 if (1 < cli_psprintf(&usr->prompt, "%s # ", usr->cwd)) {84 cli_error(cli_errno, "Failed to set prompt");85 return 1;86 }87 88 return 0;89 }90 91 59 /* Constructor */ 92 60 static int cli_init(cliuser_t *usr) … … 125 93 126 94 while (!cli_quit) { 127 cli_set_prompt(&usr);128 95 get_input(&usr); 129 96 if (NULL != usr.line) { -
uspace/app/bdsh/scli.h
r43e02a6 r0c4f46a 14 14 } cliuser_t; 15 15 16 extern unsigned int cli_set_prompt(cliuser_t *usr);17 18 16 #endif -
uspace/app/bdsh/util.c
r43e02a6 r0c4f46a 248 248 } 249 249 250 /* (re)allocates memory to store the current working directory, gets 251 * and updates the current working directory, formats the prompt 252 * string */ 253 unsigned int cli_set_prompt(cliuser_t *usr) 254 { 255 usr->prompt = (char *) realloc(usr->prompt, PATH_MAX); 256 if (NULL == usr->prompt) { 257 cli_error(CL_ENOMEM, "Can not allocate prompt"); 258 cli_errno = CL_ENOMEM; 259 return 1; 260 } 261 memset(usr->prompt, 0, sizeof(usr->prompt)); 262 263 usr->cwd = (char *) realloc(usr->cwd, PATH_MAX); 264 if (NULL == usr->cwd) { 265 cli_error(CL_ENOMEM, "Can not allocate cwd"); 266 cli_errno = CL_ENOMEM; 267 return 1; 268 } 269 memset(usr->cwd, 0, sizeof(usr->cwd)); 270 271 usr->cwd = getcwd(usr->cwd, PATH_MAX - 1); 272 273 if (NULL == usr->cwd) 274 snprintf(usr->cwd, PATH_MAX, "(unknown)"); 275 276 if (1 < cli_psprintf(&usr->prompt, "%s # ", usr->cwd)) { 277 cli_error(cli_errno, "Failed to set prompt"); 278 return 1; 279 } 280 281 return 0; 282 } 283 284 -
uspace/app/bdsh/util.h
r43e02a6 r0c4f46a 1 1 #ifndef UTIL_H 2 2 #define UTIL_H 3 4 #include "scli.h" 3 5 4 6 /* Internal string handlers */ … … 8 10 extern char * cli_strtok_r(char *, const char *, char **); 9 11 extern char * cli_strtok(char *, const char *); 12 13 /* Utility functions */ 10 14 extern unsigned int cli_count_args(char **); 15 extern unsigned int cli_set_prompt(cliuser_t *usr); 11 16 12 17 #endif
Note:
See TracChangeset
for help on using the changeset viewer.