From d9071a494767bb959e0906efe9d156c6bcf54b77 Mon Sep 17 00:00:00 2001 From: kamkow1 Date: Thu, 26 Jun 2025 00:07:12 +0200 Subject: [PATCH] Rename etc dump to bakedres dump --- blog/the-making-of-aboba.md | 6 ++-- main.c | 64 ++++++++++++++++++------------------- tmpls/blog.html | 6 ++-- tmpls/home.html | 8 ++--- tmpls/page-missing.html | 6 ++-- tmpls/template-blog.html | 10 +++--- 6 files changed, 50 insertions(+), 50 deletions(-) diff --git a/blog/the-making-of-aboba.md b/blog/the-making-of-aboba.md index ffd10c6..bdec87d 100644 --- a/blog/the-making-of-aboba.md +++ b/blog/the-making-of-aboba.md @@ -5,7 +5,7 @@ how the code is architectured and some cool tricks that are used throughout the ## Our "engine" -![the engine](/etc/tmoa-engine.jpg) +![the engine](/bakedres/tmoa-engine.jpg) This image is a joke, obviously. @@ -133,7 +133,7 @@ void *route_thread_function(void *param) // Unparsable HTTP request } - if (mg_match(http_msg.uri, mg_str("/etc/*"), nil)) { + if (mg_match(http_msg.uri, mg_str("/bakedres/*"), nil)) { // Request for static resource } @@ -147,7 +147,7 @@ this functionality comes with mongoose built-in. God bless you mongoose! ## Dynamic pages and static assets. -![the assets](/etc/tmoa-garbage.jpg) +![the assets](/bakedres/tmoa-garbage.jpg) Let's stop here now and talk about something different entirely (dont' worry, we'll come back later). I'd like to show you how assets/pages are implemented in aboba, so we get the whole picture. diff --git a/main.c b/main.c index b20a8bc..dc655de 100644 --- a/main.c +++ b/main.c @@ -18,7 +18,7 @@ #include "locked.h" static locked(Route *) route_hashtable = locked_init(nil); -static locked(char *) etc_dump_path = locked_init(nil); +static locked(char *) baked_dump_path = locked_init(nil); void run_in_thread(void *(*f)(void *), void *p) { @@ -49,7 +49,7 @@ void *route_thread_function(void *param) return nil; } - if (mg_match(http_msg.uri, mg_str("/etc/*"), nil)) { + if (mg_match(http_msg.uri, mg_str("/bakedres/*"), nil)) { Route_Result result = {0}; result.type = ROUTE_RESULT_STATIC; @@ -60,9 +60,9 @@ void *route_thread_function(void *param) char *file = basename(p); char *full_path = malloc(PATH_MAX); - lockx(&etc_dump_path); - snprintf(full_path, PATH_MAX, "%s/%s", etc_dump_path.value, file); - unlockx(&etc_dump_path); + lockx(&baked_dump_path); + snprintf(full_path, PATH_MAX, "%s/%s", baked_dump_path.value, file); + unlockx(&baked_dump_path); sb_append_nstr(&result.body, full_path); sb_finish(&result.body); @@ -165,23 +165,23 @@ void free_route_hashtable(void) unlockx(&route_hashtable); } -char *init_etc_dump(void) +char *init_baked_dump(void) { - char template[] = "/tmp/aboba-etc.XXXXXX"; - char *etc_dump1 = mkdtemp(template); - char *etc_dump = malloc(strlen(etc_dump1)+1); - strcpy(etc_dump, etc_dump1); + char template[] = "/tmp/aboba-bakedres.XXXXXX"; + char *baked_dump1 = mkdtemp(template); + char *baked_dump = malloc(strlen(baked_dump1)+1); + strcpy(baked_dump, baked_dump1); - if (etc_dump == nil) { - LOGE("Could not create etc dump\n"); + if (baked_dump == nil) { + LOGE("Could not create bakedres dump\n"); return nil; } - LOGI("etc dump dir is %s\n", etc_dump); + LOGI("bakedres dump dir is %s\n", baked_dump); - return etc_dump; + return baked_dump; } -int etc_dump_rm_cb(const char *path, +int baked_dump_rm_cb(const char *path, discard const struct stat *st, discard int type, discard struct FTW *ftw) @@ -189,14 +189,14 @@ int etc_dump_rm_cb(const char *path, return remove(path); } -bool free_etc_dump(char *etc_dump) +bool free_baked_dump(char *baked_dump) { - LOGI("Removing etc dump %s\n", etc_dump); - bool ok = nftw(etc_dump, etc_dump_rm_cb, FOPEN_MAX, FTW_DEPTH | FTW_MOUNT | FTW_PHYS) != -1; + LOGI("Removing bakedres dump %s\n", baked_dump); + bool ok = nftw(baked_dump, baked_dump_rm_cb, FOPEN_MAX, FTW_DEPTH | FTW_MOUNT | FTW_PHYS) != -1; if (!ok) { - LOGE("Could not remove %s\n", etc_dump); + LOGE("Could not remove %s\n", baked_dump); } - free(etc_dump); + free(baked_dump); return ok; } @@ -234,20 +234,20 @@ int cp(const char* source, const char* destination) return result; } -void copy_baked_resources_to_etc_dump(Baked_Resource *resource, void *udata) +void copy_baked_resources_to_baked_dump(Baked_Resource *resource, void *udata) { - char *etc_dump = (char *)udata; + char *baked_dump = (char *)udata; char path[PATH_MAX]; get_baked_resource_path(resource->key, path, sizeof(path)); char dest[PATH_MAX]; - snprintf(dest, sizeof(dest), "%s/%s", etc_dump, resource->key); + snprintf(dest, sizeof(dest), "%s/%s", baked_dump, resource->key); cp(path, dest); } -void populate_etc_dump(char *etc_dump) +void populate_baked_dump(char *baked_dump) { lock_baked_resources(); - baked_resource_each(©_baked_resources_to_etc_dump, etc_dump); + baked_resource_each(©_baked_resources_to_baked_dump, baked_dump); unlock_baked_resources(); } @@ -261,12 +261,12 @@ int main(int argc, char ** argv) start_timer(); init_baked_resources(); - lockx(&etc_dump_path); - if ((etc_dump_path.value = init_etc_dump()) == nil) { + lockx(&baked_dump_path); + if ((baked_dump_path.value = init_baked_dump()) == nil) { return 1; } - populate_etc_dump(etc_dump_path.value); - unlockx(&etc_dump_path); + populate_baked_dump(baked_dump_path.value); + unlockx(&baked_dump_path); mg_log_set(MG_LL_DEBUG); struct mg_mgr mgr; @@ -284,9 +284,9 @@ int main(int argc, char ** argv) mg_mgr_free(&mgr); - lockx(&etc_dump_path); - free_etc_dump(etc_dump_path.value); - unlockx(&etc_dump_path); + lockx(&baked_dump_path); + free_baked_dump(baked_dump_path.value); + unlockx(&baked_dump_path); free_baked_resources(); return 0; diff --git a/tmpls/blog.html b/tmpls/blog.html index 3d3d6b3..4099d15 100644 --- a/tmpls/blog.html +++ b/tmpls/blog.html @@ -3,7 +3,7 @@ Blog - + <#META_TAGS> @@ -24,8 +24,8 @@ <#ifdef HOTRELOAD> - + <#endif> - + diff --git a/tmpls/home.html b/tmpls/home.html index 0c3e3fb..4322b4c 100644 --- a/tmpls/home.html +++ b/tmpls/home.html @@ -3,7 +3,7 @@ Kamil's personal website - + <#META_TAGS> @@ -54,7 +54,7 @@
- literally me + literally me
<#ifdef HOTRELOAD> - + <#endif> - + diff --git a/tmpls/page-missing.html b/tmpls/page-missing.html index 3330dfd..945beed 100644 --- a/tmpls/page-missing.html +++ b/tmpls/page-missing.html @@ -2,7 +2,7 @@ 404 - Page not found - + <#META_TAGS> @@ -19,8 +19,8 @@ <#ifdef HOTRELOAD> - + <#endif> - + diff --git a/tmpls/template-blog.html b/tmpls/template-blog.html index 422bc35..9e02f42 100644 --- a/tmpls/template-blog.html +++ b/tmpls/template-blog.html @@ -3,10 +3,10 @@ <#BLOG_POST_TITLE> - + <#META_TAGS> - - + +
@@ -23,9 +23,9 @@ <#ifdef HOTRELOAD> - + <#endif> - +