aboutsummaryrefslogtreecommitdiff
path: root/gmid.h
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2021-03-31 16:32:18 +0000
committerOmar Polo <op@omarpolo.com>2021-03-31 16:32:18 +0000
commitb8e64ccd44290cdd34bdcd3fd85fb1a9cb7486dd (patch)
tree0e419f355bb2bda7a099fd1c113e1c04f7dfe723 /gmid.h
parente0ebdf2d94159db669a67972b760d1920f11310b (diff)
list instead of fixed-size array for vhosts and locations
saves some bytes of memory and removes the limit on the maximum number of vhosts and location blocks.
Diffstat (limited to 'gmid.h')
-rw-r--r--gmid.h18
1 files changed, 10 insertions, 8 deletions
diff --git a/gmid.h b/gmid.h
index 17a1315..0409136 100644
--- a/gmid.h
+++ b/gmid.h
@@ -51,15 +51,13 @@
#define MAX_USERS 64
-#define HOSTSLEN 64
-#define LOCLEN 32
-
/* maximum hostname and label length, +1 for the NUL-terminator */
#define DOMAIN_NAME_LEN (253+1)
#define LABEL_LEN (63+1)
#define PROC_MAX 16
+TAILQ_HEAD(lochead, location);
struct location {
const char *match;
const char *lang;
@@ -71,8 +69,11 @@ struct location {
int strip;
X509_STORE *reqca;
int disable_log;
+
+ TAILQ_ENTRY(location) locations;
};
+extern TAILQ_HEAD(vhosthead, vhost) hosts;
struct vhost {
const char *domain;
const char *cert;
@@ -82,14 +83,14 @@ struct vhost {
const char *entrypoint;
int dirfd;
+ TAILQ_ENTRY(vhost) vhosts;
+
/* the first location rule is always '*' and holds the default
- * settings for the vhost, from locations[1] onwards there are
- * the "real" location rules specified in the configuration. */
- struct location locations[LOCLEN];
+ * settings for the vhost, then follows the "real" location
+ * rules as specified in the configuration. */
+ struct lochead locations;
};
-extern struct vhost hosts[HOSTSLEN];
-
struct etm { /* extension to mime */
const char *mime;
const char *ext;
@@ -321,6 +322,7 @@ int ends_with(const char*, const char*);
ssize_t filesize(int);
char *absolutify_path(const char*);
char *xstrdup(const char*);
+void *xcalloc(size_t, size_t);
void gen_certificate(const char*, const char*, const char*);
X509_STORE *load_ca(const char*);
int validate_against_ca(X509_STORE*, const uint8_t*, size_t);