Get rid of writefmt functions

This commit is contained in:
2025-09-28 20:10:41 +02:00
parent 96ce9233ff
commit 1fd6c4e221
15 changed files with 80 additions and 262 deletions

View File

@ -32,7 +32,7 @@ void do_file(char *filepath);
void set_config(void) {
int32_t ret;
if ((ret = parse_args(args(), argslen(), ARGS)) < 0) {
writefmt("Could not parse args: {d}\n", ret);
uprintf("Could not parse args: %d\n", ret);
}
if (CONFIG.modestr != NULL) {
@ -57,7 +57,7 @@ void do_file(char *filepath) {
return;
}
IoctlStat statbuf = {0};
IoctlStat statbuf; ZERO(&statbuf);
ioctl(ioh, IOCTL_STAT, (uint64_t)&statbuf, 0, 0);
if (statbuf.type != IOCTLSTAT_FILE) {
@ -75,13 +75,13 @@ void do_file(char *filepath) {
InterpResult *res;
bool ok = interp_runstring((char *)buf, &res, CONFIG.logcmds, CONFIG.mode == MODE_INTERACTIVE);
if (!ok) {
writefmt("Interpreter error:\n");
writefmt("{s}\n", res->errmsg);
uprintf("Interpreter error:\n");
uprintf("%s\n", res->errmsg);
goto done;
}
done:
/* dlfree(buf); */
ufree(buf);
ioctl(ioh, IOCTL_CLOSEF, 0, 0, 0);
}
@ -90,7 +90,7 @@ void do_mode_interactive(void) {
size_t cursor;
for(;;) {
begin:
writefmt("tb# ");
uprintf("tb# ");
cursor = 0;
string_memset(linebuf, 0, LINEBUF_MAX);
@ -102,12 +102,12 @@ void do_mode_interactive(void) {
switch (b) {
case C('C'):
case 0xE9:
writefmt("\n");
uprintf("\n");
goto begin;
break;
case C('L'):
writefmt(ANSIQ_CUR_SET(0, 0));
writefmt(ANSIQ_SCR_CLR_ALL);
uprintf(ANSIQ_CUR_SET(0, 0));
uprintf(ANSIQ_SCR_CLR_ALL);
goto begin;
break;
}
@ -118,7 +118,7 @@ void do_mode_interactive(void) {
if (string_chr_isascii(b) && b != 0 && cursor < LINEBUF_MAX) {
linebuf[cursor++] = b;
writefmt("{c}", b);
uprintf("%c", b);
}
} else {
schedrelease();
@ -128,7 +128,7 @@ void do_mode_interactive(void) {
if (cursor < LINEBUF_MAX) {
linebuf[cursor] = '\0';
}
writefmt("\n");
uprintf("\n");
InterpResult *res;
if (!interp_runstring(linebuf, &res, CONFIG.logcmds, CONFIG.mode == MODE_INTERACTIVE)) {
LOG(LOG_ERR, "{s}\n", res->errmsg);
@ -150,7 +150,7 @@ void main(void) {
/* do_mode_interactive(); */
} else if (CONFIG.mode == MODE_RUNFILE) {
if (CONFIG.filepath == NULL) {
writefmt("No file provided\n");
uprintf("No file provided\n");
return;
}
do_file(CONFIG.filepath);