/* * Copyright (c) 2026, Apollo Telephone Laboratories. * Provided under the BSD-3 clause. */ #include #include #include #include #include "defconf/state.h" #include "defconf/parser.h" /* Globals */ static char *config_path = NULL; static void help(void) { printf("usage: ./defconf [flags]\n"); printf("[-h] Display this help menu\n"); printf("[-c] Target config file\n"); } static int defconf_run(void) { struct defconf_state state; int error; error = defconf_state_init(config_path, &state); if (error < 0) { return error; } /* Begin parsing the config */ if ((error = parse_begin(&state)) < 0) { defconf_state_destroy(&state); return error; } defconf_state_destroy(&state); return 0; } int main(int argc, char **argv) { int opt, retval; if (argc < 2) { printf("fatal: too few arguments\n"); help(); return -1; } while ((opt = getopt(argc, argv, "hc:")) != -1) { switch (opt) { case 'h': help(); return -1; case 'c': if ((config_path = strdup(optarg)) == NULL) { printf("fatal: out of memory\n"); return -1; } break; } } if (config_path == NULL) { printf("fatal: expected config path\n"); return -1; } retval = defconf_run(); free(config_path); return retval; }