#line 7 "proxy.c-nw" #include "config.h" #include #include "w3a.h" #include "str.h" #include "url.h" #include "globals.e" #define MAXHOSTS 100 /* in_noproxy_list -- check is a host is `localhost' or in the noproxy list */ EXPORT Bool in_noproxy_list(Strip host) { static Strip localhost = NULL; static Strip noproxy_hosts[MAXHOSTS]; static int nrhosts = 0; char *s, *t, *next; int i; if (!localhost) { /* Initialize */ localhost = str2strip("localhost"); if (appdata.noproxy) { s = newstring(appdata.noproxy); next = s; while (nrhosts < MAXHOSTS && (t = tokenize(next, " \t\n,", &next)) != NULL) noproxy_hosts[nrhosts++] = str2strip(t); dispose(s); } } if (hcase_eq(host, localhost)) return TRUE; for (i = 0; i < nrhosts; i++) if (hcase_eq(host, noproxy_hosts[i])) return TRUE; return FALSE; } /* insert_proxy -- insert possible proxy server in front of url */ EXPORT Bool insert_proxy(URI uri, char *url, char **newurl) { if (appdata.proxy && ! in_noproxy_list(uri.host)) { newarray(*newurl, strlen(appdata.proxy) + strlen(url) + 10); sprintf(*newurl, "proxy://%s/%s", appdata.proxy, url); return TRUE; } else { return FALSE; } }