/*
* Copyright (C) 2026 Joshua Vega
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see .
*/
#include
#include
#include
#include
#include "config.h"
#define ARG_L_CONFIG_PATH "--config"
#define ARG_S_CONFIG_PATH "-c"
#define ARG_LEN_L_CONFIG_PATH 8
#define ARG_LEN_S_CONFIG_PATH 2
Config *config = NULL;
int parseArguments(int, char **);
void printHelp(void);
int main(int argc, char **argv) {
if (parseArguments(argc, argv) != 0) {
printHelp();
return 0;
}
return 0;
}
int parseArguments(int argc, char **argv) {
char configPath[1024];
size_t configPathLength = 0;
bool expectConfigPath = false;
for (int argIndex = 1; argIndex < argc; argIndex++) {
const char *arg = argv[argIndex];
if (expectConfigPath) {
size_t length = strlen(arg);
if (length > 1024) {
return 1;
}
memcpy(configPath, arg, length);
configPath[length] = '\0';
configPathLength = length + 1;
printf("Loading config %s\n", configPath);
expectConfigPath = false;
continue;
}
if (!expectConfigPath &&
(strncmp(arg, ARG_L_CONFIG_PATH, ARG_LEN_L_CONFIG_PATH) ||
strncmp(arg, ARG_S_CONFIG_PATH, ARG_LEN_S_CONFIG_PATH))) {
printf("Encountered config path argument.\n");
expectConfigPath = true;
} else {
return 1;
}
}
if (loadConfigFromFile(configPath, configPathLength, &config) != 0) {
return -1;
}
return 0;
}
void printHelp(void) {
/* TODO */
}