add modified parser
This commit is contained in:
parent
faebe3def0
commit
56fb016254
@ -23,6 +23,6 @@
|
|||||||
int checkForRoot();
|
int checkForRoot();
|
||||||
char checkForEmkFile();
|
char checkForEmkFile();
|
||||||
char readEmkFile();
|
char readEmkFile();
|
||||||
char includeFromConfig();
|
char includeConfig();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
24
src/parse.c
24
src/parse.c
@ -69,32 +69,38 @@ char readEmkFile() {
|
|||||||
fclose(emkfile);
|
fclose(emkfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
char includeFromConfig() {
|
char includeConfig() {
|
||||||
char cwd[PATH_MAX];
|
char cwd[PATH_MAX];
|
||||||
FILE *emkconfig, *emkfile;
|
file *emkconfig, *emkfile, *emkfile_new;
|
||||||
char filename[100], contents;
|
char filename[100], contents;
|
||||||
|
|
||||||
emkconfig = fopen(EMKCONFIG, "r");
|
emkconfig = fopen(EMKCONFIG, "r");
|
||||||
if (emkconfig == NULL) {
|
emkfile = fopen(EMKFILE, "r");
|
||||||
printf(COL_BLUE "INF" COL_RESET " | no config.emk found\n");
|
|
||||||
} else if (getcwd(cwd, sizeof(cwd)) != NULL) {
|
|
||||||
printf(COL_BLUE "INF" COL_RESET " | including config.emk at %s\n", cwd);
|
|
||||||
}
|
|
||||||
|
|
||||||
emkfile = fopen(EMKFILE, "w");
|
emkfile_new = fopen(EMKFILE_NEW, "a+");
|
||||||
|
|
||||||
|
/* write emkconfig to new emkfile */
|
||||||
contents = fgetc(emkconfig);
|
contents = fgetc(emkconfig);
|
||||||
while (contents != EOF) {
|
while (contents != EOF) {
|
||||||
fputc(contents, emkfile);
|
fputc(contents, emkfile_new);
|
||||||
contents = fgetc(emkconfig);
|
contents = fgetc(emkconfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* write emkfile to new emkfile */
|
||||||
|
contents = fgetc(emkfile):
|
||||||
|
while (contents != EOF) {
|
||||||
|
fputc(contents, emkfile_new);
|
||||||
|
contents = fgetc(emkfile);
|
||||||
|
}
|
||||||
|
|
||||||
fclose(emkconfig);
|
fclose(emkconfig);
|
||||||
fclose(emkfile);
|
fclose(emkfile);
|
||||||
|
fclose(emkfile_new);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
checkForEmkFile();
|
checkForEmkFile();
|
||||||
readEmkFile();
|
readEmkFile();
|
||||||
checkForRoot();
|
checkForRoot();
|
||||||
|
includeConfig();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user