	If a proxy is defined, the W3Aprocess and W3Asubprocess
	functions will insert it in fron of the URL. But before they
	do so, they check if the host is in the noproxy resource, by
	calling [[in_noproxy_list]].

<<*>>=
#include "config.h"
#include <Xm/Xm.h>
#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;
    }
}
