Commit Diff


commit - 982069a120a3d36483427ce00b9cf90a8bf4daab
commit + a010b0ddc5aa8cf49207b0ab87d36be6ebb320cf
blob - bbf70d3ecdfc159c0d72c2c1b17c5accb675c43a
blob + 5d4b5f83d291ca27bf763feffaa69b2fdf0b524c
--- gmid.h
+++ gmid.h
@@ -64,11 +64,24 @@ struct vhost {
 
 extern struct vhost hosts[HOSTSLEN];
 
+struct etm {			/* extension to mime */
+	const char	*mime;
+	const char	*ext;
+};
+
+struct mimes {
+	char		*def;
+	struct etm	*t;
+	size_t		len;
+	size_t		cap;
+};
+
 struct conf {
-	int	foreground;
-	int	port;
-	int	ipv6;
-	uint32_t protos;
+	int		foreground;
+	int		port;
+	int		ipv6;
+	uint32_t	protos;
+	struct mimes	mimes;
 };
 
 extern struct conf conf;
blob - 121dee05310d1f280333e947e2bdf0d219557119
blob + 35ff72e47d9e280b831795a9d008ae877ae0a5c3
--- mime.c
+++ mime.c
@@ -20,31 +20,18 @@
 
 #include "gmid.h"
 
-struct etm {			/* extension to mime */
-	const char	*mime;
-	const char	*ext;
-};
-
-struct mimes {
-	char		*def;
-	struct etm	*t;
-	size_t		len;
-	size_t		cap;
-};
-
-struct mimes mimes;
-
 void
 init_mime(void)
 {
-	mimes.len = 0;
-	mimes.cap = 2;
+	conf.mimes.len = 0;
+	conf.mimes.cap = 2;
 
-	if ((mimes.t = calloc(mimes.cap, sizeof(struct etm))) == NULL)
+	conf.mimes.t = calloc(conf.mimes.cap, sizeof(struct etm));
+	if (conf.mimes.t == NULL)
 		fatal("calloc: %s", strerror(errno));
 
-	mimes.def = strdup("application/octet-stream");
-	if (mimes.def == NULL)
+	conf.mimes.def = strdup("application/octet-stream");
+	if (conf.mimes.def == NULL)
 		fatal("strdup: %s", strerror(errno));
 
 }
@@ -52,8 +39,8 @@ init_mime(void)
 void
 set_default_mime(const char *m)
 {
-	free(mimes.def);
-	if ((mimes.def = strdup(m)) == NULL)
+	free(conf.mimes.def);
+	if ((conf.mimes.def = strdup(m)) == NULL)
 		fatal("strdup: %s", strerror(errno));
 }
 
@@ -61,16 +48,17 @@ set_default_mime(const char *m)
 void
 add_mime(const char *mime, const char *ext)
 {
-	if (mimes.len == mimes.cap) {
-		mimes.cap *= 1.5;
-		mimes.t = realloc(mimes.t, mimes.cap * sizeof(struct etm));
-		if (mimes.t == NULL)
+	if (conf.mimes.len == conf.mimes.cap) {
+		conf.mimes.cap *= 1.5;
+		conf.mimes.t = realloc(conf.mimes.t,
+		    conf.mimes.cap * sizeof(struct etm));
+		if (conf.mimes.t == NULL)
 			fatal("realloc: %s", strerror(errno));
 	}
 
-	mimes.t[mimes.len].mime = mime;
-	mimes.t[mimes.len].ext  = ext;
-	mimes.len++;
+	conf.mimes.t[conf.mimes.len].mime = mime;
+	conf.mimes.t[conf.mimes.len].ext  = ext;
+	conf.mimes.len++;
 }
 
 /* load a default set of common mime-extension associations */
@@ -120,11 +108,11 @@ mime(const char *path)
 	struct etm *t;
 
 	if ((ext = path_ext(path)) == NULL)
-		return mimes.def;
+		return conf.mimes.def;
 
-	for (t = mimes.t; t->mime != NULL; ++t)
+	for (t = conf.mimes.t; t->mime != NULL; ++t)
 		if (!strcmp(ext, t->ext))
 			return t->mime;
 
-	return mimes.def;
+	return conf.mimes.def;
 }