aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorprofkhaos <profkhaos@Khaos-Phantom.(none)>2009-08-13 19:54:17 +0300
committerprofkhaos <profkhaos@Khaos-Phantom.(none)>2009-08-13 19:54:17 +0300
commitd1dfdca844d2108fa2f3612ee651250a01f1e319 (patch)
treec0e394cf708e4ad29d76323ee532688b3bed0114
parent7ab9b993d4c89b2f35f02d7b15bf33d78650fc69 (diff)
downloadsyslinux-d1dfdca844d2108fa2f3612ee651250a01f1e319.tar.gz
syslinux-d1dfdca844d2108fa2f3612ee651250a01f1e319.tar.xz
syslinux-d1dfdca844d2108fa2f3612ee651250a01f1e319.zip
Integrated command line into core
-rw-r--r--com32/elflink/modules/ansiraw.c1
-rw-r--r--com32/elflink/modules/cli.h6
-rw-r--r--com32/elflink/modules/menu.h4
-rw-r--r--com32/elflink/modules/menumain.c202
-rw-r--r--com32/elflink/modules/mytest.c2
-rw-r--r--com32/menu/menumain.c2
-rw-r--r--core/elflink/cli.c225
-rw-r--r--core/elflink/cli.h7
-rw-r--r--core/elflink/get_key.c174
-rw-r--r--core/elflink/getkey.h80
-rw-r--r--core/elflink/load_env32.c18
-rw-r--r--core/elflink/menu.h2
12 files changed, 499 insertions, 224 deletions
diff --git a/com32/elflink/modules/ansiraw.c b/com32/elflink/modules/ansiraw.c
index d37922f5..b50b47f0 100644
--- a/com32/elflink/modules/ansiraw.c
+++ b/com32/elflink/modules/ansiraw.c
@@ -47,6 +47,7 @@ static int ansiraw_init()
void console_ansi_raw(void)
{
openconsole(&dev_rawcon_r, &dev_ansiserial_w);
+ printf("hmmm 2\n");
}
static void ansiraw_exit()
diff --git a/com32/elflink/modules/cli.h b/com32/elflink/modules/cli.h
new file mode 100644
index 00000000..6c5815d0
--- /dev/null
+++ b/com32/elflink/modules/cli.h
@@ -0,0 +1,6 @@
+#ifndef CLI_H
+#define CLI_H
+
+extern const char *edit_cmdline(const char *input, int top);
+
+#endif
diff --git a/com32/elflink/modules/menu.h b/com32/elflink/modules/menu.h
index 1d7dee80..3bdf2d45 100644
--- a/com32/elflink/modules/menu.h
+++ b/com32/elflink/modules/menu.h
@@ -26,6 +26,7 @@
#include <unistd.h>
#include <colortbl.h>
#include <stdbool.h>
+#include <setjmp.h>
#include "refstr.h"
#ifndef CLK_TCK
@@ -178,9 +179,10 @@ extern struct menu *root_menu, *start_menu, *hide_menu, *menu_list;
extern int shiftkey;
extern int hiddenmenu;
extern long long totaltimeout;
+jmp_buf timeout_jump;
void parse_configs(char **argv);
-int draw_background(const char *filename);
+extern int draw_background(const char *filename);
static inline int my_isspace(char c)
{
diff --git a/com32/elflink/modules/menumain.c b/com32/elflink/modules/menumain.c
index 2e4e74d7..30cd2d07 100644
--- a/com32/elflink/modules/menumain.c
+++ b/com32/elflink/modules/menumain.c
@@ -32,6 +32,7 @@
#include <sys/module.h>
#include "menu.h"
+#include "cli.h"
static int menumain_init()
{
@@ -178,42 +179,6 @@ static void draw_row(int y, int sel, int top, int sbtop, int sbbot)
}
}
-static jmp_buf timeout_jump;
-
-int mygetkey(clock_t timeout)
-{
- clock_t t0, t;
- clock_t tto, to;
- int key;
-
- if (!totaltimeout)
- return get_key(stdin, timeout);
-
- for (;;) {
- tto = min(totaltimeout, INT_MAX);
- to = timeout ? min(tto, timeout) : tto;
-
- t0 = times(NULL);
- key = get_key(stdin, to);
- t = times(NULL) - t0;
-
- if (totaltimeout <= t)
- longjmp(timeout_jump, 1);
-
- totaltimeout -= t;
-
- if (key != KEY_NONE)
- return key;
-
- if (timeout) {
- if (timeout <= t)
- return KEY_NONE;
-
- timeout -= t;
- }
- }
-}
-
int show_message_file(const char *filename, const char *background)
{
int rv = KEY_NONE;
@@ -465,172 +430,7 @@ static void show_fkey(int key)
}
}
-static const char *edit_cmdline(const char *input, int top)
-{
- static char cmdline[MAX_CMDLINE_LEN];
- int key, len, prev_len, cursor;
- int redraw = 1; /* We enter with the menu already drawn */
-
- strncpy(cmdline, input, MAX_CMDLINE_LEN);
- cmdline[MAX_CMDLINE_LEN - 1] = '\0';
-
- len = cursor = strlen(cmdline);
- prev_len = 0;
-
- for (;;) {
- if (redraw > 1) {
- /* Clear and redraw whole screen */
- /* Enable ASCII on G0 and DEC VT on G1; do it in this order
- to avoid confusing the Linux console */
- clear_screen();
- draw_menu(-1, top, 1);
- prev_len = 0;
- }
-
- if (redraw > 0) {
- /* Redraw the command line */
- printf("\033[?25l\033[%d;1H\1#9> \2#10%s",
- CMDLINE_ROW, pad_line(cmdline, 0, max(len, prev_len)));
- printf("\2#10\033[%d;3H%s\033[?25h",
- CMDLINE_ROW, pad_line(cmdline, 0, cursor));
- prev_len = len;
- redraw = 0;
- }
-
- key = mygetkey(0);
-
- switch (key) {
- case KEY_CTRL('L'):
- redraw = 2;
- break;
-
- case KEY_ENTER:
- case KEY_CTRL('J'):
- return cmdline;
-
- case KEY_ESC:
- case KEY_CTRL('C'):
- return NULL;
-
- case KEY_BACKSPACE:
- case KEY_DEL:
- if (cursor) {
- memmove(cmdline + cursor - 1, cmdline + cursor,
- len - cursor + 1);
- len--;
- cursor--;
- redraw = 1;
- }
- break;
-
- case KEY_CTRL('D'):
- case KEY_DELETE:
- if (cursor < len) {
- memmove(cmdline + cursor, cmdline + cursor + 1, len - cursor);
- len--;
- redraw = 1;
- }
- break;
-
- case KEY_CTRL('U'):
- if (len) {
- len = cursor = 0;
- cmdline[len] = '\0';
- redraw = 1;
- }
- break;
-
- case KEY_CTRL('W'):
- if (cursor) {
- int prevcursor = cursor;
-
- while (cursor && my_isspace(cmdline[cursor - 1]))
- cursor--;
-
- while (cursor && !my_isspace(cmdline[cursor - 1]))
- cursor--;
-
- memmove(cmdline + cursor, cmdline + prevcursor,
- len - prevcursor + 1);
- len -= (cursor - prevcursor);
- redraw = 1;
- }
- break;
-
- case KEY_LEFT:
- case KEY_CTRL('B'):
- if (cursor) {
- cursor--;
- redraw = 1;
- }
- break;
- case KEY_RIGHT:
- case KEY_CTRL('F'):
- if (cursor < len) {
- putchar(cmdline[cursor++]);
- }
- break;
-
- case KEY_CTRL('K'):
- if (cursor < len) {
- cmdline[len = cursor] = '\0';
- redraw = 1;
- }
- break;
-
- case KEY_HOME:
- case KEY_CTRL('A'):
- if (cursor) {
- cursor = 0;
- redraw = 1;
- }
- break;
-
- case KEY_END:
- case KEY_CTRL('E'):
- if (cursor != len) {
- cursor = len;
- redraw = 1;
- }
- break;
-
- case KEY_F1:
- case KEY_F2:
- case KEY_F3:
- case KEY_F4:
- case KEY_F5:
- case KEY_F6:
- case KEY_F7:
- case KEY_F8:
- case KEY_F9:
- case KEY_F10:
- case KEY_F11:
- case KEY_F12:
- show_fkey(key);
- redraw = 1;
- break;
-
- default:
- if (key >= ' ' && key <= 0xFF && len < MAX_CMDLINE_LEN - 1) {
- if (cursor == len) {
- cmdline[len] = key;
- cmdline[++len] = '\0';
- cursor++;
- putchar(key);
- prev_len++;
- } else {
- memmove(cmdline + cursor + 1, cmdline + cursor,
- len - cursor + 1);
- cmdline[cursor++] = key;
- len++;
- redraw = 1;
- }
- }
- break;
- }
- }
-}
static inline int shift_is_held(void)
{
diff --git a/com32/elflink/modules/mytest.c b/com32/elflink/modules/mytest.c
index 7bf7a6f5..309a90ca 100644
--- a/com32/elflink/modules/mytest.c
+++ b/com32/elflink/modules/mytest.c
@@ -21,6 +21,8 @@
static int mytest_main(int argc, char **argv)
{
console_ansi_raw();
+ printf("hmmm\n");
+ edit_cmdline("hello",1);
menu_main(argc, argv);
return 0;
}
diff --git a/com32/menu/menumain.c b/com32/menu/menumain.c
index 82f0018c..f74e224f 100644
--- a/com32/menu/menumain.c
+++ b/com32/menu/menumain.c
@@ -440,7 +440,7 @@ static void show_fkey(int key)
}
}
-static const char *edit_cmdline(const char *input, int top)
+const char *edit_cmdline(const char *input, int top)
{
static char cmdline[MAX_CMDLINE_LEN];
int key, len, prev_len, cursor;
diff --git a/core/elflink/cli.c b/core/elflink/cli.c
index 8dfa88ff..78076b64 100644
--- a/core/elflink/cli.c
+++ b/core/elflink/cli.c
@@ -1,23 +1,218 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <console.h>
+#include <com32.h>
+#include <syslinux/adv.h>
+#include <syslinux/config.h>
+#include <setjmp.h>
+#include <netinet/in.h>
+#include <limits.h>
+#include <minmax.h>
+#include "getkey.h"
+
+#include "common.h"
#include "menu.h"
+#include "cli.h"
-void enter_cmdline(char * cmdline)
+int mygetkey(clock_t timeout)
{
- int cmdlen;
- kernel_type kt=KT_NONE;
- fgets(cmdline,MAX_CMDLINE_LEN,stdin);
- if((cmdlen=strlen(cmdline))<=3) execute(cmdline,KT_NONE);
- else
- {
- if(!strcmp(cmdline,".com")) 1;
- else if(!strcmp(cmdline,".cbt")) 1;
- else if(!strcmp(cmdline,".c32")) 1;
- else if(!strcmp(cmdline,".bs")) 1;
- else if(!strcmp(cmdline,".0")) 1;
- else if(!strcmp(cmdline,".bin")) 1;
- else if(!strcmp(cmdline,".bss")) 1;
- else if(!strcmp(cmdline,".img")) 1;
+ clock_t t0, t;
+ clock_t tto, to;
+ int key;
+
+ if (!totaltimeout)
+ return get_key(stdin, timeout);
+
+ for (;;) {
+ tto = min(totaltimeout, INT_MAX);
+ to = timeout ? min(tto, timeout) : tto;
+
+ t0 = times(NULL);
+ key = get_key(stdin, to);
+ t = times(NULL) - t0;
+
+ if (totaltimeout <= t)
+ longjmp(timeout_jump, 1);
+
+ totaltimeout -= t;
+
+ if (key != KEY_NONE)
+ return key;
+
+ if (timeout) {
+ if (timeout <= t)
+ return KEY_NONE;
+
+ timeout -= t;
+ }
+ }
+}
+
+const char *edit_cmdline(const char *input, int top)
+{
+ static char cmdline[MAX_CMDLINE_LEN];
+ int key, len, prev_len, cursor;
+ int redraw = 1; /* We enter with the menu already drawn */
+
+ strncpy(cmdline, input, MAX_CMDLINE_LEN);
+ cmdline[MAX_CMDLINE_LEN - 1] = '\0';
+
+ len = cursor = strlen(cmdline);
+ prev_len = 0;
+
+ for (;;) {
+ if (redraw > 1) {
+ /* Clear and redraw whole screen */
+ /* Enable ASCII on G0 and DEC VT on G1; do it in this order
+ to avoid confusing the Linux console */
+ /* clear_screen();
+ draw_menu(-1, top, 1);
+ prev_len = 0;*/
+ }
+
+ if (redraw > 0) {
+ /* Redraw the command line */
+ /* printf("\033[?25l\033[%d;1H\1#9> \2#10%s",
+ CMDLINE_ROW, pad_line(cmdline, 0, max(len, prev_len)));
+ printf("\2#10\033[%d;3H%s\033[?25h",
+ CMDLINE_ROW, pad_line(cmdline, 0, cursor));
+ prev_len = len;
+ redraw = 0;*/
+ }
+
+ key = mygetkey(0);
+
+ switch (key) {
+ case KEY_CTRL('L'):
+ redraw = 2;
+ break;
+
+ case KEY_ENTER:
+ case KEY_CTRL('J'):
+ return cmdline;
+
+ case KEY_ESC:
+ case KEY_CTRL('C'):
+ return NULL;
+
+ case KEY_BACKSPACE:
+ case KEY_DEL:
+ if (cursor) {
+ memmove(cmdline + cursor - 1, cmdline + cursor,
+ len - cursor + 1);
+ len--;
+ cursor--;
+ redraw = 1;
+ }
+ break;
+
+ case KEY_CTRL('D'):
+ case KEY_DELETE:
+ if (cursor < len) {
+ memmove(cmdline + cursor, cmdline + cursor + 1, len - cursor);
+ len--;
+ redraw = 1;
+ }
+ break;
+
+ case KEY_CTRL('U'):
+ if (len) {
+ len = cursor = 0;
+ cmdline[len] = '\0';
+ redraw = 1;
+ }
+ break;
+
+ case KEY_CTRL('W'):
+ if (cursor) {
+ int prevcursor = cursor;
+
+ while (cursor && my_isspace(cmdline[cursor - 1]))
+ cursor--;
+
+ while (cursor && !my_isspace(cmdline[cursor - 1]))
+ cursor--;
+
+ memmove(cmdline + cursor, cmdline + prevcursor,
+ len - prevcursor + 1);
+ len -= (cursor - prevcursor);
+ redraw = 1;
+ }
+ break;
+
+ case KEY_LEFT:
+ case KEY_CTRL('B'):
+ if (cursor) {
+ cursor--;
+ redraw = 1;
+ }
+ break;
+
+ case KEY_RIGHT:
+ case KEY_CTRL('F'):
+ if (cursor < len) {
+ putchar(cmdline[cursor++]);
+ }
+ break;
+
+ case KEY_CTRL('K'):
+ if (cursor < len) {
+ cmdline[len = cursor] = '\0';
+ redraw = 1;
+ }
+ break;
+
+ case KEY_HOME:
+ case KEY_CTRL('A'):
+ if (cursor) {
+ cursor = 0;
+ redraw = 1;
+ }
+ break;
+
+ case KEY_END:
+ case KEY_CTRL('E'):
+ if (cursor != len) {
+ cursor = len;
+ redraw = 1;
+ }
+ break;
+
+ case KEY_F1:
+ case KEY_F2:
+ case KEY_F3:
+ case KEY_F4:
+ case KEY_F5:
+ case KEY_F6:
+ case KEY_F7:
+ case KEY_F8:
+ case KEY_F9:
+ case KEY_F10:
+ case KEY_F11:
+ case KEY_F12:
+ //show_fkey(key);
+ redraw = 1;
+ break;
+
+ default:
+ if (key >= ' ' && key <= 0xFF && len < MAX_CMDLINE_LEN - 1) {
+ if (cursor == len) {
+ cmdline[len] = key;
+ cmdline[++len] = '\0';
+ cursor++;
+ putchar(key);
+ prev_len++;
+ } else {
+ memmove(cmdline + cursor + 1, cmdline + cursor,
+ len - cursor + 1);
+ cmdline[cursor++] = key;
+ len++;
+ redraw = 1;
+ }
+ }
+ break;
}
+ }
}
+
diff --git a/core/elflink/cli.h b/core/elflink/cli.h
new file mode 100644
index 00000000..de27ed4b
--- /dev/null
+++ b/core/elflink/cli.h
@@ -0,0 +1,7 @@
+#ifndef CLI_H
+#define CLI_H
+
+extern int mygetkey(clock_t timeout);
+extern const char *edit_cmdline(const char *input, int top);
+
+#endif
diff --git a/core/elflink/get_key.c b/core/elflink/get_key.c
new file mode 100644
index 00000000..bed1ac20
--- /dev/null
+++ b/core/elflink/get_key.c
@@ -0,0 +1,174 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2004-2008 H. Peter Anvin - All Rights Reserved
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall
+ * be included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * ----------------------------------------------------------------------- */
+
+/*
+ * get_key.c
+ *
+ * Get a single key, and try to pick apart function key codes.
+ * This doesn't decode anywhere close to all possiblities, but
+ * hopefully is enough to be useful.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+#include <time.h>
+#include <sys/times.h>
+#include <sys/module.h>
+#include "getkey.h"
+
+struct keycode {
+ int code;
+ int seqlen;
+ const unsigned char *seq;
+};
+
+#define MAXLEN 8
+#define CODE(x,y) { x, (sizeof y)-1, y }
+
+static const struct keycode keycodes[] = {
+ /* First, the BIOS combined codes */
+ CODE(KEY_F1, "\0\x3B"),
+ CODE(KEY_F2, "\0\x3C"),
+ CODE(KEY_F3, "\0\x3D"),
+ CODE(KEY_F4, "\0\x3E"),
+ CODE(KEY_F5, "\0\x3F"),
+ CODE(KEY_F6, "\0\x40"),
+ CODE(KEY_F7, "\0\x41"),
+ CODE(KEY_F8, "\0\x42"),
+ CODE(KEY_F9, "\0\x43"),
+ CODE(KEY_F10, "\0\x44"),
+ CODE(KEY_F11, "\0\x85"),
+ CODE(KEY_F12, "\0\x86"),
+
+ CODE(KEY_UP, "\0\x48"),
+ CODE(KEY_DOWN, "\0\x50"),
+ CODE(KEY_LEFT, "\0\x4B"),
+ CODE(KEY_RIGHT, "\0\x4D"),
+ CODE(KEY_PGUP, "\0\x49"),
+ CODE(KEY_PGDN, "\0\x51"),
+ CODE(KEY_HOME, "\0\x47"),
+ CODE(KEY_END, "\0\x4F"),
+ CODE(KEY_INSERT, "\0\x52"),
+ CODE(KEY_DELETE, "\0\x53"),
+
+ /* Now, VT/xterm/Linux codes */
+ CODE(KEY_F1, "\033[[A"),
+ CODE(KEY_F1, "\033OP"),
+ CODE(KEY_F2, "\033[[B"),
+ CODE(KEY_F2, "\033OQ"),
+ CODE(KEY_F3, "\033[[C"),
+ CODE(KEY_F3, "\033OR"),
+ CODE(KEY_F4, "\033[[D"),
+ CODE(KEY_F4, "\033OS"),
+ CODE(KEY_F5, "\033[[E"),
+ CODE(KEY_F5, "\033[15~"),
+ CODE(KEY_F6, "\033[17~"),
+ CODE(KEY_F7, "\033[18~"),
+ CODE(KEY_F8, "\033[19~"),
+ CODE(KEY_F9, "\033[20~"),
+ CODE(KEY_F10, "\033[21~"),
+ CODE(KEY_F11, "\033[23~"),
+ CODE(KEY_F12, "\033[24~"),
+
+ CODE(KEY_UP, "\033[A"),
+ CODE(KEY_DOWN, "\033[B"),
+ CODE(KEY_LEFT, "\033[D"),
+ CODE(KEY_RIGHT, "\033[C"),
+ CODE(KEY_PGUP, "\033[5~"),
+ CODE(KEY_PGUP, "\033[V"),
+ CODE(KEY_PGDN, "\033[6~"),
+ CODE(KEY_PGDN, "\033[U"),
+ CODE(KEY_HOME, "\033[1~"),
+ CODE(KEY_HOME, "\033[H"),
+ CODE(KEY_END, "\033[4~"),
+ CODE(KEY_END, "\033[F"),
+ CODE(KEY_END, "\033OF"),
+ CODE(KEY_INSERT, "\033[2~"),
+ CODE(KEY_INSERT, "\033[@"),
+ CODE(KEY_DELETE, "\033[3~"),
+};
+
+#define NCODES ((int)(sizeof keycodes/sizeof(struct keycode)))
+
+#define KEY_TIMEOUT ((CLK_TCK+9)/10)
+
+int get_key(FILE * f, clock_t timeout)
+{
+ unsigned char buffer[MAXLEN];
+ int nc, i, rv;
+ const struct keycode *kc;
+ int another;
+ unsigned char ch;
+ clock_t start;
+
+ /* We typically start in the middle of a clock tick */
+ if (timeout)
+ timeout++;
+
+ nc = 0;
+ start = times(NULL);
+ do {
+ rv = read(fileno(f), &ch, 1);
+ if (rv == 0 || (rv == -1 && errno == EAGAIN)) {
+ clock_t lateness = times(NULL) - start;
+ if (nc && lateness > 1 + KEY_TIMEOUT) {
+ if (nc == 1)
+ return buffer[0]; /* timeout in sequence */
+ else if (timeout && lateness > timeout)
+ return KEY_NONE;
+ } else if (!nc && timeout && lateness > timeout)
+ return KEY_NONE; /* timeout before sequence */
+
+ syslinux_idle();
+
+ another = 1;
+ continue;
+ }
+
+ start = times(NULL);
+
+ buffer[nc++] = ch;
+
+ another = 0;
+ for (i = 0, kc = keycodes; i < NCODES; i++, kc++) {
+ if (nc == kc->seqlen && !memcmp(buffer, kc->seq, nc))
+ return kc->code;
+ else if (nc < kc->seqlen && !memcmp(buffer, kc->seq, nc)) {
+ another = 1;
+ break;
+ }
+ }
+ } while (another);
+
+ /* We got an unrecognized sequence; return the first character */
+ /* We really should remember this and return subsequent characters later */
+ return buffer[0];
+}
+
+
diff --git a/core/elflink/getkey.h b/core/elflink/getkey.h
new file mode 100644
index 00000000..52312a25
--- /dev/null
+++ b/core/elflink/getkey.h
@@ -0,0 +1,80 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2004-2008 H. Peter Anvin - All Rights Reserved
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall
+ * be included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * ----------------------------------------------------------------------- */
+
+/*
+ * getkey.h
+ *
+ * Function to get a key symbol and parse it
+ */
+
+#ifndef LIBUTIL_GETKEY_H
+#define LIBUTIL_GETKEY_H
+
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/times.h>
+
+#ifndef CLK_TCK
+# define CLK_TCK sysconf(_SC_CLK_TCK)
+#endif
+
+#define KEY_NONE (-1)
+
+#define KEY_CTRL(x) ((x) & 0x001f)
+#define KEY_BACKSPACE 0x0008
+#define KEY_TAB 0x0009
+#define KEY_ENTER 0x000d
+#define KEY_ESC 0x001b
+#define KEY_DEL 0x007f
+
+#define KEY_F1 0x0100
+#define KEY_F2 0x0101
+#define KEY_F3 0x0102
+#define KEY_F4 0x0103
+#define KEY_F5 0x0104
+#define KEY_F6 0x0105
+#define KEY_F7 0x0106
+#define KEY_F8 0x0107
+#define KEY_F9 0x0108
+#define KEY_F10 0x0109
+#define KEY_F11 0x010A
+#define KEY_F12 0x010B
+
+#define KEY_UP 0x0120
+#define KEY_DOWN 0x0121
+#define KEY_LEFT 0x0122
+#define KEY_RIGHT 0x0123
+#define KEY_PGUP 0x0124
+#define KEY_PGDN 0x0125
+#define KEY_HOME 0x0126
+#define KEY_END 0x0127
+#define KEY_INSERT 0x0128
+#define KEY_DELETE 0x0129
+
+int get_key(FILE *, clock_t);
+
+#endif /* LIBUTIL_GETKEY_H */
diff --git a/core/elflink/load_env32.c b/core/elflink/load_env32.c
index 7f072f5b..5211d131 100644
--- a/core/elflink/load_env32.c
+++ b/core/elflink/load_env32.c
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
+#include <unistd.h>
#include <string.h>
#include <console.h>
#include <com32.h>
@@ -12,6 +13,7 @@
#include <sys/module.h>
#include "common.h"
#include "menu.h"
+#include "cli.h"
typedef void (*constructor_t)(void);
constructor_t __ctors_start[], __ctors_end[];
@@ -67,9 +69,11 @@ static void call_constr()
/* note to self: do _*NOT*_ use static key word on this function */
void load_env32(com32sys_t * regs)
{
- openconsole(&dev_stdcon_r, &dev_stdcon_w);
- printf("Calling initilization constructor procedures...\n");
call_constr();
+ char *cmdline;
+ //openconsole(&dev_stdcon_r, &dev_stdcon_w);
+ openconsole(&dev_rawcon_r, &dev_ansiserial_w);
+ printf("Calling initilization constructor procedures...\n");
printf("Starting 32 bit elf module subsystem...\n");
init_module_subsystem(&core_module);
@@ -78,6 +82,10 @@ void load_env32(com32sys_t * regs)
printf("Str table size: %d\n",core_module.strtable_size);
printf("Sym table size: %d\n",core_module.symtable_size);
+ cmdline=edit_cmdline("hello",1);
+ //printf("%s\n",cmdline);
+ //fgets(cmdline,100,stdin);
+
int i,n=5;
char **argv;
argv=(char**)calloc(n,sizeof(char*));
@@ -87,9 +95,8 @@ void load_env32(com32sys_t * regs)
strcpy(argv[0],"extlinux.conf");
strcpy(argv[1],"extlinux.conf");
- /*printf("\nBegin dynamic module test ...\n");
- printf("\n\nTrying to laod 'dyn/sort.dyn'\n\n");*/
printf("%d\n",load_library("dyn/sort.dyn"));
+ printf("Loading ansiraw.c32\n%d\n",load_library("dyn/ansiraw.c32"));
printf("Loading background.c32\n%d\n",load_library("dyn/background.c32"));
printf("Loading printmsg.c32\n%d\n",load_library("dyn/printmsg.c32"));
printf("Loading drain.c32\n%d\n",load_library("dyn/drain.c32"));
@@ -102,14 +109,13 @@ void load_env32(com32sys_t * regs)
printf("Loading passwd.c32\n%d\n",load_library("dyn/passwd.c32"));
printf("Loading get_key.c32\n%d\n",load_library("dyn/get_key.c32"));
printf("Loading menumain.c32\n%d\n",load_library("dyn/menumain.c32"));
- printf("Loading ansiraw.c32\n%d\n",load_library("dyn/ansiraw.c32"));
/*printf("\n\nTrying to spawn 'dyn/hello.dyn'\n\n");
spawnv("dyn/hello.dyn",0);
printf("\nTest done\n");*/
//printf("%d\n",spawnv("mytest.c32",argv));
spawnl("mytest.c32", "mytest",(regs->edi.w[0]), NULL);
- printf("Done\n");
+ //printf("Done\n");
while(1) 1; /* we don't have anything better to do so hang around for a bit */
}
diff --git a/core/elflink/menu.h b/core/elflink/menu.h
index 5e696425..3bdf2d45 100644
--- a/core/elflink/menu.h
+++ b/core/elflink/menu.h
@@ -26,6 +26,7 @@
#include <unistd.h>
#include <colortbl.h>
#include <stdbool.h>
+#include <setjmp.h>
#include "refstr.h"
#ifndef CLK_TCK
@@ -178,6 +179,7 @@ extern struct menu *root_menu, *start_menu, *hide_menu, *menu_list;
extern int shiftkey;
extern int hiddenmenu;
extern long long totaltimeout;
+jmp_buf timeout_jump;
void parse_configs(char **argv);
extern int draw_background(const char *filename);