Subversion Repositories HelenOS

Rev

Rev 3376 | Rev 3420 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3376 Rev 3377
Line 245... Line 245...
245
 
245
 
246
    for (i=0; args[i] != NULL; i++);
246
    for (i=0; args[i] != NULL; i++);
247
    return i;
247
    return i;
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