site

A custom static site generator written in C.
git clone https://unitehenry.com/git/site.git
Log | Files | Refs | README

commit 060c0906462066fbed11a696caf7d25ccac18845
parent c988f81a81b6dba78f1c1d1ab4490395cf21a3d4
Author: Henry Unite <unitehenry@gmail.com>
Date:   Thu,  9 Apr 2026 04:10:00 +0000

chore: format

Diffstat:
Msrc/create_subdirectories.c | 41+++++++++++++++++++++--------------------
Msrc/main.c | 10+++++-----
2 files changed, 26 insertions(+), 25 deletions(-)

diff --git a/src/create_subdirectories.c b/src/create_subdirectories.c @@ -1,36 +1,37 @@ +#include <stdlib.h> +#include <string.h> #include <sys/stat.h> #include <unistd.h> -#include <string.h> -#include <stdlib.h> void create_subdirectories(char *filepath) { - char *path_copy = strdup(filepath); + char *path_copy = strdup(filepath); - if (!path_copy) return; + if (!path_copy) + return; - char *last_slash = strrchr(path_copy, '/'); + char *last_slash = strrchr(path_copy, '/'); - if (last_slash) { - *last_slash = '\0'; - } else { - free(path_copy); + if (last_slash) { + *last_slash = '\0'; + } else { + free(path_copy); - return; - } + return; + } - char *p; + char *p; - for (p = path_copy + 1; *p; p++) { - if (*p == '/') { - *p = '\0'; + for (p = path_copy + 1; *p; p++) { + if (*p == '/') { + *p = '\0'; - mkdir(path_copy, 0755); + mkdir(path_copy, 0755); - *p = '/'; - } + *p = '/'; } + } - mkdir(path_copy, 0755); + mkdir(path_copy, 0755); - free(path_copy); + free(path_copy); } diff --git a/src/main.c b/src/main.c @@ -59,14 +59,14 @@ void run_pandoc(FILE **fp, char *content_path) { *fp = popen(command, "r"); } -void to_write_path(char *write_path, char* read_path) { - char replace_path[strlen(read_path)]; +void to_write_path(char *write_path, char *read_path) { + char replace_path[strlen(read_path)]; - strcpy(replace_path, read_path); + strcpy(replace_path, read_path); - strcpy(write_path, str_replace(replace_path, ".md", ".html")); + strcpy(write_path, str_replace(replace_path, ".md", ".html")); - strcpy(write_path, str_replace(write_path, "content/", "build/")); + strcpy(write_path, str_replace(write_path, "content/", "build/")); } void generate_pages(StringList *list) {