access config via a pointer, not a hardcoded struct address

this is required so we can elegantly swap out an old config for a
new one in the future and remove lots of boilerplate from config
initialization code.

unfortunately this is a quite intrusive change as the config struct
was accessed in numerous places, but frankly it should have been
done via a pointer right from the start.

right now, we simply point to a static struct in main.c, so there
shouldn't be any noticeable changes in behaviour.
This commit is contained in:
rofl0r committed 2020-01-15 16:09:41 +00:00
1 parent bffa705005
commit c63d5d26b4
11 files changed
+107 -103

No files matched your search

+4 -4
View File
@@ -122,14 +122,14 @@ char *reverse_rewrite_url (struct conn_s *connptr, hashmap_t hashofheaders,
/* Reverse requests always start with a slash */
if (*url == '/') {
/* First try locating the reverse mapping by request url */
reverse = reversepath_get (url, config.reversepath_list);
reverse = reversepath_get (url, config->reversepath_list);
if (reverse) {
rewrite_url = (char *)
safemalloc (strlen (url) + strlen (reverse->url) +
1);
strcpy (rewrite_url, reverse->url);
strcat (rewrite_url, url + strlen (reverse->path));
} else if (config.reversemagic
} else if (config->reversemagic
&& hashmap_entry_by_key (hashofheaders,
"cookie",
(void **) &cookie) > 0) {
@@ -139,7 +139,7 @@ char *reverse_rewrite_url (struct conn_s *connptr, hashmap_t hashofheaders,
&& (reverse =
reversepath_get (cookieval +
strlen (REVERSE_COOKIE) + 1,
config.reversepath_list)))
config->reversepath_list)))
{
rewrite_url = (char *) safemalloc
@@ -163,7 +163,7 @@ char *reverse_rewrite_url (struct conn_s *connptr, hashmap_t hashofheaders,
log_message (LOG_CONN, "Rewriting URL: %s -> %s", url, rewrite_url);
/* Store reverse path so that the magical tracking cookie can be set */
if (config.reversemagic && reverse)
if (config->reversemagic && reverse)
connptr->reversepath = safestrdup (reverse->path);
return rewrite_url;