diff --git a/CMakeLists.txt b/CMakeLists.txt index f4b7de8..f20ee8d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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" diff --git a/Makefile b/Makefile index b076b58..a3ee88e 100644 --- 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 index 0000000..7d04da4 --- /dev/null +++ b/src/html_cache.c @@ -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 + +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 index 0000000..a382c34 --- /dev/null +++ b/src/html_cache.h @@ -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