diff options
| author | Clecio Jung | 2023-03-18 18:02:41 -0300 |
|---|---|---|
| committer | Clecio Jung | 2023-03-18 18:02:41 -0300 |
| commit | a3942b3241189a003414874a96732e373e63ccae (patch) | |
| tree | 32df11e16faaecb62b1b407ab49490dffe546cec /examples/ini_file_read.c | |
| download | libini-a3942b3241189a003414874a96732e373e63ccae.tar.xz libini-a3942b3241189a003414874a96732e373e63ccae.tar.zst | |
Initial commit
Diffstat (limited to 'examples/ini_file_read.c')
| -rw-r--r-- | examples/ini_file_read.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/examples/ini_file_read.c b/examples/ini_file_read.c new file mode 100644 index 0000000..7752f36 --- /dev/null +++ b/examples/ini_file_read.c @@ -0,0 +1,41 @@ +/*------------------------------------------------------------------------------ + * SOURCE + *------------------------------------------------------------------------------ + */ + +#include <stdio.h> +#include <stdlib.h> + +#include "../ini_file.h" + +int error_callback(const char *const filename, const size_t line_number, const char *const line, const enum Ini_File_Errors error) { + fprintf(stderr, "%s:%lu %s:\n%s\n", filename, line_number, ini_file_error_to_string(error), line); + return 0; +} + +/*------------------------------------------------------------------------------ + * MAIN + *------------------------------------------------------------------------------ + */ + +int main(const int argc, const char **const argv) { + struct Ini_File *ini_file; + if (argc < 2) { + fprintf(stderr, "Usage: %s ini_file_name\n", argv[0]); + return EXIT_FAILURE; + } + ini_file = ini_file_parse(argv[1], error_callback); + if (ini_file == NULL) { + fprintf(stderr, "Was not possible to parse the ini_file \"%s\"\n", argv[1]); + return EXIT_FAILURE; + } + printf("\nThe properties retrieved from the the ini file \"%s\" are:\n\n", argv[1]); + ini_file_print_to(ini_file, stdout); + ini_file_free(ini_file); + return EXIT_SUCCESS; +} + +/*------------------------------------------------------------------------------ + * END + *------------------------------------------------------------------------------ + */ |
