]> Nishi Git Mirror - clover.git/commitdiff
kinda works
authornishi <nishi@cc13bd98-b292-b64a-ad22-c0789b689ca7>
Sun, 5 May 2024 04:47:29 +0000 (04:47 +0000)
committernishi <nishi@cc13bd98-b292-b64a-ad22-c0789b689ca7>
Sun, 5 May 2024 04:47:29 +0000 (04:47 +0000)
git-svn-id: file:///raid/svn-main/nishi-clover/trunk@4 cc13bd98-b292-b64a-ad22-c0789b689ca7

clover.c
clover.conf [new file with mode: 0644]

index 72bb1f80bab79a12ce65620b71cc6289a9cc93c0..e8307b1f35d16d2c95cb7e0be54131f3f48f25d9 100644 (file)
--- a/clover.c
+++ b/clover.c
@@ -1,6 +1,8 @@
 /* $Id$ */
 /* --- START LICENSE --- */
 /* -------------------------------------------------------------------------- */
+/*                                  HTML 2.0 compliant static site generator  */
+/* -------------------------------------------------------------------------- */
 /* Copyright (c) 2024 Nishi.                                                  */
 /* Redistribution and use in source and binary forms, with or without modific */
 /* ation, are permitted provided that the following conditions are met:       */
@@ -43,6 +45,17 @@ char* concat_str(const char* str1, const char* str2) {
        return r;
 }
 
+char* dup_str(const char* str) {
+       char* r = malloc(strlen(str) + 1);
+       memcpy(r, str, strlen(str));
+       r[strlen(str)] = 0;
+       return r;
+}
+
+char* input_dir;
+char* output_dir;
+char* title;
+
 int parse_config(const char* path) {
        FILE* f = fopen(path, "r");
        if(f == NULL) {
@@ -66,10 +79,22 @@ int parse_config(const char* path) {
                                        break;
                                }
                        }
-                       if(strcmp(str, "output") == 0) {
+                       if(str[0] == '#') {
+                       } else if(strcmp(str, "output") == 0) {
                                if(found) {
+                                       free(output_dir);
+                                       output_dir = dup_str(str + i);
                                        mkdir(str + i, 0775);
-                                       chdir(str + i);
+                               }
+                       } else if(strcmp(str, "input") == 0) {
+                               if(found) {
+                                       free(input_dir);
+                                       input_dir = dup_str(str + i);
+                               }
+                       } else if(strcmp(str, "title") == 0) {
+                               if(found) {
+                                       free(title);
+                                       title = dup_str(str + i);
                                }
                        }
                        free(str);
@@ -88,9 +113,18 @@ int parse_config(const char* path) {
 }
 
 int main(int argc, char** argv) {
+       output_dir = dup_str("webroot");
+       input_dir = dup_str("input");
+       title = dup_str("Unnamed");
+       int r;
        if(argv[1] == NULL) {
-               return parse_config("clover.conf");
+               r = parse_config("clover.conf");
        } else {
-               return parse_config(argv[1]);
+               r = parse_config(argv[1]);
        }
+       printf("Clover %s Copyright (c) 2024 Nishi\n", CLOVER_VERSION);
+       printf(" Title: %s\n", title);
+       printf(" Input: %s\n", input_dir);
+       printf("Output: %s\n", output_dir);
+       if(r != 0) return r;
 }
diff --git a/clover.conf b/clover.conf
new file mode 100644 (file)
index 0000000..c6d4093
--- /dev/null
@@ -0,0 +1,4 @@
+#comment
+title Example
+output webroot
+input example