reading file
This commit is contained in:
parent
d273544702
commit
3ee35c7f23
1 changed files with 16 additions and 2 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue