From 3ee35c7f23dc0058fa3a2efbbffd5540e71ab712 Mon Sep 17 00:00:00 2001 From: Luka Jankovic Date: Sat, 26 Jul 2025 22:09:01 +0200 Subject: [PATCH] reading file --- kubo_command.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/kubo_command.c b/kubo_command.c index 2543163..68eae67 100644 --- a/kubo_command.c +++ b/kubo_command.c @@ -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); +}