add more error checking to parse.c

This commit is contained in:
Liam Waldron 2023-05-04 13:03:46 -04:00
parent 03c2ae7681
commit 5e7706d2c2
2 changed files with 16 additions and 5 deletions

View File

@ -21,7 +21,7 @@
#define EMK_H_ #define EMK_H_
int checkForRoot(); int checkForRoot();
char checkForEmkFile(); char checkForFiles();
char readEmkFile(); char readEmkFile();
char includeConfig(); char includeConfig();

View File

@ -40,9 +40,9 @@ int checkForRoot() {
} }
} }
char checkForEmkFile() { char checkForFiles() {
char cwd[PATH_MAX]; char cwd[PATH_MAX];
FILE *emkfile; FILE *emkfile, *emkconfig;
emkfile = fopen(EMKFILE, "r"); emkfile = fopen(EMKFILE, "r");
if (emkfile == NULL) { if (emkfile == NULL) {
@ -52,6 +52,17 @@ char checkForEmkFile() {
printf(COL_BLUE "INF" COL_RESET " | using emkfile at %s/emkfile\n", cwd); printf(COL_BLUE "INF" COL_RESET " | using emkfile at %s/emkfile\n", cwd);
} }
fclose(emkfile); fclose(emkfile);
emkconfig = fopen(EMKCONFIG, "r");
if (emkconfig == NULL) {
printf(COL_YELLOW "WRN" COL_RESET " | config.emk does not exist\n");
printf(COL_YELLOW "WRN" COL_RESET " | it is highly recommended to\n");
printf(COL_YELLOW "WRN" COL_RESET " | use a config.emk file, rather\n");
printf(COL_YELLOW "WRN" COL_RESET " | than embedding settings directly\n");
printf(COL_YELLOW "WRN" COL_RESET " | within the emkfile.\n");
} else if (gwtcwd(cwd, sizeof(cwd)) != NULL) {
printf(COL_BLUE "INF" COL_RESET " | using config.emk at %s/config.emk\n", cwd);
}
} }
char readEmkFile() { char readEmkFile() {
@ -104,8 +115,8 @@ char includeConfig() {
} }
int main() { int main() {
checkForEmkFile(); checkForFiles();
readEmkFile(); /* readEmkFile(); */
checkForRoot(); checkForRoot();
includeConfig(); includeConfig();
} }