]> git.seodisparate.com - c_simple_http/commitdiff
Add WIP html_cache
authorStephen Seo <seo.disparate@gmail.com>
Sun, 22 Sep 2024 06:44:04 +0000 (15:44 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Sun, 22 Sep 2024 06:44:04 +0000 (15:44 +0900)
CMakeLists.txt
Makefile
src/html_cache.c [new file with mode: 0644]
src/html_cache.h [new file with mode: 0644]

index f4b7de8186d5ed71edbad61e713ae53fd4bfe464..f20ee8d532cb96fa9f8b519a3d8f02af567a9135 100644 (file)
@@ -11,6 +11,7 @@ set(c_simple_http_SOURCES
   "${CMAKE_CURRENT_SOURCE_DIR}/src/config.c"
   "${CMAKE_CURRENT_SOURCE_DIR}/src/http_template.c"
   "${CMAKE_CURRENT_SOURCE_DIR}/src/helpers.c"
+  "${CMAKE_CURRENT_SOURCE_DIR}/src/html_cache.c"
   "${CMAKE_CURRENT_SOURCE_DIR}/third_party/SimpleArchiver/src/helpers.c"
   "${CMAKE_CURRENT_SOURCE_DIR}/third_party/SimpleArchiver/src/data_structures/linked_list.c"
   "${CMAKE_CURRENT_SOURCE_DIR}/third_party/SimpleArchiver/src/data_structures/hash_map.c"
index b076b580beef3df61047c9d1bd04224cf1b8457d..a3ee88e0532f4b8369a94e02a2d374ba971e5f7d 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -42,7 +42,8 @@ HEADERS = \
        src/http.h \
        src/config.h \
        src/http_template.h \
-       src/helpers.h
+       src/helpers.h \
+       src/html_cache.h
 
 SOURCES = \
                src/main.c \
@@ -55,6 +56,7 @@ SOURCES = \
                src/config.c \
                src/http_template.c \
                src/helpers.c \
+               src/html_cache.c \
                third_party/SimpleArchiver/src/helpers.c \
                third_party/SimpleArchiver/src/data_structures/linked_list.c \
                third_party/SimpleArchiver/src/data_structures/hash_map.c \
diff --git a/src/html_cache.c b/src/html_cache.c
new file mode 100644 (file)
index 0000000..7d04da4
--- /dev/null
@@ -0,0 +1,36 @@
+// ISC License
+// 
+// Copyright (c) 2024 Stephen Seo
+// 
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+// Third-party includes.
+//#include <SimpleArchiver/src/data_structures/linked_list.h>
+
+char *c_simple_http_path_to_cache_filename(const char *path) {
+//  SDArchiverLinkedList *parts = simple_archiver_list_init();
+  // TODO
+
+  return 0;
+}
+
+int c_simple_http_cache_path(
+    const char *path,
+    const char *config_filename,
+    const char *cache_dir,
+    char **buf_out) {
+  // TODO
+  return 0;
+}
+
+// vim: et ts=2 sts=2 sw=2
diff --git a/src/html_cache.h b/src/html_cache.h
new file mode 100644 (file)
index 0000000..a382c34
--- /dev/null
@@ -0,0 +1,39 @@
+// ISC License
+// 
+// Copyright (c) 2024 Stephen Seo
+// 
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#ifndef SEODISPARATE_COM_C_SIMPLE_HTTP_HTML_CACHE_H_
+#define SEODISPARATE_COM_C_SIMPLE_HTTP_HTML_CACHE_H_
+
+/// Must be free'd if non-NULL.
+char *c_simple_http_path_to_cache_filename(const char *path);
+
+/// Must be free'd if non-NULL.
+char *c_simple_http_cache_filename_to_path(const char *cache_filename);
+
+/// Given a "path", returns non-zero if the cache is invalidated.
+/// "config_filename" is required to check its timestamp. "cache_dir" is
+/// required to actually get the cache file to check against. "buf_out" will be
+/// populated if non-NULL, and will either be fetched from the cache or from the
+/// config (using http_template). Note that "buf_out" will point to a c-string.
+int c_simple_http_cache_path(
+  const char *path,
+  const char *config_filename,
+  const char *cache_dir,
+  char **buf_out);
+
+#endif
+
+// vim: et ts=2 sts=2 sw=2