aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitmodules2
-rw-r--r--Makefile2
-rw-r--r--jals.dbbin8192 -> 0 bytes
-rw-r--r--src/endpoints.c14
-rw-r--r--src/main.c4
5 files changed, 15 insertions, 7 deletions
diff --git a/.gitmodules b/.gitmodules
index 1d6a137..a79ccfe 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,3 @@
[submodule "c_headers"]
path = c_headers
- url = git:repos/c_headers
+ url = https://git.twistea.su/c_headers.git
diff --git a/Makefile b/Makefile
index 7a101dd..1b71312 100644
--- a/Makefile
+++ b/Makefile
@@ -61,7 +61,7 @@ clean:
$(RM) --recursive $(BLDDIR)/template/* $(BLDDIR)/* main endpoints.o endpoints.so rename.ld include/mime.h.inc
veryclean: clean
- $(RM) jals.db
+ $(RM) jals.db config.env
run: main endpoints.so
env $(shell cat config.env) ./main
diff --git a/jals.db b/jals.db
deleted file mode 100644
index 939d4bb..0000000
--- a/jals.db
+++ /dev/null
Binary files differ
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);
+}
diff --git a/src/main.c b/src/main.c
index 3283525..67c4559 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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());