WIP
This commit is contained in:
@ -15,6 +15,8 @@
|
||||
#include <util/util.h>
|
||||
#include "interp.h"
|
||||
|
||||
uint64_t PID;
|
||||
|
||||
struct {
|
||||
char *modestr;
|
||||
enum { MODE_INTERACTIVE = 1, MODE_RUNFILE = 2 } mode;
|
||||
@ -68,7 +70,8 @@ void do_file(char *filepath) {
|
||||
LOG(LOG_ERR, "%s is not a file (%d)\n", filepath, statbuf.type);
|
||||
return;
|
||||
}
|
||||
uint8_t *buf = dlmalloc(statbuf.size);
|
||||
uint8_t *buf = dlmalloc(statbuf.size+1);
|
||||
string_memset(buf, 0, statbuf.size+1);
|
||||
|
||||
if ((ret = ioctl(ioh, IOCTL_READ, (uint64_t)buf, statbuf.size, 0)) < 0) {
|
||||
LOG(LOG_ERR, "Could not read %s (%d): %s\n", filepath, ioh, ERRSTRING(ioh));
|
||||
@ -76,7 +79,7 @@ void do_file(char *filepath) {
|
||||
}
|
||||
|
||||
InterpResult *res;
|
||||
bool ok = interp_runstring((const char *)buf, statbuf.size, &res);
|
||||
bool ok = interp_runstring((const char *)buf, &res);
|
||||
if (!ok) {
|
||||
uprintf("Interpreter error:\n");
|
||||
uprintf("%s\n", res->errmsg);
|
||||
@ -105,10 +108,16 @@ void do_mode_interactive(void) {
|
||||
}
|
||||
linebuf[cursor - 1] = '\0';
|
||||
uprintf("\n");
|
||||
InterpResult *res;
|
||||
if (!interp_runstring(linebuf, &res)) {
|
||||
LOG(LOG_ERR, "%s\n", res->errmsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void main(void) {
|
||||
PID = processctl(-1, PCTL_GETPID, 0, 0, 0);
|
||||
|
||||
set_config();
|
||||
|
||||
if (CONFIG.mode == MODE_INTERACTIVE) {
|
||||
|
Reference in New Issue
Block a user