CLEANUP: da: move global settings out of the global section

We replaced global.deviceatlas with global_deviceatlas since there's no need
to store all this into the global section. This removes the last #ifdefs,
and now the code is 100% self-contained in da.c. The file da.h was now
removed because it was only used to load dac.h, which is more easily
loaded directly from da.c. It provides another good example of how to
integrate code in the future without touching the core parts.
diff --git a/src/da.c b/src/da.c
index 9ea266f..856ef0d 100644
--- a/src/da.c
+++ b/src/da.c
@@ -6,7 +6,27 @@
 #include <proto/log.h>
 #include <proto/proto_http.h>
 #include <proto/sample.h>
-#include <import/da.h>
+#include <dac.h>
+
+static struct {
+	void *atlasimgptr;
+	char *jsonpath;
+	char *cookiename;
+	size_t cookienamelen;
+	da_atlas_t atlas;
+	da_evidence_id_t useragentid;
+	da_severity_t loglevel;
+	char separator;
+	unsigned char daset:1;
+} global_deviceatlas = {
+	.loglevel = 0,
+	.jsonpath = 0,
+	.cookiename = 0,
+	.cookienamelen = 0,
+	.useragentid = 0,
+	.daset = 0,
+	.separator = '|',
+};
 
 static int da_json_file(char **args, int section_type, struct proxy *curpx,
                         struct proxy *defpx, const char *file, int line,
@@ -16,7 +36,7 @@
 		memprintf(err, "deviceatlas json file : expects a json path.\n");
 		return -1;
 	}
-	global.deviceatlas.jsonpath = strdup(args[1]);
+	global_deviceatlas.jsonpath = strdup(args[1]);
 	return 0;
 }
 
@@ -34,7 +54,7 @@
 	if (loglevel < 0 || loglevel > 3) {
 		memprintf(err, "deviceatlas log level : expects a log level between 0 and 3, %s given.\n", args[1]);
 	} else {
-		global.deviceatlas.loglevel = (da_severity_t)loglevel;
+		global_deviceatlas.loglevel = (da_severity_t)loglevel;
 	}
 
 	return 0;
@@ -48,7 +68,7 @@
 		memprintf(err, "deviceatlas property separator : expects a character argument.\n");
 		return -1;
 	}
-	global.deviceatlas.separator = *args[1];
+	global_deviceatlas.separator = *args[1];
 	return 0;
 }
 
@@ -60,9 +80,9 @@
 		memprintf(err, "deviceatlas cookie name : expects a string argument.\n");
 		return -1;
 	} else {
-		global.deviceatlas.cookiename = strdup(args[1]);
+		global_deviceatlas.cookiename = strdup(args[1]);
 	}
-	global.deviceatlas.cookienamelen = strlen(global.deviceatlas.cookiename);
+	global_deviceatlas.cookienamelen = strlen(global_deviceatlas.cookiename);
 	return 0;
 }
 
