summaryrefslogtreecommitdiff
path: root/src/mod_vhostdb_api.c
diff options
context:
space:
mode:
authorGlenn Strauss <gstrauss@gluelogic.com>2021-05-22 17:14:22 -0400
committerGlenn Strauss <gstrauss@gluelogic.com>2021-08-27 02:16:52 -0400
commit0fd891877713b1755d8b3182528f8b845cf7db0f (patch)
tree43aa421ab339766fc4710dddb39a10d91169e328 /src/mod_vhostdb_api.c
parent3538f8f2a407aadcce945c6ae4c96e7335f13fec (diff)
downloadlighttpd-git-0fd891877713b1755d8b3182528f8b845cf7db0f.tar.gz
[mod_vhostdb*] rename http_vhostdb->mod_vhostdb_api
rename http_vhostdb.[ch] -> mod_vhostdb_api.[ch]
Diffstat (limited to 'src/mod_vhostdb_api.c')
-rw-r--r--src/mod_vhostdb_api.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/mod_vhostdb_api.c b/src/mod_vhostdb_api.c
new file mode 100644
index 00000000..8c3543b3
--- /dev/null
+++ b/src/mod_vhostdb_api.c
@@ -0,0 +1,41 @@
+/*
+ * http_vhostdb_api - virtual hosts mapping backend registration
+ *
+ * Copyright(c) 2017 Glenn Strauss gstrauss()gluelogic.com All rights reserved
+ * License: BSD 3-clause (same as lighttpd)
+ */
+#include "first.h"
+
+#include "mod_vhostdb_api.h"
+
+#include <string.h>
+
+
+static http_vhostdb_backend_t http_vhostdb_backends[8];
+
+void http_vhostdb_dumbdata_reset (void)
+{
+ memset(http_vhostdb_backends, 0, sizeof(http_vhostdb_backends));
+}
+
+const http_vhostdb_backend_t * http_vhostdb_backend_get (const buffer *name)
+{
+ int i = 0;
+ while (NULL != http_vhostdb_backends[i].name
+ && 0 != strcmp(http_vhostdb_backends[i].name, name->ptr)) {
+ ++i;
+ }
+ return (NULL != http_vhostdb_backends[i].name)
+ ? http_vhostdb_backends+i
+ : NULL;
+}
+
+void http_vhostdb_backend_set (const http_vhostdb_backend_t *backend)
+{
+ unsigned int i = 0;
+ while (NULL != http_vhostdb_backends[i].name) ++i;
+ /*(must resize http_vhostdb_backends[] if too many different backends)*/
+ force_assert(
+ i < (sizeof(http_vhostdb_backends)/sizeof(http_vhostdb_backend_t))-1);
+ memcpy(http_vhostdb_backends+i, backend, sizeof(http_vhostdb_backend_t));
+}