Second commit

This commit is contained in:
Ur Mom 2024-05-14 22:32:44 +02:00
parent 20ef894f88
commit 027b54d087
1 changed files with 43 additions and 7 deletions

View File

@ -7,19 +7,44 @@
extern FILE *yyin; extern FILE *yyin;
// Global array to store options
char options[5][10];
int num_options = 0;
/** /**
* @brief Log a debug message to inform about beginning exit procedures * @brief Log a debug message to inform about beginning exit procedures
* *
*/ */
void notify_exit(void) { DEBUG("Exiting gemstone..."); } void notify_exit(void) { DEBUG("Exiting gemstone..."); }
/**
* @brief add option to global option array
*
*/
void add_option(const char* option) {
if (num_options < 5 ) {
strcpy(options[num_options], option);
num_options++;
} else {
PANIC("Too Many Options given");
}
}
/**
* @brief Check if Option is set
*
*/
size_t check_option(const char* name) { size_t check_option(const char* name) {
if (0 != name){ for (int i = 0; i < num_options; i++) {
if (strcmp(options[i], name) == 0) {
return 1; return 1;
} else { }
}
return 0; return 0;
}; }
};
/** /**
* @brief Closes File after compiling. * @brief Closes File after compiling.
@ -38,7 +63,6 @@ void close_file(void) {
*/ */
void setup(void) { void setup(void) {
// setup preample // setup preample
log_init(); log_init();
DEBUG("starting gemstone..."); DEBUG("starting gemstone...");
@ -54,6 +78,18 @@ void setup(void) {
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
// Iteration through arguments
for (int i = 1; i < argc; i++) {
// Check if the argument starts with "--"
if (argv[i][0] == '-' && argv[i][1] == '-') {
// Extract option name
char option[10];
strcpy(option, argv[i] + 2);
// Add option to the global array
add_option(option);
}
}
setup(); setup();
atexit(close_file); atexit(close_file);