feat(main_loop): Wrote the base of the main entrypoint. Implemented a helper which converts the args options to iob_context
This commit is contained in:
parent
83b7374583
commit
f71d0a2183
3 changed files with 89 additions and 5 deletions
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "utils/args/args.h"
|
||||
|
||||
static struct iob_context context;
|
||||
static FILE *input;
|
||||
|
||||
|
|
@ -33,3 +35,28 @@ int iob_init(struct iob_context *ctx)
|
|||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int iob_config_from_args(struct args_options *args, struct iob_context *ctx)
|
||||
{
|
||||
switch (args->type)
|
||||
{
|
||||
case INPUT_STDIN:
|
||||
ctx->mode = IOB_MODE_STDIN;
|
||||
ctx->args = NULL;
|
||||
break;
|
||||
|
||||
case INPUT_FILE:
|
||||
ctx->mode = IOB_MODE_SCRIPT;
|
||||
ctx->args = (char *)args->input_source;
|
||||
break;
|
||||
|
||||
case INPUT_CMD:
|
||||
ctx->mode = IOB_MODE_CMD;
|
||||
ctx->args = NULL;
|
||||
break;
|
||||
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -23,6 +23,14 @@ struct iob_context
|
|||
char *args;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Converts struct arg_options to iob_context
|
||||
*
|
||||
* @param args The arguments options struct
|
||||
* @param ctx The IO Backend context struct to populate
|
||||
* @return int 0 on success, negative value on error
|
||||
*/
|
||||
int iob_config_from_args(struct args_options *args, struct iob_context *ctx);
|
||||
/*
|
||||
* @brief Initializes the IO Backend module
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue