diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/endpoints.c | 14 | ||||
-rw-r--r-- | src/main.c | 4 |
2 files changed, 13 insertions, 5 deletions
diff --git a/src/endpoints.c b/src/endpoints.c index d8efb0c..a4ac35a 100644 --- a/src/endpoints.c +++ b/src/endpoints.c @@ -31,7 +31,7 @@ do { \ const char *const JSON_ERROR = "{\"error\":\"%s\"}"; const char *const HTML_ERROR = "<!DOCTYPE html><html><body>Error: %s</body></html>"; -const char *HTTPHOSTNAME = "http://127.0.0.1"; +const char *HTTPHOSTNAME = "http://127.0.0.1:80"; struct global_args { enum { @@ -57,6 +57,12 @@ struct global_args parse_global_args(struct MHD_Connection *connection) { return ret; } +void init(const char *db) { + sqlite_init(db); + const char *new_httphostname = getenv("HTTPHOSTNAME"); + if (new_httphostname) HTTPHOSTNAME = new_httphostname; +} + // index, path: / struct MHD_Response *ENDP_(struct MHD_Connection* connection, int *status) { return get_from_file("www/index.html"); @@ -109,8 +115,10 @@ exit: // API, path: /api/linkdel struct MHD_Response *ENDP_api_linkdel(const char *method, struct MHD_Connection *connection, int *status) { - + return MHD_create_response_from_buffer(4, "TODO", MHD_RESPMEM_PERSISTENT); } // API, path: /api/linkget -struct MHD_Response *ENDP_api_linkget(const char *method, struct MHD_Connection *connection, int *status) { } +struct MHD_Response *ENDP_api_linkget(const char *method, struct MHD_Connection *connection, int *status) { + return MHD_create_response_from_buffer(4, "TODO", MHD_RESPMEM_PERSISTENT); +} @@ -85,8 +85,8 @@ void reload_dylib(const char *so_path, const char *db_path) { if (!arg.dylib) LCRITVF(1, "Could not open dynamic library: %s\n", dlerror()); arg.query = dlsym(arg.dylib, "db_get_url"); if (!arg.query) LCRITVF(1, "Could not load `db_get_url` from shared library: %s", dlerror()); - arg.constructor = dlsym(arg.dylib, "sqlite_init"); - if (!arg.constructor) LCRITVF(1, "Could not load `sqlite_init` from shared library: %s", dlerror()); + arg.constructor = dlsym(arg.dylib, "init"); + if (!arg.constructor) LCRITVF(1, "Could not load `init` from shared library: %s", dlerror()); arg.constructor(db_path); arg.destructor = dlsym(arg.dylib, "sqlite_deinit"); if (!arg.destructor) LCRITVF(1, "Could not load `sqlite_deinit` from shared library: %s", dlerror()); |