Add a reversepath argument to reversepath_get().

This abstracts the setter/getter functions for the reversepath
list from the concrete list in config.reversepath_list.

Michael
This commit is contained in:
Michael Adam 2009-12-06 22:59:08 +01:00
parent 624d146cd6
commit 3f1201c8b3
2 changed files with 7 additions and 7 deletions

View File

@ -80,10 +80,8 @@ void reversepath_add (const char *path, const char *url,
/* /*
* Check if a request url is in the reversepath list * Check if a request url is in the reversepath list
*/ */
struct reversepath *reversepath_get (char *url) struct reversepath *reversepath_get (char *url, struct reversepath *reverse)
{ {
struct reversepath *reverse = config.reversepath_list;
while (reverse) { while (reverse) {
if (strstr (url, reverse->path) == url) if (strstr (url, reverse->path) == url)
return reverse; return reverse;
@ -108,7 +106,7 @@ char *reverse_rewrite_url (struct conn_s *connptr, hashmap_t hashofheaders,
/* Reverse requests always start with a slash */ /* Reverse requests always start with a slash */
if (*url == '/') { if (*url == '/') {
/* First try locating the reverse mapping by request url */ /* First try locating the reverse mapping by request url */
reverse = reversepath_get (url); reverse = reversepath_get (url, config.reversepath_list);
if (reverse) { if (reverse) {
rewrite_url = (char *) rewrite_url = (char *)
safemalloc (strlen (url) + strlen (reverse->url) + safemalloc (strlen (url) + strlen (reverse->url) +
@ -124,8 +122,9 @@ char *reverse_rewrite_url (struct conn_s *connptr, hashmap_t hashofheaders,
if ((cookieval = strstr (cookie, REVERSE_COOKIE "=")) if ((cookieval = strstr (cookie, REVERSE_COOKIE "="))
&& (reverse = && (reverse =
reversepath_get (cookieval + reversepath_get (cookieval +
strlen (REVERSE_COOKIE) + strlen (REVERSE_COOKIE) + 1,
1))) { config.reversepath_list)))
{
rewrite_url = (char *) safemalloc rewrite_url = (char *) safemalloc
(strlen (url) + (strlen (url) +

View File

@ -33,7 +33,8 @@ struct reversepath {
extern void reversepath_add (const char *path, const char *url, extern void reversepath_add (const char *path, const char *url,
struct reversepath **reversepath_list); struct reversepath **reversepath_list);
extern struct reversepath *reversepath_get (char *url); extern struct reversepath *reversepath_get (char *url,
struct reversepath *reverse);
extern char *reverse_rewrite_url (struct conn_s *connptr, extern char *reverse_rewrite_url (struct conn_s *connptr,
hashmap_t hashofheaders, char *url); hashmap_t hashofheaders, char *url);