/* $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: */
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) {
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);
}
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;
}