This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// $ cc -Isrc/hin -Isrc/system -Iexternal/basic/include \ | |
// hin9.c -luring -lz $(pkg-config lua-5.3 --cflags --libs) | |
// Ref: https://gitlab.com/tiotags/hin9 | |
// Ref: https://old.reddit.com/r/linux/comments/zl2vm1 | |
#define _GNU_SOURCE | |
#define HIN_USE_CGI | |
#include "external/basic/basic_args.c" | |
#include "external/basic/basic_endianness.c" | |
#include "external/basic/basic_hashtable.c" | |
#include "external/basic/basic_lists.c" | |
#include "external/basic/basic_pattern.c" | |
#include "external/basic/vfs/basic_vfs.c" | |
#include "external/basic/vfs/compat.c" | |
#include "external/basic/vfs/dir.c" | |
#include "external/basic/vfs/inotify.c" | |
#include "external/basic/vfs/path.c" | |
#include "external/basic/vfs/stat.c" | |
#include "src/http/cache/cache.c" | |
#include "src/http/cache/utils.c" | |
#include "src/http/cgi/cgi_parse.c" | |
#include "src/http/cgi/fcgi.c" | |
#include "src/http/cgi/fcgi_post.c" | |
#include "src/http/cgi/fcgi_read.c" | |
#include "src/http/cgi/fcgi_socket.c" | |
#include "src/http/cgi/fcgi_util.c" | |
#include "src/http/cgi/fcgi_worker.c" | |
#include "src/http/cgi/fcgi_write.c" | |
#include "src/http/cgi/httpd_cgi.c" | |
#include "src/http/client/connect.c" | |
#include "src/http/client/data.c" | |
#include "src/http/client/download.c" | |
#include "src/http/client/headers.c" | |
#include "src/http/client/rproxy.c" | |
#include "src/http/client/state.c" | |
#include "src/http/server/client.c" | |
#include "src/http/server/file.c" | |
#include "src/http/server/headers.c" | |
#include "src/http/server/httpd.c" | |
#include "src/http/server/httpd1.c" | |
#include "src/http/server/read.c" | |
#include "src/http/server/response.c" | |
#include "src/http/server/vhost.c" | |
#include "src/http/utils/filters.c" | |
#include "src/http/utils/http_misc.c" | |
#include "src/http/utils/string.c" | |
#include "src/http/utils/timer.c" | |
#include "src/lua/lua.c" | |
#include "src/lua/lua_callback.c" | |
#include "src/lua/lua_config.c" | |
#include "src/lua/lua_map.c" | |
#include "src/lua/lua_opt.c" | |
#include "src/lua/lua_os.c" | |
#include "src/lua/lua_req.c" | |
#include "src/lua/lua_utils.c" | |
#include "src/lua/lua_vfs.c" | |
#include "src/lua/lua_vhost.c" | |
#include "src/netcode/buffer.c" | |
#include "src/netcode/connect.c" | |
#include "src/netcode/epoll.c" | |
#include "src/netcode/header.c" | |
#include "src/netcode/hin.c" | |
#include "src/netcode/listen.c" | |
#include "src/netcode/pipe.c" | |
#include "src/netcode/server.c" | |
#include "src/netcode/ssl_data.c" | |
#include "src/netcode/ssl_init.c" | |
#include "src/netcode/timer.c" | |
#include "src/netcode/uring.c" | |
#include "src/netcode/utils.c" | |
#include "src/system/args.c" | |
#include "src/system/console.c" | |
#include "src/system/daemon.c" | |
#include "src/system/helper.c" | |
#include "src/system/main.c" | |
#include "src/system/restart.c" | |
#include "src/system/signal.c" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- a/src/http/client/http_internal.h | |
+++ b/src/http/client/http_internal.h | |
@@ -1,5 +1,5 @@ | |
-#ifndef HIN_HTTP_INTERNAL_H | |
-#define HIN_HTTP_INTERNAL_H | |
+#ifndef HIN_CLIENT_HTTP_INTERNAL_H | |
+#define HIN_CLIENT_HTTP_INTERNAL_H | |
int http_client_unlink (http_client_t * http); | |
--- a/src/http/server/file.c | |
+++ b/src/http/server/file.c | |
@@ -46,7 +46,6 @@ static int httpd_send_file_done (hin_pipe_t * pipe) { | |
httpd_client_finish_output (http, pipe); | |
- void hin_cache_unref (void *); | |
if (pipe->parent1) hin_cache_unref (pipe->parent1); | |
return 0; | |
--- a/src/http/server/httpd_internal.h | |
+++ b/src/http/server/httpd_internal.h | |
@@ -1,6 +1,6 @@ | |
-#ifndef HIN_HTTP_INTERNAL_H | |
-#define HIN_HTTP_INTERNAL_H | |
+#ifndef HIN_SERVER_HTTP_INTERNAL_H | |
+#define HIN_SERVER_HTTP_INTERNAL_H | |
int httpd_client_reread (httpd_client_t * http); | |
--- a/src/http/utils/filters.c | |
+++ b/src/http/utils/filters.c | |
@@ -132,7 +132,7 @@ int httpd_pipe_set_chunked (httpd_client_t * http, hin_pipe_t * pipe) { | |
return 0; | |
} | |
-static int httpd_pipe_error_callback (hin_pipe_t * pipe, int err) { | |
+static int filters_httpd_pipe_error_callback (hin_pipe_t * pipe, int err) { | |
hin_error ("httpd %d pipe: %s", pipe->out.fd, strerror (-err)); | |
httpd_client_shutdown (pipe->parent); | |
return 0; | |
@@ -145,7 +145,7 @@ HIN_EXPORT int httpd_pipe_set_http11_response_options (httpd_client_t * http, hi | |
pipe->out.pos = 0; | |
pipe->parent = http; | |
pipe->debug = http->debug; | |
- pipe->out_error_callback = httpd_pipe_error_callback; | |
+ pipe->out_error_callback = filters_httpd_pipe_error_callback; | |
if (http->status == 304 || http->method == HIN_METHOD_HEAD) { | |
http->peer_flags &= ~(HIN_HTTP_CHUNKED | HIN_HTTP_COMPRESS); | |
--- a/src/lua/lua_config.c | |
+++ b/src/lua/lua_config.c | |
@@ -426,18 +426,17 @@ static int l_hin_create_fcgi (lua_State *L) { | |
int l_hin_add_vhost (lua_State *L); | |
int l_hin_map (lua_State *L); | |
-static lua_function_t functs [] = { | |
-{"create_log", l_hin_create_log }, | |
-{"nil_log", l_hin_nil_log }, | |
-{"redirect_log", l_hin_redirect_log }, | |
-{"create_cert", l_hin_create_cert }, | |
-{"create_fcgi", l_hin_create_fcgi }, | |
-{"add_vhost", l_hin_add_vhost }, | |
-{"map", l_hin_map }, | |
-{NULL, NULL}, | |
-}; | |
- | |
int hin_lua_config_init (lua_State * L) { | |
+ static lua_function_t functs [] = { | |
+ {"create_log", l_hin_create_log }, | |
+ {"nil_log", l_hin_nil_log }, | |
+ {"redirect_log", l_hin_redirect_log }, | |
+ {"create_cert", l_hin_create_cert }, | |
+ {"create_fcgi", l_hin_create_fcgi }, | |
+ {"add_vhost", l_hin_add_vhost }, | |
+ {"map", l_hin_map }, | |
+ {NULL, NULL}, | |
+ }; | |
return lua_add_functions (L, functs); | |
} | |
--- a/src/lua/lua_opt.c | |
+++ b/src/lua/lua_opt.c | |
@@ -455,24 +455,23 @@ static int l_hin_disable_debug (lua_State *L) { | |
return 1; | |
} | |
-static lua_function_t functs [] = { | |
-{"set_server_option", l_hin_set_server_option }, | |
-{"get_server_option", l_hin_get_server_option }, | |
-{"set_option", l_hin_set_option }, | |
-{"get_option", l_hin_get_option }, | |
-{"set_global_option", l_hin_set_global_option }, | |
-{"enable_debug", l_hin_enable_debug }, | |
-{"disable_debug", l_hin_disable_debug }, | |
-{"req_get_file_size", l_req_get_file_size }, | |
-{"req_get_status", l_req_get_status }, | |
-{"req_get_vhost", l_req_get_vhost }, | |
-{"req_set_cache", l_req_set_cache }, | |
-{"req_set_cache_key", l_req_set_cache_key }, | |
-{"req_set_disabled", l_req_set_disabled }, | |
-{NULL, NULL}, | |
-}; | |
- | |
int hin_lua_opt_init (lua_State * L) { | |
+ static lua_function_t functs [] = { | |
+ {"set_server_option", l_hin_set_server_option }, | |
+ {"get_server_option", l_hin_get_server_option }, | |
+ {"set_option", l_hin_set_option }, | |
+ {"get_option", l_hin_get_option }, | |
+ {"set_global_option", l_hin_set_global_option }, | |
+ {"enable_debug", l_hin_enable_debug }, | |
+ {"disable_debug", l_hin_disable_debug }, | |
+ {"req_get_file_size", l_req_get_file_size }, | |
+ {"req_get_status", l_req_get_status }, | |
+ {"req_get_vhost", l_req_get_vhost }, | |
+ {"req_set_cache", l_req_set_cache }, | |
+ {"req_set_cache_key", l_req_set_cache_key }, | |
+ {"req_set_disabled", l_req_set_disabled }, | |
+ {NULL, NULL}, | |
+ }; | |
return lua_add_functions (L, functs); | |
} | |
--- a/src/lua/lua_os.c | |
+++ b/src/lua/lua_os.c | |
@@ -216,14 +216,13 @@ static int l_hin_list_dir1 (lua_State *L) { | |
return 1; | |
} | |
-static lua_function_t functs [] = { | |
-{"exec", l_hin_exec }, | |
-{"app_state", l_hin_app_state }, | |
-{"list_dir1", l_hin_list_dir1 }, | |
-{NULL, NULL}, | |
-}; | |
- | |
int hin_lua_os_init (lua_State * L) { | |
+ static lua_function_t functs [] = { | |
+ {"exec", l_hin_exec }, | |
+ {"app_state", l_hin_app_state }, | |
+ {"list_dir1", l_hin_list_dir1 }, | |
+ {NULL, NULL}, | |
+ }; | |
return lua_add_functions (L, functs); | |
} | |
--- a/src/lua/lua_req.c | |
+++ b/src/lua/lua_req.c | |
@@ -341,26 +341,25 @@ static int l_hin_get_vhost (lua_State *L) { | |
int l_hin_set_path (lua_State *L); | |
int l_hin_list_dir (lua_State *L); | |
-static lua_function_t functs [] = { | |
-{"parse_path", l_hin_parse_path }, | |
-{"parse_headers", l_hin_parse_headers }, | |
-{"send_file", l_hin_send_file }, | |
-{"proxy", l_hin_proxy }, | |
-{"cgi", l_hin_cgi }, | |
-{"fastcgi", l_hin_fastcgi }, | |
-{"respond", l_hin_respond }, | |
-{"sanitize_path", l_hin_sanitize_path }, | |
-{"remote_address", l_hin_remote_address }, | |
-{"add_header", l_hin_add_header }, | |
-{"shutdown", l_hin_shutdown }, | |
-{"set_content_type", l_hin_set_content_type }, | |
-{"set_path", l_hin_set_path }, | |
-{"list_dir", l_hin_list_dir }, | |
-{"get_vhost", l_hin_get_vhost }, | |
-{NULL, NULL}, | |
-}; | |
- | |
int hin_lua_req_init (lua_State * L) { | |
+ static lua_function_t functs [] = { | |
+ {"parse_path", l_hin_parse_path }, | |
+ {"parse_headers", l_hin_parse_headers }, | |
+ {"send_file", l_hin_send_file }, | |
+ {"proxy", l_hin_proxy }, | |
+ {"cgi", l_hin_cgi }, | |
+ {"fastcgi", l_hin_fastcgi }, | |
+ {"respond", l_hin_respond }, | |
+ {"sanitize_path", l_hin_sanitize_path }, | |
+ {"remote_address", l_hin_remote_address }, | |
+ {"add_header", l_hin_add_header }, | |
+ {"shutdown", l_hin_shutdown }, | |
+ {"set_content_type", l_hin_set_content_type }, | |
+ {"set_path", l_hin_set_path }, | |
+ {"list_dir", l_hin_list_dir }, | |
+ {"get_vhost", l_hin_get_vhost }, | |
+ {NULL, NULL}, | |
+ }; | |
return lua_add_functions (L, functs); | |
} | |
--- a/src/lua/lua_utils.c | |
+++ b/src/lua/lua_utils.c | |
@@ -152,14 +152,13 @@ static int l_hin_file_age (lua_State *L) { | |
return 1; | |
} | |
-static lua_function_t functs [] = { | |
-{"include", l_hin_include }, | |
-{"require", l_hin_require }, | |
-{"file_age", l_hin_file_age }, | |
-{NULL, NULL}, | |
-}; | |
- | |
int hin_lua_utils_init (lua_State * L) { | |
+ static lua_function_t functs [] = { | |
+ {"include", l_hin_include }, | |
+ {"require", l_hin_require }, | |
+ {"file_age", l_hin_file_age }, | |
+ {NULL, NULL}, | |
+ }; | |
return lua_add_functions (L, functs); | |
} | |
--- a/src/lua/lua_vfs.c | |
+++ b/src/lua/lua_vfs.c | |
@@ -81,7 +81,6 @@ int hin_send_raw_path (httpd_client_t * http) { | |
} | |
http->file = node; | |
- int httpd_handle_file_request (httpd_client_t * http, const char * path, off_t pos, off_t count, uintptr_t param); | |
httpd_handle_file_request (http, NULL, 0, 0, 0); | |
return 1; | |
--- a/src/system/main.c | |
+++ b/src/system/main.c | |
@@ -125,7 +125,6 @@ int main (int argc, const char * argv[], const char * envp[]) { | |
if (hin_pidfile (hin_app.pid_path) < 0) { return -1; } | |
} | |
- void * hin_cache_create (); | |
hin_cache_create (); | |
if ((hin_g.flags & HIN_FLAG_RUN) == 0) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment