-/* $OpenBSD: cmd.c,v 1.2 1997/03/31 23:06:21 mickey Exp $ */
+/* $OpenBSD: cmd.c,v 1.3 1997/04/01 04:50:33 mickey Exp $ */
/*
* Copyright (c) 1997 Michael Shalayeff
#include <sys/param.h>
#include <string.h>
#include <libsa.h>
+#include <debug.h>
#include "cmd.h"
#ifndef _TEST
#include <biosdev.h>
extern int debug;
+#define CTRL(c) ((c)&0x1f)
+
const struct cmd_table {
char *cmd_name;
int cmd_id;
{"ls", CMD_LS},
{"nope", CMD_NOPE},
{"reboot", CMD_REBOOT},
+ {"regs", CMD_REGS},
{"set", CMD_SET},
{NULL, 0},
};
}
static int
-readline(p, to)
- register char *p;
+readline(buf, to)
+ register char *buf;
int to;
{
- char *buf = p, ch;
+ char *p = buf, *pe = buf, ch;
int i;
for (i = to; i-- && !ischar(); )
while (1) {
switch (ch = getchar()) {
+ case CTRL('u'):
+ while (pe > buf) {
+ pe--;
+ putchar('\b');
+ putchar(' ');
+ putchar('\b');
+ }
+ p = pe = buf;
+ continue;
case '\n':
- p[1] = *p = '\0';
+ pe[1] = *pe = '\0';
break;
case '\b':
if (p > buf) {
putchar(' ');
putchar('\b');
p--;
+ pe--;
}
continue;
default:
+ pe++;
*p++ = ch;
continue;
}
break;
}
- return p - buf;
+
+ return pe - buf;
}
char *
cmd->rc = -1;
break;
+ case CMD_REGS:
+ DUMP_REGS;
+ break;
+
case CMD_BOOT:
if (cmd->argc > 1)
strncpy(cmd->path, cmd->argv[1], sizeof(cmd->path));
-/* $OpenBSD: cmd.h,v 1.2 1997/03/31 23:06:21 mickey Exp $ */
+/* $OpenBSD: cmd.h,v 1.3 1997/04/01 04:50:33 mickey Exp $ */
/*
* Copyright (c) 1997 Michael Shalayeff
enum { CMD_ADDR, CMD_BOOT, CMD_CD, CMD_DEVICE, CMD_DEBUG, CMD_HELP,
CMD_IMAGE, CMD_LS, CMD_NOPE, CMD_REBOOT, CMD_SET,
+ CMD_REGS,
CMD_ERROR /* last !!! */
} cmd;
int argc;
-/* $OpenBSD: cmd.c,v 1.2 1997/03/31 23:06:21 mickey Exp $ */
+/* $OpenBSD: cmd.c,v 1.3 1997/04/01 04:50:33 mickey Exp $ */
/*
* Copyright (c) 1997 Michael Shalayeff
#include <sys/param.h>
#include <string.h>
#include <libsa.h>
+#include <debug.h>
#include "cmd.h"
#ifndef _TEST
#include <biosdev.h>
extern int debug;
+#define CTRL(c) ((c)&0x1f)
+
const struct cmd_table {
char *cmd_name;
int cmd_id;
{"ls", CMD_LS},
{"nope", CMD_NOPE},
{"reboot", CMD_REBOOT},
+ {"regs", CMD_REGS},
{"set", CMD_SET},
{NULL, 0},
};
}
static int
-readline(p, to)
- register char *p;
+readline(buf, to)
+ register char *buf;
int to;
{
- char *buf = p, ch;
+ char *p = buf, *pe = buf, ch;
int i;
for (i = to; i-- && !ischar(); )
while (1) {
switch (ch = getchar()) {
+ case CTRL('u'):
+ while (pe > buf) {
+ pe--;
+ putchar('\b');
+ putchar(' ');
+ putchar('\b');
+ }
+ p = pe = buf;
+ continue;
case '\n':
- p[1] = *p = '\0';
+ pe[1] = *pe = '\0';
break;
case '\b':
if (p > buf) {
putchar(' ');
putchar('\b');
p--;
+ pe--;
}
continue;
default:
+ pe++;
*p++ = ch;
continue;
}
break;
}
- return p - buf;
+
+ return pe - buf;
}
char *
cmd->rc = -1;
break;
+ case CMD_REGS:
+ DUMP_REGS;
+ break;
+
case CMD_BOOT:
if (cmd->argc > 1)
strncpy(cmd->path, cmd->argv[1], sizeof(cmd->path));
-/* $OpenBSD: cmd.h,v 1.2 1997/03/31 23:06:21 mickey Exp $ */
+/* $OpenBSD: cmd.h,v 1.3 1997/04/01 04:50:33 mickey Exp $ */
/*
* Copyright (c) 1997 Michael Shalayeff
enum { CMD_ADDR, CMD_BOOT, CMD_CD, CMD_DEVICE, CMD_DEBUG, CMD_HELP,
CMD_IMAGE, CMD_LS, CMD_NOPE, CMD_REBOOT, CMD_SET,
+ CMD_REGS,
CMD_ERROR /* last !!! */
} cmd;
int argc;