mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-11-09 08:37:58 +08:00
2008-04-03 Chris Johns <chrisj@rtems.org>
* libfs/src/nfsclient/src/librtemsNfs.h, libfs/src/nfsclient/src/nfs.c: Remove CEXP references. CEXP is external to RTEMS and even if in the cpukit it should not cross reference in this way. * libmisc/shell/shell_getchar.c: New. Taken from the monitor. * libmisc/Makefile.am: Add shell_getchar.c and clean up a little in the shell area. * libmisc/shell/shell.c, libmisc/shell/shell.h: Add line editting support.
This commit is contained in:
1 parent
ffd1050791
commit
ea90df234a
7 files changed
+652
-128
No files matched your search
@@ -1,3 +1,15 @@
|
||||
2008-04-03 Chris Johns <chrisj@rtems.org>
|
||||
|
||||
* libfs/src/nfsclient/src/librtemsNfs.h,
|
||||
libfs/src/nfsclient/src/nfs.c: Remove CEXP references. CEXP is
|
||||
external to RTEMS and even if in the cpukit it should not cross
|
||||
reference in this way.
|
||||
* libmisc/shell/shell_getchar.c: New. Taken from the monitor.
|
||||
* libmisc/Makefile.am: Add shell_getchar.c and clean up a little
|
||||
in the shell area.
|
||||
* libmisc/shell/shell.c, libmisc/shell/shell.h: Add line editting
|
||||
support.
|
||||
|
||||
2008-03-29 Chris Johns <chrisj@rtems.org>
|
||||
|
||||
* librpc/include/rpc/clnt.h: Added the missing __BEGIN_DECLS as
|
||||
|
||||
@@ -70,11 +70,6 @@
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
|
||||
#ifdef HAVE_CEXP_H
|
||||
#include <cexpHelp.h>
|
||||
#endif
|
||||
|
||||
/* RPCIO driver interface.
|
||||
* If you need RPCIO for other purposes than NFS
|
||||
* you may want to include <rpcio.h>
|
||||
|
||||
@@ -68,17 +68,11 @@
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
|
||||
#include <nfs_prot.h>
|
||||
#include <mount_prot.h>
|
||||
|
||||
#include "rpcio.h"
|
||||
|
||||
#ifdef HAVE_CEXP_H
|
||||
#include <cexpHelp.h>
|
||||
#endif
|
||||
|
||||
|
||||
/* Configurable parameters */
|
||||
|
||||
/* Estimated average length of a filename (including terminating 0).
|
||||
|
||||
@@ -71,16 +71,16 @@ libshell_a_SOURCES = shell/cat_file.c shell/cmds.c shell/internal.h \
|
||||
shell/main_echo.c shell/main_exit.c shell/main_help.c shell/main_id.c \
|
||||
shell/main_logoff.c shell/main_ls.c shell/main_mallocinfo.c \
|
||||
shell/main_mdump.c shell/main_medit.c shell/main_mfill.c \
|
||||
shell/main_mkdir.c shell/main_mount.c $(shell_mount_fs) \
|
||||
shell/main_mkdir.c shell/main_mount.c \
|
||||
shell/main_mount_msdos.c shell/main_mmove.c shell/main_msdosfmt.c \
|
||||
shell/main_mwdump.c shell/main_perioduse.c shell/main_pwd.c \
|
||||
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/shellconfig.c shell/shellconfig.h \
|
||||
shell/shell.h shell/shell_makeargs.c shell/str2int.c shell/write_file.c \
|
||||
shell/utils-cp.c shell/err.c shell/errx.c shell/verr.c shell/verrx.c \
|
||||
shell/vwarn.c shell/vwarnx.c shell/warn.c shell/warnx.c \
|
||||
shell/shell.c shell/shell_cmdset.c shell/shell_getchar.c shell/shellconfig.c \
|
||||
shell/shellconfig.h shell/shell.h shell/shell_makeargs.c shell/str2int.c \
|
||||
shell/write_file.c shell/utils-cp.c shell/err.c shell/errx.c shell/verr.c \
|
||||
shell/verrx.c shell/vwarn.c shell/vwarnx.c shell/warn.c shell/warnx.c \
|
||||
shell/fts.c shell/print_heapinfo.c shell/main_wkspaceinfo.c \
|
||||
shell/shell_script.c
|
||||
if LIBNETWORKING
|
||||
|
||||
+428
-112
File diff suppressed because it is too large.
Load diff
@@ -29,6 +29,31 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Some key labels to define special keys.
|
||||
*/
|
||||
|
||||
#define RTEMS_SHELL_KEYS_EXTENDED (0x8000)
|
||||
#define RTEMS_SHELL_KEYS_NORMAL_MASK (0x00ff)
|
||||
#define RTEMS_SHELL_KEYS_INS (0)
|
||||
#define RTEMS_SHELL_KEYS_DEL (1)
|
||||
#define RTEMS_SHELL_KEYS_UARROW (2)
|
||||
#define RTEMS_SHELL_KEYS_DARROW (3)
|
||||
#define RTEMS_SHELL_KEYS_LARROW (4)
|
||||
#define RTEMS_SHELL_KEYS_RARROW (5)
|
||||
#define RTEMS_SHELL_KEYS_HOME (6)
|
||||
#define RTEMS_SHELL_KEYS_END (7)
|
||||
#define RTEMS_SHELL_KEYS_F1 (8)
|
||||
#define RTEMS_SHELL_KEYS_F2 (9)
|
||||
#define RTEMS_SHELL_KEYS_F3 (10)
|
||||
#define RTEMS_SHELL_KEYS_F4 (11)
|
||||
#define RTEMS_SHELL_KEYS_F5 (12)
|
||||
#define RTEMS_SHELL_KEYS_F6 (13)
|
||||
#define RTEMS_SHELL_KEYS_F7 (14)
|
||||
#define RTEMS_SHELL_KEYS_F8 (15)
|
||||
#define RTEMS_SHELL_KEYS_F9 (16)
|
||||
#define RTEMS_SHELL_KEYS_F10 (17)
|
||||
|
||||
typedef int (*rtems_shell_command_t)(int argc,char * argv[]);
|
||||
|
||||
struct rtems_shell_cmd_tt;
|
||||
@@ -48,6 +73,12 @@ typedef struct {
|
||||
char *alias;
|
||||
} rtems_shell_alias_t;
|
||||
|
||||
/*
|
||||
* The return value has RTEMS_SHELL_KEYS_EXTENDED set if the key
|
||||
* is extended, ie a special key.
|
||||
*/
|
||||
unsigned int rtems_shell_getchar(FILE *in);
|
||||
|
||||
rtems_shell_cmd_t * rtems_shell_lookup_cmd(char * cmd);
|
||||
|
||||
rtems_shell_cmd_t *rtems_shell_add_cmd_struct(
|
||||
|
||||
@@ -0,0 +1,176 @@
|
||||
/*
|
||||
*
|
||||
* Handle keys for the shell.
|
||||
*
|
||||
* Author:
|
||||
*
|
||||
* Chris Johns (chrisj@rtems.org)
|
||||
*
|
||||
* 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/system.h>
|
||||
#include <rtems/shell.h>
|
||||
#include <rtems/shellconfig.h>
|
||||
#include "internal.h"
|
||||
|
||||
/*
|
||||
* Taken from the monitor code.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Translation tables. Not sure if this is the best way to
|
||||
* handle this, how-ever I wish to avoid the overhead of
|
||||
* including a more complete and standard environment such
|
||||
* as ncurses.
|
||||
*/
|
||||
|
||||
struct translation_table
|
||||
{
|
||||
char expecting;
|
||||
struct translation_table *branch;
|
||||
unsigned int key;
|
||||
};
|
||||
|
||||
static struct translation_table trans_one[] =
|
||||
{
|
||||
{ '\x7e', 0, RTEMS_SHELL_KEYS_HOME },
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
|
||||
static struct translation_table trans_two[] =
|
||||
{
|
||||
{ '~', 0, RTEMS_SHELL_KEYS_INS },
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
|
||||
static struct translation_table trans_three[] =
|
||||
{
|
||||
{ '~', 0, RTEMS_SHELL_KEYS_DEL },
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
|
||||
static struct translation_table trans_tab_csi[] =
|
||||
{
|
||||
{ '1', trans_one, 0 },
|
||||
{ '2', trans_two, 0 },
|
||||
{ '3', trans_three, 0 },
|
||||
{ 'A', 0, RTEMS_SHELL_KEYS_UARROW },
|
||||
{ 'B', 0, RTEMS_SHELL_KEYS_DARROW },
|
||||
{ 'D', 0, RTEMS_SHELL_KEYS_LARROW },
|
||||
{ 'C', 0, RTEMS_SHELL_KEYS_RARROW },
|
||||
{ 'F', 0, RTEMS_SHELL_KEYS_END },
|
||||
{ 'H', 0, RTEMS_SHELL_KEYS_HOME },
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
|
||||
static struct translation_table trans_tab_O[] =
|
||||
{
|
||||
{ '1', 0, RTEMS_SHELL_KEYS_F1 },
|
||||
{ '2', 0, RTEMS_SHELL_KEYS_F2 },
|
||||
{ '3', 0, RTEMS_SHELL_KEYS_F3 },
|
||||
{ '4', 0, RTEMS_SHELL_KEYS_F4 },
|
||||
{ '5', 0, RTEMS_SHELL_KEYS_F5 },
|
||||
{ '6', 0, RTEMS_SHELL_KEYS_F6 },
|
||||
{ '7', 0, RTEMS_SHELL_KEYS_F7 },
|
||||
{ '8', 0, RTEMS_SHELL_KEYS_F8 },
|
||||
{ '9', 0, RTEMS_SHELL_KEYS_F9 },
|
||||
{ ':', 0, RTEMS_SHELL_KEYS_F10 },
|
||||
{ 'F', 0, RTEMS_SHELL_KEYS_END },
|
||||
{ 'P', 0, RTEMS_SHELL_KEYS_F1 },
|
||||
{ 'Q', 0, RTEMS_SHELL_KEYS_F2 },
|
||||
{ 'R', 0, RTEMS_SHELL_KEYS_F3 },
|
||||
{ 'S', 0, RTEMS_SHELL_KEYS_F4 },
|
||||
{ 'T', 0, RTEMS_SHELL_KEYS_F5 },
|
||||
{ 'U', 0, RTEMS_SHELL_KEYS_F6 },
|
||||
{ 'V', 0, RTEMS_SHELL_KEYS_F7 },
|
||||
{ 'W', 0, RTEMS_SHELL_KEYS_F8 },
|
||||
{ 'X', 0, RTEMS_SHELL_KEYS_F9 },
|
||||
{ 'Y', 0, RTEMS_SHELL_KEYS_F10 },
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
|
||||
static struct translation_table trans_tab[] =
|
||||
{
|
||||
{ '[', trans_tab_csi, 0 }, /* CSI command sequences */
|
||||
{ 'O', trans_tab_O, 0 }, /* O are the fuction keys */
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
|
||||
/*
|
||||
* Perform a basic tranlation for some ANSI/VT100 key codes.
|
||||
* This code could do with a timeout on the ESC as it is
|
||||
* now lost from the input stream. It is not* used by the
|
||||
* line editor below so considiered not worth the effort.
|
||||
*/
|
||||
|
||||
unsigned int
|
||||
rtems_shell_getchar (FILE *in)
|
||||
{
|
||||
struct translation_table *translation = 0;
|
||||
for (;;)
|
||||
{
|
||||
char c = fgetc (in);
|
||||
if (c == EOF)
|
||||
return EOF;
|
||||
if (c == 27)
|
||||
translation = trans_tab;
|
||||
else
|
||||
{
|
||||
/*
|
||||
* If no translation happing just pass through
|
||||
* and return the key.
|
||||
*/
|
||||
if (translation)
|
||||
{
|
||||
/*
|
||||
* Scan the current table for the key, and if found
|
||||
* see if this key is a fork. If so follow it and
|
||||
* wait else return the extended key.
|
||||
*/
|
||||
int index = 0;
|
||||
int branched = 0;
|
||||
while ((translation[index].expecting != '\0') ||
|
||||
(translation[index].key != '\0'))
|
||||
{
|
||||
if (translation[index].expecting == c)
|
||||
{
|
||||
/*
|
||||
* A branch is take if more keys are to come.
|
||||
*/
|
||||
if (translation[index].branch == 0)
|
||||
return RTEMS_SHELL_KEYS_EXTENDED | translation[index].key;
|
||||
else
|
||||
{
|
||||
translation = translation[index].branch;
|
||||
branched = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
index++;
|
||||
}
|
||||
/*
|
||||
* Who knows what these keys are, just drop them.
|
||||
*/
|
||||
if (!branched)
|
||||
translation = 0;
|
||||
}
|
||||
else
|
||||
return c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user