updated main.c
This commit is contained in:
parent
cebe5c5bf4
commit
72bba3278a
17
src/main.c
17
src/main.c
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
#define LOG_LEVEL LOG_LEVEL_DEBUG
|
#define LOG_LEVEL LOG_LEVEL_DEBUG
|
||||||
|
|
||||||
|
extern FILE* yyin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Log a debug message to inform about beginning exit procedures
|
* @brief Log a debug message to inform about beginning exit procedures
|
||||||
*
|
*
|
||||||
|
@ -18,9 +20,12 @@ void notify_exit(void)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void close_file(char file_to_close)
|
void close_file(void)
|
||||||
{
|
{
|
||||||
fclose(file_to_close);
|
if (NULL != yyin)
|
||||||
|
{
|
||||||
|
fclose(yyin);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,7 +51,7 @@ void setup(void)
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
setup();
|
setup();
|
||||||
atexit(close_file(filename));
|
atexit(close_file);
|
||||||
|
|
||||||
// Check for file input as argument
|
// Check for file input as argument
|
||||||
if (2 != argc)
|
if (2 != argc)
|
||||||
|
@ -58,13 +63,13 @@ int main(int argc, char *argv[]) {
|
||||||
// filename as first argument
|
// filename as first argument
|
||||||
char *filename = argv[1];
|
char *filename = argv[1];
|
||||||
|
|
||||||
|
FILE *file = fopen(filename, "r");
|
||||||
|
|
||||||
if (NULL == file)
|
if (NULL == file)
|
||||||
{
|
{
|
||||||
PANIC("File couldn't be opened!");
|
PANIC("File couldn't be opened!");
|
||||||
}
|
}
|
||||||
|
yyin = file;
|
||||||
FILE *file = fopen(filename, "r");
|
|
||||||
*file = yyin;
|
|
||||||
|
|
||||||
yyparse();
|
yyparse();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue