verbose));
(char *) referer, verbose));
main(int argc, char *argv[]){	char		*ampersand;	App		*app;	unsigned char	*equals;	char		*name;	unsigned char	*newURL;	char		*p;	char		*query;	URL		*u;	unsigned char	*url;	char		*verbose;	View		*view;	if (!netInit())	{		return 1;	}	if (!threadInit())	{		return 1;	}	url = NULL;	verbose = "?url=";	query = getenv("QUERY_STRING");	app = appAlloc();	app->html = cgiviewHTML;	app->htmlAttributeName = cgiviewHTMLAttributeName;	app->htmlAttributeValue = cgiviewHTMLAttributeValue;	app->htmlTag = cgiviewHTMLTag;	app->htmlText = cgiviewHTMLText;	app->http = cgiviewHTTP;	app->httpBody = cgiviewHTTPBody;	app->httpHeaderName = cgiviewHTTPHeaderName;	app->httpHeaderValue = cgiviewHTTPHeaderValue;	view = &app->view;	view->out = stdout;	freopen("/dev/null", "w", stderr);	fprintf(view->out, "Content-Type: text/html\n");	fprintf(view->out, "\n");	if (query)	{		p = query;		do		{			name = p;			ampersand = strchr(p, '&');			if (ampersand)			{				*ampersand = 0;				p = ampersand + 1;			}			equals = (unsigned char *) strchr(name, '=');			if (equals)			{				*equals = 0;				if (!strcmp(name, "url"))				{					url = equals + 1;					urlDecode(url);				}				else if (!strcmp(name, "verbose"))				{					verbose = "?verbose=on&url=";					viewVerbose();				}			}		} while (ampersand);	}	else if (argc > 1)	{		url = (unsigned char *) argv[1];	}	else	{		fprintf(view->out, "no environment variable QUERY_STRING<br>\n");		fprintf(view->out, "and no arg passed<br>\n");		return 1;	}	if (url && (*url))	{		fprintf		(			view->out,			"<html><head><title>View %s</title></head>"				"<body><tt><b>\n",			url		);		viewReport(app, "input url:");		viewReport(app, (char *) url);		viewReportHTML(app, "<hr>");		u = urlParse(url);		if		(			((!u->scheme)||(!strcmp((char *) u->scheme, "http"))) &&			(!u->host) &&			(*url != '/')		)		{			newURL = calloc(strlen((char *) url) + 3, 1);			if (!newURL)			{				viewReport(app, "calloc failed");				return 1;			}			strcpy((char *) newURL, "//");			strcat((char *) newURL, (char *) url);		}		else		{			newURL = copyString(url);		}		urlFree(u);		u = urlParse(newURL);		if		(			(				(!u->scheme) ||				(!strcmp((char *) u->scheme, "http"))			) &&			(!*u->path)		)		{			url = newURL;			newURL = calloc(strlen((char *) url) + 2, 1);			if (!newURL)			{				viewReport(app, "calloc failed");				return 1;			}			strcpy((char *) newURL, (char *) url);			free(url);			strcat((char *) newURL, "/");		}		urlFree(u);		u = urlRelative(			(unsigned char *) "http://www.mozilla.org/index.html",			newURL);		free(newURL);		viewReport(app, "fully qualified url:");		viewReport(app, (char *) u->url);		viewReportHTML(app, "<hr>");		fflush(view->out);		if (!strcmp((char *) u->scheme, "http"))		{			httpProcess(app, u,				getHTTPRequestHeaders(app, (char *) u->host,				verbose));		}		else		{			fprintf			(				view->out,				"Sorry, %s URLs are not supported yet. "					"Only http URLs are supported.",				u->scheme			);		}		fprintf(view->out, "</b></tt></body></html>\n");	}	else	{		fprintf(view->out, "<html><head><title>SniffURI Error</title>");		fprintf(view->out, "</head><body><h2>Please enter a URI</h2>");		fprintf(view->out, "<a href=index.html>Go Back</a>");		fprintf(view->out, "</body></html>");	}	exit(0);	return 1;}