summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-11-03 08:19:14 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-11-03 08:19:14 -0600
commita6c6119c811c117bbeda3edb6a82bd310b0ac3e6 (patch)
tree29224f7093a74d4748cb3fde361f9626c10f54df /apps
parentd5ac348ccc43fdef4f429f1f9a1411d2618c9d74 (diff)
downloadnuttx-a6c6119c811c117bbeda3edb6a82bd310b0ac3e6.tar.gz
nuttx-a6c6119c811c117bbeda3edb6a82bd310b0ac3e6.tar.bz2
nuttx-a6c6119c811c117bbeda3edb6a82bd310b0ac3e6.zip
Remove dependencies on TGETENT, SIGINT, SIGKILL, and most terminal configuration logic.
Diffstat (limited to 'apps')
-rw-r--r--apps/interpreters/bas/Kconfig14
-rw-r--r--apps/interpreters/bas/bas.c33
-rw-r--r--apps/interpreters/bas/config.h3
-rw-r--r--apps/interpreters/bas/fs.c455
-rw-r--r--apps/interpreters/bas/fs.h2
-rw-r--r--apps/interpreters/bas/program.c3
-rw-r--r--apps/interpreters/bas/statement.c26
7 files changed, 50 insertions, 486 deletions
diff --git a/apps/interpreters/bas/Kconfig b/apps/interpreters/bas/Kconfig
index 275ac6350..3542f7303 100644
--- a/apps/interpreters/bas/Kconfig
+++ b/apps/interpreters/bas/Kconfig
@@ -56,18 +56,4 @@ config INTERPRETER_BAS_HAVE_SYSCFG
---help---
NuttX does not support the syscfg() function
-config INTERPRETER_BAS_HAVE_SIGINT
- bool
- default n
- depends on EXPERIMENTAL
- ---help---
- NuttX does not support the SIGINT signal
-
-config INTERPRETER_BAS_HAVE_SIGQUIT
- bool
- default n
- depends on EXPERIMENTAL
- ---help---
- NuttX does not support the SIGQUIT signal
-
endif
diff --git a/apps/interpreters/bas/bas.c b/apps/interpreters/bas/bas.c
index e621c5939..e81b0f34d 100644
--- a/apps/interpreters/bas/bas.c
+++ b/apps/interpreters/bas/bas.c
@@ -1553,7 +1553,6 @@ static struct Value *compileProgram(struct Value *v, int clearGlobals)
lastdata = &stack.begindata;
}
optionbase = 0;
- FS_intr = 0;
stopped = 0;
program.runnable = 1;
pc = begin;
@@ -1614,7 +1613,6 @@ static void runline(struct Token *line)
pc.line = -1;
pc.token = line;
optionbase = 0;
- FS_intr = 0;
stopped = 0;
statements(&value);
if (value.type != V_ERROR && pc.token->type != T_EOL)
@@ -1656,7 +1654,7 @@ static void runline(struct Token *line)
nextdata.line = -1;
Value_destroy(&value);
pass = INTERPRET;
- FS_allowIntr(1);
+
do
{
assert(pass == INTERPRET);
@@ -1698,7 +1696,6 @@ static void runline(struct Token *line)
}
while (pc.token->type != T_EOL ||
Program_skipEOL(&program, &pc, STDCHANNEL, 1));
- FS_allowIntr(0);
}
static struct Value *evalGeometry(struct Value *value, unsigned int *dim, unsigned int geometry[])
@@ -1843,12 +1840,7 @@ more:
else
return Value_new_ERROR(value, MISSINGSTATEMENT);
- if (FS_intr)
- {
- stopped = 1;
- return Value_new_ERROR(value, BREAK);
- }
- else if (pc.token->type == T_COLON && (pc.token + 1)->type == T_ELSE)
+ if (pc.token->type == T_COLON && (pc.token + 1)->type == T_ELSE)
++pc.token;
else if ((pc.token->type == T_COLON && (pc.token + 1)->type != T_ELSE) ||
pc.token->type == T_QUOTE)
@@ -1951,9 +1943,7 @@ void bas_interpreter(void)
struct Token *line;
struct String s;
- FS_intr = 0;
stopped = 0;
- FS_allowIntr(1);
FS_nextline(STDCHANNEL);
if (FS_istty(STDCHANNEL))
FS_putChars(STDCHANNEL, "> ");
@@ -1961,20 +1951,10 @@ void bas_interpreter(void)
String_new(&s);
if (FS_appendToString(STDCHANNEL, &s, 1) == -1)
{
- if (FS_intr)
- {
- FS_putChars(STDCHANNEL, _("\nBreak\n"));
- FS_flush(STDCHANNEL);
- String_destroy(&s);
- continue;
- }
- else
- {
- FS_putChars(STDCHANNEL, FS_errmsg);
- FS_flush(STDCHANNEL);
- String_destroy(&s);
- break;
- }
+ FS_putChars(STDCHANNEL, FS_errmsg);
+ FS_flush(STDCHANNEL);
+ String_destroy(&s);
+ break;
}
if (s.length == 0)
{
@@ -2029,7 +2009,6 @@ void bas_interpreter(void)
else
Token_destroy(line);
}
- FS_allowIntr(0);
}
void bas_exit(void)
diff --git a/apps/interpreters/bas/config.h b/apps/interpreters/bas/config.h
index 7912f4d67..9572b11c8 100644
--- a/apps/interpreters/bas/config.h
+++ b/apps/interpreters/bas/config.h
@@ -5,9 +5,6 @@
/* The package name. */
#define PACKAGE "bas"
-/* Do you have tgetent()? */
-/* #undef HAVE_TGETENT */
-
/* Should we need to include termcap.h? */
/* #undef HAVE_TERMCAP_H */
diff --git a/apps/interpreters/bas/fs.c b/apps/interpreters/bas/fs.c
index ad67982de..f4302e55d 100644
--- a/apps/interpreters/bas/fs.c
+++ b/apps/interpreters/bas/fs.c
@@ -113,41 +113,10 @@
static struct FileStream **file;
static int capacity;
static int used;
-#ifdef CONFIG_SERIAL_TERMIOS
-static struct termios origMode;
-#endif
-static struct termios rawMode;
static const int open_mode[4] = { 0, O_RDONLY, O_WRONLY, O_RDWR };
-#ifdef CONFIG_INTERPRETER_BAS_HAVE_SIGINT
-static struct sigaction old_sigint;
-#endif
-#ifdef CONFIG_INTERPRETER_BAS_HAVE_SIGQUIT
-static struct sigaction old_sigquit;
-#endif
-#ifdef CONFIG_SERIAL_TERMIOS
-static int termchannel;
-#endif
-
const char *FS_errmsg;
static char FS_errmsgbuf[80];
-volatile int FS_intr;
-
-#ifdef HAVE_TGETENT
-static char *term;
-static char entrybuf[2048];
-static char *cap;
-static char *cl;
-static char *cm;
-static char *ce;
-static char *cr;
-static char *md;
-static char *me;
-static char *AF;
-static char *AB;
-static int Co;
-static int NC;
-#endif
/****************************************************************************
* Private Functions
@@ -327,24 +296,11 @@ static int edit(int chn, int onl)
return -1;
}
- if (ch == rawMode.c_cc[VERASE])
- {
- if (f->inCapacity)
- {
- if (f->inBuf[f->inCapacity - 1] >= '\0' &&
- f->inBuf[f->inCapacity - 1] < ' ')
- {
- FS_putChars(chn, "\b\b \b\b");
- }
- else
- {
- FS_putChars(chn, "\b \b");
- }
-
- --f->inCapacity;
- }
- }
- else if ((f->inCapacity + 1) < sizeof(f->inBuf))
+#ifdef CONFIG_INTERPREPTER_BAS_VT100
+ /* REVISIT: Use VT100 commands to erase */
+#warning Missing Logic
+#else
+ if ((f->inCapacity + 1) < sizeof(f->inBuf))
{
if (ch != '\n')
{
@@ -365,273 +321,52 @@ static int edit(int chn, int onl)
f->inBuf[f->inCapacity++] = ch;
}
- }
- while (ch != '\n');
-
- return 0;
-}
-
-#if defined(HAVE_TGETENT) || defined(CONFIG_SERIAL_TERMIOS)
-static int outc(int ch)
-{
- struct FileStream *f;
-
- if (opened(termchannel, 0) == -1)
- {
- return -1;
- }
-
- f = file[termchannel];
- if (f->outSize + 1 >= f->outCapacity && FS_flush(termchannel) == -1)
- {
- return -1;
- }
-
- f->outBuf[f->outSize++] = ch;
- FS_errmsg = (const char *)0;
- return ch;
-}
#endif
-
-#ifdef HAVE_TGETENT
-static int mytputs(const char *str, int affcnt, int (*out) (int))
-{
-# ifdef TPUTS_RETURNS_VOID
- tputs(str, affcnt, out);
- return 0;
-# else
- return tputs(str, affcnt, out);
-# endif
-}
-
-#ifdef CONFIG_SERIAL_TERMIOS
-static int initTerminal(int chn)
-{
- static int init = 0;
-
- if (!init)
- {
- termchannel = chn;
- if ((term = getenv("TERM")) == (char *)0)
- {
- FS_errmsg = _("environment variable TERM is not set");
- return -1;
- }
-
- switch (tgetent(entrybuf, term))
- {
- case -1:
- {
- FS_errmsg = _("reading terminal description failed");
- return -1;
- }
-
- case 0:
- {
- sprintf(FS_errmsgbuf, _("unknown terminal type %s"), term);
- FS_errmsg = FS_errmsgbuf;
- return -1;
- }
-
- case 1:
- {
- cl = tgetstr("cl", &cap);
- cm = tgetstr("cm", &cap);
- ce = tgetstr("ce", &cap);
- cr = tgetstr("cr", &cap);
- md = tgetstr("md", &cap);
- me = tgetstr("me", &cap);
- AF = tgetstr("AF", &cap);
- AB = tgetstr("AB", &cap);
- Co = tgetnum("Co");
- if ((NC = tgetnum("NC")) == -1)
- {
- NC = 0;
- }
-
- return 0;
- }
- }
-
- init = 1;
- }
-
- return 0;
-}
-#endif /* CONFIG_SERIAL_TERMIOS */
-
-static int cls(int chn)
-{
- if (cl == (char *)0)
- {
- sprintf(FS_errmsgbuf,
- _("terminal type %s can not clear the screen"), term);
- FS_errmsg = FS_errmsgbuf;
- return -1;
- }
-
- if (mytputs(cl, 0, outc) == -1)
- {
- return -1;
- }
-
- return 0;
-}
-
-static int locate(int chn, int line, int column)
-{
- termchannel = chn;
- if (cm == (char *)0)
- {
- sprintf(FS_errmsgbuf,
- _("terminal type %s can not position the cursor"), term);
- FS_errmsg = FS_errmsgbuf;
- return -1;
- }
-
- if (mytputs(tgoto(cm, column - 1, line - 1), 0, outc) == -1)
- {
- return -1;
- }
-
- return 0;
-}
-
-static int colour(int chn, int foreground, int background)
-{
- if (AF && AB && Co >= 8)
- {
- static int map[8] = { 0, 4, 2, 6, 1, 5, 3, 7 };
-
- if (foreground != -1)
- {
- if (md && me && !(NC & 32))
- {
- if (foreground > 7 && file[chn]->outforeground <= 7)
- {
- if (mytputs(md, 0, outc) == -1)
- {
- return -1;
- }
-
- /* all attributes are gone now, need to set background
- * again */
-
- if (background == -1)
- {
- background = file[chn]->outbackground;
- }
- }
- else if (foreground <= 7 && file[chn]->outforeground > 7)
- {
- if (mytputs(me, 0, outc) == -1)
- {
- return -1;
- }
- }
- }
-
- if (mytputs(tgoto(AF, 0, map[foreground & 7]), 0, outc) == -1)
- {
- return -1;
- }
- }
-
- if (background != -1)
- {
- if (mytputs(tgoto(AB, 0, map[background & 7]), 0, outc) == -1)
- {
- return -1;
- }
- }
- }
-
- return 0;
-}
-
-static int resetcolour(int chn)
-{
- if (me)
- {
- mytputs(me, 0, outc);
- }
-
- if (ce)
- {
- mytputs(ce, 0, outc);
- }
-
- return 0;
-}
-
-#ifdef CONFIG_SERIAL_TERMIOS
-static void carriage_return(int chn)
-{
- if (cr)
- {
- mytputs(cr, 0, outc);
- }
- else
- {
- outc('\r');
}
+ while (ch != '\n');
- outc('\n');
-}
-#endif /* CONFIG_SERIAL_TERMIOS */
-
-#else /* HAVE_TGETENT */
-
-#ifdef CONFIG_SERIAL_TERMIOS
-static int initTerminal(int chn)
-{
- termchannel = chn;
return 0;
}
-#endif /* CONFIG_SERIAL_TERMIOS */
static int cls(int chn)
{
- FS_errmsg = _("This installation does not support terminal handling");
+#ifdef CONFIG_INTERPREPTER_BAS_VT100
+ /* REVISIT: Use VT100 commands to clear the screen */
+#warning Missing Logic
+#endif
+ FS_errmsg = _("Clear screen operation not implemented");
return -1;
}
static int locate(int chn, int line, int column)
{
- FS_errmsg = _("This installation does not support terminal handling");
+#ifdef CONFIG_INTERPREPTER_BAS_VT100
+ /* REVISIT: Use VT100 commands to set the cursor position */
+#warning Missing Logic
+#endif
+ FS_errmsg = _("Set cursor position operation not implement");
return -1;
}
static int colour(int chn, int foreground, int background)
{
- FS_errmsg = _("This installation does not support terminal handling");
+#ifdef CONFIG_INTERPREPTER_BAS_VT100
+ /* REVISIT: Use VT100 commands to color */
+#warning Missing Logic
+#endif
+ FS_errmsg = _("Set color operation no implemented");
return -1;
}
static int resetcolour(int chn)
{
+#ifdef CONFIG_INTERPREPTER_BAS_VT100
+ /* REVISIT: Use VT100 commands to reset color */
+#warning Missing Logic
+#endif
return 0;
}
-#ifdef CONFIG_SERIAL_TERMIOS
-static void carriage_return(int chn)
-{
- outc('\r');
- outc('\n');
-}
-#endif /* CONFIG_SERIAL_TERMIOS */
-
-#endif /* HAVE_TGETENT */
-
-#ifdef CONFIG_INTERPRETER_BAS_HAVE_SIGINT
-static void sigintr(int sig)
-{
- FS_intr = 1;
- FS_allowIntr(0);
-}
-
-#endif
-
/****************************************************************************
* Public Functions
****************************************************************************/
@@ -651,38 +386,11 @@ int FS_opendev(int chn, int infd, int outfd)
file[chn] = malloc(sizeof(struct FileStream));
file[chn]->dev = 1;
-
#ifdef CONFIG_SERIAL_TERMIOS
- if ((file[chn]->tty = (infd == 0 ? isatty(infd) && isatty(outfd) : 0)))
- {
- if (tcgetattr(infd, &origMode) == -1)
- {
- FS_errmsg = strerror(errno);
- free(file[chn]);
- file[chn] = (struct FileStream *)0;
- return -1;
- }
-
- rawMode = origMode;
- rawMode.c_lflag &= ~(ICANON | ECHO); /* IEXTEN would disable IUCLC,
- * breaking UC only terminals */
- rawMode.c_cc[VMIN] = 1;
- rawMode.c_cc[VTIME] = 0;
- rawMode.c_oflag &= ~ONLCR;
- if (tcsetattr(infd, TCSADRAIN, &rawMode) == -1)
- {
- FS_errmsg = strerror(errno);
- free(file[chn]);
- file[chn] = (struct FileStream *)0;
- return -1;
- }
-
- initTerminal(chn);
- }
+ file[chn]->tty = (infd == 0 ? isatty(infd) && isatty(outfd) : 0);
#else
file[chn]->tty = 1;
#endif
-
file[chn]->recLength = 1;
file[chn]->infd = infd;
file[chn]->inSize = 0;
@@ -1043,13 +751,6 @@ int FS_close(int dev)
close(file[dev]->binaryfd);
}
-#ifdef CONFIG_SERIAL_TERMIOS
- if (file[dev]->tty)
- {
- tcsetattr(file[dev]->infd, TCSADRAIN, &origMode);
- }
-#endif
-
if (file[dev]->infd >= 0)
{
close(file[dev]->infd);
@@ -1163,64 +864,15 @@ int FS_truncate(int chn)
void FS_shellmode(int dev)
{
-#if defined(CONFIG_INTERPRETER_BAS_HAVE_SIGINT) || defined(CONFIG_INTERPRETER_BAS_HAVE_SIGQUIT)
- struct sigaction interrupt;
-#endif
-
-#ifdef CONFIG_SERIAL_TERMIOS
- if (file[dev]->tty)
- {
- tcsetattr(file[dev]->infd, TCSADRAIN, &origMode);
- }
-#endif
-
-#if defined(CONFIG_INTERPRETER_BAS_HAVE_SIGINT) || defined(CONFIG_INTERPRETER_BAS_HAVE_SIGQUIT)
- interrupt.sa_flags = 0;
- sigemptyset(&interrupt.sa_mask);
- interrupt.sa_handler = SIG_IGN;
-# ifdef CONFIG_INTERPRETER_BAS_HAVE_SIGINT
- sigaction(SIGINT, &interrupt, &old_sigint);
-# endif
-# ifdef CONFIG_INTERPRETER_BAS_HAVE_SIGQUIT
- sigaction(SIGQUIT, &interrupt, &old_sigquit);
-# endif
-#endif
}
void FS_fsmode(int chn)
{
-#ifdef CONFIG_SERIAL_TERMIOS
- if (file[chn]->tty)
- {
- tcsetattr(file[chn]->infd, TCSADRAIN, &rawMode);
- }
-#endif
-
-#ifdef CONFIG_INTERPRETER_BAS_HAVE_SIGINT
- sigaction(SIGINT, &old_sigint, (struct sigaction *)0);
-#endif
-#ifdef CONFIG_INTERPRETER_BAS_HAVE_SIGQUIT
- sigaction(SIGQUIT, &old_sigquit, (struct sigaction *)0);
-#endif
}
void FS_xonxoff(int chn, int on)
{
-#ifdef CONFIG_SERIAL_TERMIOS
- if (file[chn]->tty)
- {
- if (on)
- {
- rawMode.c_iflag |= (IXON | IXOFF);
- }
- else
- {
- rawMode.c_iflag &= ~(IXON | IXOFF);
- }
-
- tcsetattr(file[chn]->infd, TCSADRAIN, &rawMode);
- }
-#endif
+ /* Not implemented */
}
int FS_put(int chn)
@@ -1280,30 +932,11 @@ int FS_putChar(int dev, char ch)
if (f->outLineWidth && f->outPos == f->outLineWidth)
{
-#ifdef CONFIG_SERIAL_TERMIOS
- if (FS_istty(dev))
- {
- carriage_return(dev);
- }
- else
-#endif
- {
- f->outBuf[f->outSize++] = '\n';
- }
-
+ f->outBuf[f->outSize++] = '\n';
f->outPos = 0;
}
-#ifdef CONFIG_SERIAL_TERMIOS
- if (FS_istty(dev) && ch == '\n')
- {
- carriage_return(dev);
- }
- else
-#endif
- {
- f->outBuf[f->outSize++] = ch;
- }
+ f->outBuf[f->outSize++] = ch;
if (ch != '\n' && ch != '\b')
{
@@ -1767,8 +1400,6 @@ int FS_inkeyChar(int dev, int ms)
#ifdef USE_SELECT
fd_set just_infd;
struct timeval timeout;
-#elif defined(CONFIG_SERIAL_TERMIOS)
- struct termios timedread;
#endif
if (opened(dev, 1) == -1)
@@ -1815,24 +1446,9 @@ int FS_inkeyChar(int dev, int ms)
return 0;
#else
-#ifdef CONFIG_SERIAL_TERMIOS
- timedread = rawMode;
- timedread.c_cc[VMIN] = 0;
- timedread.c_cc[VTIME] = (ms ? ms : 100) / 100;
- if (tcsetattr(f->infd, TCSADRAIN, &timedread) == -1)
- {
- FS_errmsg = strerror(errno);
- return -1;
- }
-#endif
-
FS_errmsg = (const char *)0;
len = read(f->infd, &c, 1);
-#ifdef CONFIG_SERIAL_TERMIOS
- tcsetattr(f->infd, TCSADRAIN, &rawMode);
-#endif
-
if (len == -1)
{
FS_errmsg = strerror(errno);
@@ -2223,16 +1839,3 @@ int FS_memOutput(int address, int value)
FS_errmsg = _("Direct memory access not available");
return -1;
}
-
-void FS_allowIntr(int on)
-{
-#ifdef CONFIG_INTERPRETER_BAS_HAVE_SIGINT
- struct sigaction breakact;
-
- breakact.sa_handler = on ? sigintr : SIG_IGN;
- sigemptyset(&breakact.sa_mask);
- sigaddset(&breakact.sa_mask, SIGINT);
- breakact.sa_flags = 0;
- sigaction(SIGINT, &breakact, (struct sigaction *)0);
-#endif
-}
diff --git a/apps/interpreters/bas/fs.h b/apps/interpreters/bas/fs.h
index 1b00ea25f..5dd1027f9 100644
--- a/apps/interpreters/bas/fs.h
+++ b/apps/interpreters/bas/fs.h
@@ -55,7 +55,6 @@ struct FileStream
#define FS_LOCK_EXCLUSIVE 2
extern const char *FS_errmsg;
-extern volatile int FS_intr;
extern int FS_opendev(int dev, int infd, int outfd);
extern int FS_openin(const char *name);
@@ -116,6 +115,5 @@ extern int FS_portInput(int address);
extern int FS_memInput(int address);
extern int FS_portOutput(int address, int value);
extern int FS_memOutput(int address, int value);
-extern void FS_allowIntr(int on);
#endif
diff --git a/apps/interpreters/bas/program.c b/apps/interpreters/bas/program.c
index 900016063..f24318979 100644
--- a/apps/interpreters/bas/program.c
+++ b/apps/interpreters/bas/program.c
@@ -749,7 +749,8 @@ struct Value *Program_list(struct Program *this, int dev, int watchIntr,
{
return Value_new_ERROR(value, IOERROR, FS_errmsg);
}
- if (watchIntr && FS_intr)
+
+ if (watchIntr)
{
return Value_new_ERROR(value, BREAK);
}
diff --git a/apps/interpreters/bas/statement.c b/apps/interpreters/bas/statement.c
index 774adee6f..3279e6c9b 100644
--- a/apps/interpreters/bas/statement.c
+++ b/apps/interpreters/bas/statement.c
@@ -2972,10 +2972,10 @@ struct Value *stmt_OPTIONRUN(struct Value *value)
{
++pc.token;
if (pass==INTERPRET)
- {
- FS_allowIntr(0);
- FS_xonxoff(STDCHANNEL,0);
- }
+ {
+ FS_xonxoff(STDCHANNEL,0);
+ }
+
return (struct Value*)0;
}
@@ -2983,10 +2983,10 @@ struct Value *stmt_OPTIONSTOP(struct Value *value)
{
++pc.token;
if (pass==INTERPRET)
- {
- FS_allowIntr(1);
- FS_xonxoff(STDCHANNEL,1);
- }
+ {
+ FS_xonxoff(STDCHANNEL,1);
+ }
+
return (struct Value*)0;
}
@@ -3706,11 +3706,11 @@ struct Value *stmt_SLEEP(struct Value *value)
struct Value *stmt_STOP(struct Value *value)
{
- if (pass==INTERPRET) FS_intr=1;
- else
- {
- ++pc.token;
- }
+ if (pass!=INTERPRET)
+ {
+ ++pc.token;
+ }
+
return (struct Value*)0;
}