Files
mop3/ce/ce.c
kamkow1 bf1e8e8573
All checks were successful
Build documentation / build-and-deploy (push) Successful in 3m49s
libinput Generic way of gathering user commandline input
2026-03-20 18:04:26 +01:00

76 lines
1.4 KiB
C

#include "arena_alloc.h"
#include "context.h"
#include "interp.h"
#include "strbuf.h"
#include <arena.h>
#include <debugconsole.h>
#include <in_gb.h>
#include <in_input.h>
#include <malloc.h>
#include <mprintf.h>
#include <printf.h>
#include <process_self.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <system.h>
#define PROMPT "$ "
void* wmalloc (void* ctx, size_t size) {
(void)ctx;
return malloc (size);
}
void* wrealloc (void* ctx, void* mem, size_t old, size_t new) {
(void)ctx, (void)old;
return realloc (mem, new);
}
void wfree (void* ctx, void* mem) {
(void)ctx;
free (mem);
}
void* warena_malloc (void* ctx, size_t size) {
struct arena* a = ctx;
return arena_malloc (a, size);
}
void* warena_realloc (void* ctx, void* mem, size_t old, size_t new) {
struct arena* a = ctx;
return arena_realloc (a, mem, old, new);
}
void warena_free (void* ctx, void* mem) { (void)ctx, (void)mem; }
struct edit_line {
struct in_gb gb;
size_t cursor;
};
static void exec_line (const char* line) {
struct list_node_link* tokens = NULL;
tokenize (&tokens, line);
if (tokens != NULL)
parse_and_execute (tokens);
}
void app_main (void) {
libprocess_self_init ();
char line[1024];
while (interp_is_running ()) {
memset (line, 0, sizeof (line));
in_stream_read_line (PROMPT, line, sizeof (line) - 1);
if (line[0] != '\0')
exec_line (line);
}
}