reading file

This commit is contained in:
Luka Jankovic 2025-07-26 22:09:01 +02:00
parent d273544702
commit 3ee35c7f23

View file

@ -20,9 +20,12 @@
static inline void kubo_command_exit(struct kubo_context *context, char *rest);
static inline void kubo_command_write(struct kubo_context *context, char *rest);
static inline void kubo_command_read(struct kubo_context *context, char *rest);
static const struct kubo_command_data kubo_commands[] = {
{":q", kubo_command_exit}, {":w", kubo_command_write}};
{":q", kubo_command_exit},
{":w", kubo_command_write},
{":e", kubo_command_read}};
static const size_t kubo_commands_size =
sizeof(kubo_commands) / sizeof(kubo_commands[0]);
@ -63,10 +66,21 @@ static inline void kubo_command_exit(struct kubo_context *context, char *rest) {
context->exit_pending = true;
}
static inline void kubo_command_write(struct kubo_context *context, char *rest) {
static inline void kubo_command_write(struct kubo_context *context,
char *rest) {
if (rest) {
context->file_name = rest;
}
kubo_file_write(context);
}
static inline void kubo_command_read(struct kubo_context *context, char *rest) {
if (rest) {
context->file_name = rest;
} else {
return;
}
*context = kubo_file_parse(rest);
}