@@ -79,7 +99,7 @@
 static void da_haproxy_log(da_severity_t severity, da_status_t status,
 	const char *fmt, va_list args)
 {
-	if (global.deviceatlas.loglevel && severity <= global.deviceatlas.loglevel) {
+	if (global_deviceatlas.loglevel && severity <= global_deviceatlas.loglevel) {
 		char logbuf[256];
 		vsnprintf(logbuf, sizeof(logbuf), fmt, args);
 		Warning("deviceatlas : %s.\n", logbuf);
@@ -95,16 +115,16 @@
 {
 	int err_code = 0;
 
-	if (global.deviceatlas.jsonpath != 0) {
+	if (global_deviceatlas.jsonpath != 0) {
 		FILE *jsonp;
 		da_property_decl_t extraprops[] = {{0, 0}};
 		size_t atlasimglen;
 		da_status_t status;
 
-		jsonp = fopen(global.deviceatlas.jsonpath, "r");
+		jsonp = fopen(global_deviceatlas.jsonpath, "r");
 		if (jsonp == 0) {
 			Alert("deviceatlas : '%s' json file has invalid path or is not readable.\n",
-				global.deviceatlas.jsonpath);
+				global_deviceatlas.jsonpath);
 			err_code |= ERR_ALERT | ERR_FATAL;
 			goto out;
 		}
@@ -112,17 +132,17 @@
 		da_init();
 		da_seterrorfunc(da_haproxy_log);
 		status = da_atlas_compile(jsonp, da_haproxy_read, da_haproxy_seek,
-			&global.deviceatlas.atlasimgptr, &atlasimglen);
+			&global_deviceatlas.atlasimgptr, &atlasimglen);
 		fclose(jsonp);
 		if (status != DA_OK) {
 			Alert("deviceatlas : '%s' json file is invalid.\n",
-				global.deviceatlas.jsonpath);
+				global_deviceatlas.jsonpath);
 			err_code |= ERR_ALERT | ERR_FATAL;
 			goto out;
 		}
 
-		status = da_atlas_open(&global.deviceatlas.atlas, extraprops,
-			global.deviceatlas.atlasimgptr, atlasimglen);
+		status = da_atlas_open(&global_deviceatlas.atlas, extraprops,
+			global_deviceatlas.atlasimgptr, atlasimglen);
 
 		if (status != DA_OK) {
 			Alert("deviceatlas : data could not be compiled.\n");
@@ -130,14 +150,14 @@
 			goto out;
 		}
 
-		if (global.deviceatlas.cookiename == 0) {
-			global.deviceatlas.cookiename = strdup(DA_COOKIENAME_DEFAULT);
-			global.deviceatlas.cookienamelen = strlen(global.deviceatlas.cookiename);
+		if (global_deviceatlas.cookiename == 0) {
+			global_deviceatlas.cookiename = strdup(DA_COOKIENAME_DEFAULT);
+			global_deviceatlas.cookienamelen = strlen(global_deviceatlas.cookiename);
 		}
 
-		global.deviceatlas.useragentid = da_atlas_header_evidence_id(&global.deviceatlas.atlas,
+		global_deviceatlas.useragentid = da_atlas_header_evidence_id(&global_deviceatlas.atlas,
 			"user-agent");
-		global.deviceatlas.daset = 1;
+		global_deviceatlas.daset = 1;
 
 		fprintf(stdout, "Deviceatlas module loaded.\n");
 	}
@@ -148,14 +168,14 @@
 
 static void deinit_deviceatlas(void)
 {
-	if (global.deviceatlas.jsonpath != 0) {
-		free(global.deviceatlas.jsonpath);
+	if (global_deviceatlas.jsonpath != 0) {
+		free(global_deviceatlas.jsonpath);
 	}
 
-	if (global.deviceatlas.daset == 1) {
-		free(global.deviceatlas.cookiename);
-		da_atlas_close(&global.deviceatlas.atlas);
-		free(global.deviceatlas.atlasimgptr);
+	if (global_deviceatlas.daset == 1) {
+		free(global_deviceatlas.cookiename);
+		da_atlas_close(&global_deviceatlas.atlas);
+		free(global_deviceatlas.atlasimgptr);
 	}
 
 	da_fini();
@@ -177,14 +197,14 @@
 	i = 0;
 
 	for (; propname != 0; i ++, propname = (const char *)args[i].data.str.str) {
-		status = da_atlas_getpropid(&global.deviceatlas.atlas,
+		status = da_atlas_getpropid(&global_deviceatlas.atlas,
 			propname, &prop);
 		if (status != DA_OK) {
-			chunk_appendf(tmp, "%c", global.deviceatlas.separator);
+			chunk_appendf(tmp, "%c", global_deviceatlas.separator);
 			continue;
 		}
 		pprop = &prop;
-		da_atlas_getproptype(&global.deviceatlas.atlas, *pprop, &proptype);
+		da_atlas_getproptype(&global_deviceatlas.atlas, *pprop, &proptype);
 
 		switch (proptype) {
 			case DA_TYPE_BOOLEAN: {
@@ -216,7 +236,7 @@
 			break;
 		}
 
-		chunk_appendf(tmp, "%c", global.deviceatlas.separator);
+		chunk_appendf(tmp, "%c", global_deviceatlas.separator);
 	}
 
 	da_close(devinfo);
@@ -240,7 +260,7 @@
 	char useragentbuf[1024] = { 0 };
 	int i;
 
-	if (global.deviceatlas.daset == 0 || smp->data.u.str.len == 0) {
+	if (global_deviceatlas.daset == 0 || smp->data.u.str.len == 0) {
 		return 1;
 	}
 
@@ -250,8 +270,8 @@
 
 	useragent = (const char *)useragentbuf;
 
-	status = da_search(&global.deviceatlas.atlas, &devinfo,
-		global.deviceatlas.useragentid, useragent, 0);
+	status = da_search(&global_deviceatlas.atlas, &devinfo,
+		global_deviceatlas.useragentid, useragent, 0);
 
 	return status != DA_OK ? 0 : da_haproxy(args, smp, &devinfo);
 }
@@ -269,7 +289,7 @@
 	char vbuf[DA_MAX_HEADERS][1024] = {{ 0 }};
 	int i, nbh = 0;
 
-	if (global.deviceatlas.daset == 0) {
+	if (global_deviceatlas.daset == 0) {
 		return 1;
 	}
 
@@ -302,7 +322,7 @@
 		pval = (hctx.line + hctx.val);
 
 		if (strcmp(hbuf, "Accept-Language") == 0) {
-			evid = da_atlas_accept_language_evidence_id(&global.deviceatlas.
+			evid = da_atlas_accept_language_evidence_id(&global_deviceatlas.
 				atlas);
 		} else if (strcmp(hbuf, "Cookie") == 0) {
 			char *p, *eval;
@@ -313,16 +333,16 @@
 			 * The cookie value, if it exists, is located between the current header's
 			 * value position and the next one
 			 */
-			if (extract_cookie_value(pval, eval, global.deviceatlas.cookiename,
-				global.deviceatlas.cookienamelen, 1, &p, &pl) == NULL) {
+			if (extract_cookie_value(pval, eval, global_deviceatlas.cookiename,
+				global_deviceatlas.cookienamelen, 1, &p, &pl) == NULL) {
 				continue;
 			}
 
 			vlen = (size_t)pl;
 			pval = p;
-			evid = da_atlas_clientprop_evidence_id(&global.deviceatlas.atlas);
+			evid = da_atlas_clientprop_evidence_id(&global_deviceatlas.atlas);
 		} else {
-			evid = da_atlas_header_evidence_id(&global.deviceatlas.atlas,
+			evid = da_atlas_header_evidence_id(&global_deviceatlas.atlas,
 				hbuf);
 		}
 
@@ -339,7 +359,7 @@
 		++ nbh;
 	}
 
-	status = da_searchv(&global.deviceatlas.atlas, &devinfo,
+	status = da_searchv(&global_deviceatlas.atlas, &devinfo,
 			ev, nbh);
 
 	return status != DA_OK ? 0 : da_haproxy(args, smp, &devinfo);