2026-01-12 18:42:02 +00:00
|
|
|
#ifndef ARGS_H
|
|
|
|
|
#define ARGS_H
|
|
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
2026-01-12 19:30:11 +00:00
|
|
|
#include <stdio.h>
|
2026-01-12 18:42:02 +00:00
|
|
|
|
2026-01-23 17:05:56 +00:00
|
|
|
#include "../hash_map/hash_map.h"
|
|
|
|
|
|
2026-01-12 18:42:02 +00:00
|
|
|
enum input_type
|
|
|
|
|
{
|
|
|
|
|
INPUT_UNDEFINED,
|
|
|
|
|
INPUT_FILE,
|
|
|
|
|
INPUT_CMD,
|
|
|
|
|
INPUT_STDIN
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct args_options
|
|
|
|
|
{
|
|
|
|
|
/** Source of the input, filename or command string depending on type, NULL
|
|
|
|
|
* if INPUT_STDIN */
|
|
|
|
|
const char *input_source;
|
|
|
|
|
/** Type of the input source */
|
|
|
|
|
enum input_type type;
|
|
|
|
|
/** Enable or disable pretty printing of outputs */
|
|
|
|
|
bool pretty_print;
|
|
|
|
|
/** Enable or disable verbose mode */
|
|
|
|
|
bool verbose;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Handles command-line arguments and populates the args_options structure.
|
|
|
|
|
* @param argc The argument count.
|
|
|
|
|
* @param argv The argument vector.
|
|
|
|
|
* @param options Pointer to args_options structure to be populated.
|
2026-01-23 17:05:56 +00:00
|
|
|
* @param vars Pointer to the variables hash map.
|
2026-01-12 18:42:02 +00:00
|
|
|
* @return 0 on success, non-zero on failure.
|
|
|
|
|
*/
|
2026-01-23 17:05:56 +00:00
|
|
|
int args_handler(int argc, char **argv, struct args_options *options,
|
|
|
|
|
struct hash_map *vars);
|
2026-01-12 18:42:02 +00:00
|
|
|
|
|
|
|
|
/** Prints the parsed arguments for debugging purposes.
|
|
|
|
|
* @param options Pointer to args_options structure containing parsed options.
|
|
|
|
|
*/
|
|
|
|
|
void args_print(struct args_options *options);
|
|
|
|
|
|
2026-01-12 19:30:11 +00:00
|
|
|
/** Prints the usage information for the program.
|
|
|
|
|
* @param std The output stream to print to (e.g., stdout or stderr).
|
|
|
|
|
* @param program_name The name of the program.
|
|
|
|
|
*/
|
|
|
|
|
void print_usage(FILE *std, const char *program_name);
|
|
|
|
|
|
2026-01-12 18:42:02 +00:00
|
|
|
#endif /* ARGS_H */
|