aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/main.c b/main.c
index fcfbbd0..4b68fb4 100644
--- a/main.c
+++ b/main.c
@@ -30,21 +30,21 @@ void *f1_newer(void *arg) {
pthread_exit(&ret);
}
-void *create_make() {
- /* Create simple makefile */
- int fd = creat("makefile", 00644);
+void *create_template(void *arg) {
+ /* Create simple main.c and makefile boilerplate */
+ char *path = (char *) arg;
+ int fd = creat(path, 00644);
FILE *file = fdopen(fd, "w");
- fprintf(file, "debug: main.c\n\tgcc -Wall main.c -o ./bin/debug\nrelease: main.c\n\tgcc -O2 -march=native main.c -o ./bin/release");
- fclose(file);
-
- return NULL;
-}
+ switch(path[2]) {
+ case 'i':
+ fprintf(file, "#include <stdio.h>\n\nint main() {\n\tprintf(\"Hello world\\n\");\n}");
+ break;
+ case 'k':
+ fprintf(file, "debug: main.c\n\tgcc -Wall main.c -o ./bin/debug\nrelease: main.c\n\tgcc -O2 -march=native main.c -o ./bin/release");
+ break;
+ default: break;
+ }
-void *create_src() {
- /* Create simple main.c */
- int fd = creat("main.c", 00644);
- FILE *file = fdopen(fd, "w");
- fprintf(file, "#include <stdio.h>\n\nint main() {\n\tprintf(\"Hello world\\n\");\n}");
fclose(file);
return NULL;
@@ -55,8 +55,8 @@ void new(char *argv[]) {
mkdir(name, 0777);
chdir(name);
pthread_t s_thread, m_thread;
- pthread_create(&s_thread, NULL, create_src, NULL);
- pthread_create(&m_thread, NULL, create_make, NULL);
+ pthread_create(&s_thread, NULL, create_template, (void *) "main.c");
+ pthread_create(&m_thread, NULL, create_template, (void *) "makefile");
pthread_join(s_thread, NULL);
pthread_join(m_thread, NULL);
@@ -94,7 +94,7 @@ int main(int argc, char *argv[]) {
* check age of source vs. bin
*/
pthread_t f_thread, check_thread;
- pthread_create(&f_thread, NULL, create_make, NULL);
+ pthread_create(&f_thread, NULL, create_template, (void *) "makefile");
pthread_create(&check_thread, NULL, f1_newer, (void *)&files);
mkdir("./bin", 0777);