forked from Imagelibrary/rtems
2008-08-27 Joel Sherrill <joel.sherrill@OARcorp.com>
* libmisc/Makefile.am, libmisc/shell/shell.c, libmisc/shell/shell.h: Split out rtems_shell_get_prompt() so it can be overridden by the user. * libmisc/shell/shell_getprompt.c: New file.
This commit is contained in:
@@ -1,3 +1,10 @@
|
||||
2008-08-27 Joel Sherrill <joel.sherrill@OARcorp.com>
|
||||
|
||||
* libmisc/Makefile.am, libmisc/shell/shell.c, libmisc/shell/shell.h:
|
||||
Split out rtems_shell_get_prompt() so it can be overridden by the
|
||||
user.
|
||||
* libmisc/shell/shell_getprompt.c: New file.
|
||||
|
||||
2008-08-27 Ralf Corsépius <ralf.corsepius@rtems.org>
|
||||
|
||||
* libnetworking/libc/getproto.c, libnetworking/libc/getprotoent.c,
|
||||
|
||||
@@ -77,7 +77,9 @@ libshell_a_SOURCES = shell/cat_file.c shell/cmds.c shell/internal.h \
|
||||
shell/main_rm.c shell/main_rmdir.c shell/main_sleep.c \
|
||||
shell/main_stackuse.c shell/main_tty.c shell/main_umask.c \
|
||||
shell/main_unmount.c shell/main_blksync.c shell/main_whoami.c \
|
||||
shell/shell.c shell/shell_cmdset.c shell/shell_getchar.c shell/shellconfig.c \
|
||||
shell/shell.c shell/shell_cmdset.c shell/shell_getchar.c \
|
||||
shell/shell_getprompt.c shell/shellconfig.c \
|
||||
\
|
||||
shell/shellconfig.h shell/shell.h shell/shell_makeargs.c \
|
||||
shell/str2int.c shell/filemode.c shell/pwcache.c shell/print-ls.c\
|
||||
shell/write_file.c shell/utils-cp.c shell/utils-ls.c \
|
||||
|
||||
@@ -652,22 +652,6 @@ rtems_task rtems_shell_task(rtems_task_argument task_argument)
|
||||
rtems_task_delete( RTEMS_SELF );
|
||||
}
|
||||
|
||||
void rtems_shell_get_prompt(
|
||||
rtems_shell_env_t *shell_env,
|
||||
char *prompt,
|
||||
int size)
|
||||
{
|
||||
char curdir[256];
|
||||
|
||||
/* XXX: show_prompt user adjustable */
|
||||
getcwd(curdir,sizeof(curdir));
|
||||
snprintf(prompt, size - 1, "%s%s[%s] %c ",
|
||||
((shell_env->taskname) ? shell_env->taskname : ""),
|
||||
((shell_env->taskname) ? " " : ""),
|
||||
curdir,
|
||||
geteuid()?'$':'#');
|
||||
}
|
||||
|
||||
#define RTEMS_SHELL_MAXIMUM_ARGUMENTS (128)
|
||||
#define RTEMS_SHELL_CMD_SIZE (128)
|
||||
#define RTEMS_SHELL_CMD_COUNT (32)
|
||||
|
||||
@@ -225,6 +225,25 @@ struct rtems_shell_filesystems_tt {
|
||||
rtems_shell_filesystems_mounter_t mounter;
|
||||
};
|
||||
|
||||
/**
|
||||
* This method dynamically builds the command line prompt string
|
||||
* and places it in @a prompt.
|
||||
*
|
||||
* @param[in] shell_env is the shell execution environment
|
||||
* @param[in] prompt is a pointer to a string buffer area
|
||||
* @param[in] size is length of the prompt buffer area
|
||||
*
|
||||
* @return This method fills in the memory pointed to by @a prompt.
|
||||
*
|
||||
* @note An application specific implementation can be provided
|
||||
* by the user.
|
||||
*/
|
||||
void rtems_shell_get_prompt(
|
||||
rtems_shell_env_t *shell_env,
|
||||
char *prompt,
|
||||
size_t size
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
49
cpukit/libmisc/shell/shell_getprompt.c
Normal file
49
cpukit/libmisc/shell/shell_getprompt.c
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Dynamically build the shell prompt
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.com/license/LICENSE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <rtems.h>
|
||||
#include <rtems/error.h>
|
||||
#include <rtems/libio.h>
|
||||
#include <rtems/libio_.h>
|
||||
#include <rtems/system.h>
|
||||
#include <rtems/shell.h>
|
||||
#include "internal.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <pwd.h>
|
||||
|
||||
void rtems_shell_get_prompt(
|
||||
rtems_shell_env_t *shell_env,
|
||||
char *prompt,
|
||||
size_t size
|
||||
)
|
||||
{
|
||||
char curdir[256];
|
||||
|
||||
/* XXX: show_prompt user adjustable */
|
||||
getcwd(curdir,sizeof(curdir));
|
||||
snprintf(prompt, size - 1, "%s%s[%s] %c ",
|
||||
((shell_env->taskname) ? shell_env->taskname : ""),
|
||||
((shell_env->taskname) ? " " : ""),
|
||||
curdir,
|
||||
geteuid()?'$':'#');
|
||||
}
|
||||
Reference in New Issue
Block a user