-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomp.c
More file actions
33 lines (26 loc) · 664 Bytes
/
comp.c
File metadata and controls
33 lines (26 loc) · 664 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_LINE 1024
int main(void) {
FILE *f = fopen("compile.conf", "r");
if (!f) {
perror("compile.conf");
return 1;
}
char line[MAX_LINE];
while (fgets(line, sizeof(line), f)) {
line[strcspn(line, "\n")] = 0;
if (line[0] == '\0' || line[0] == '#')
continue; // skip empty lines and comments
printf("Running: %s\n", line);
int ret = system(line);
if (ret != 0) {
fprintf(stderr, "Failed: %s\n", line);
fclose(f);
return 1;
}
}
fclose(f);
return 0;
}