Changeset 0c4f46a in mainline for uspace/app/bdsh/scli.c
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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) {
Note:
See TracChangeset
for help on using the changeset viewer.