add modified parser
This commit is contained in:
parent
faebe3def0
commit
56fb016254
@ -23,6 +23,6 @@
|
||||
int checkForRoot();
|
||||
char checkForEmkFile();
|
||||
char readEmkFile();
|
||||
char includeFromConfig();
|
||||
char includeConfig();
|
||||
|
||||
#endif
|
||||
|
24
src/parse.c
24
src/parse.c
@ -69,32 +69,38 @@ char readEmkFile() {
|
||||
fclose(emkfile);
|
||||
}
|
||||
|
||||
char includeFromConfig() {
|
||||
char includeConfig() {
|
||||
char cwd[PATH_MAX];
|
||||
FILE *emkconfig, *emkfile;
|
||||
file *emkconfig, *emkfile, *emkfile_new;
|
||||
char filename[100], contents;
|
||||
|
||||
emkconfig = fopen(EMKCONFIG, "r");
|
||||
if (emkconfig == NULL) {
|
||||
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, "r");
|
||||
|
||||
emkfile = fopen(EMKFILE, "w");
|
||||
emkfile_new = fopen(EMKFILE_NEW, "a+");
|
||||
|
||||
/* write emkconfig to new emkfile */
|
||||
contents = fgetc(emkconfig);
|
||||
while (contents != EOF) {
|
||||
fputc(contents, emkfile);
|
||||
fputc(contents, emkfile_new);
|
||||
contents = fgetc(emkconfig);
|
||||
}
|
||||
|
||||
/* write emkfile to new emkfile */
|
||||
contents = fgetc(emkfile):
|
||||
while (contents != EOF) {
|
||||
fputc(contents, emkfile_new);
|
||||
contents = fgetc(emkfile);
|
||||
}
|
||||
|
||||
fclose(emkconfig);
|
||||
fclose(emkfile);
|
||||
fclose(emkfile_new);
|
||||
}
|
||||
|
||||
int main() {
|
||||
checkForEmkFile();
|
||||
readEmkFile();
|
||||
checkForRoot();
|
||||
includeConfig();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user