Add WIP html_cache
All checks were successful
Run Unit Tests / build-and-run-unit-tests (push) Successful in 8s

This commit is contained in:
Stephen Seo 2024-09-22 15:44:04 +09:00
parent 6f845a7185
commit 8974c7b31f
4 changed files with 79 additions and 1 deletions

View file

@ -11,6 +11,7 @@ set(c_simple_http_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/src/config.c" "${CMAKE_CURRENT_SOURCE_DIR}/src/config.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/http_template.c" "${CMAKE_CURRENT_SOURCE_DIR}/src/http_template.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/helpers.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/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/linked_list.c"
"${CMAKE_CURRENT_SOURCE_DIR}/third_party/SimpleArchiver/src/data_structures/hash_map.c" "${CMAKE_CURRENT_SOURCE_DIR}/third_party/SimpleArchiver/src/data_structures/hash_map.c"

View file

@ -42,7 +42,8 @@ HEADERS = \
src/http.h \ src/http.h \
src/config.h \ src/config.h \
src/http_template.h \ src/http_template.h \
src/helpers.h src/helpers.h \
src/html_cache.h
SOURCES = \ SOURCES = \
src/main.c \ src/main.c \
@ -55,6 +56,7 @@ SOURCES = \
src/config.c \ src/config.c \
src/http_template.c \ src/http_template.c \
src/helpers.c \ src/helpers.c \
src/html_cache.c \
third_party/SimpleArchiver/src/helpers.c \ third_party/SimpleArchiver/src/helpers.c \
third_party/SimpleArchiver/src/data_structures/linked_list.c \ third_party/SimpleArchiver/src/data_structures/linked_list.c \
third_party/SimpleArchiver/src/data_structures/hash_map.c \ third_party/SimpleArchiver/src/data_structures/hash_map.c \

36
src/html_cache.c Normal file
View file

@ -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

39
src/html_cache.h Normal file
View file

@ -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