Changeset 0c4f46a in mainline for uspace/app/bdsh/util.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/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
Note:
See TracChangeset
for help on using the changeset viewer.