NET_DisplayCookieInfoAsHTML(ActiveEntry * cur_entry) { char *buffer=(char*)PR_Malloc(BUFLEN), *expireDate=NULL; NET_StreamClass *stream; int i, g, numOfCookies; XP_List *list=net_cookie_list; net_CookieStruct *cookie;  if(!buffer) { cur_entry->status = MK_UNABLE_TO_CONVERT; return; }   StrAllocCopy(cur_entry->URL_s->content_type, TEXT_HTML);  cur_entry->format_out = CLEAR_CACHE_BIT(cur_entry->format_out); stream = NET_StreamBuilder(cur_entry->format_out, cur_entry->URL_s, cur_entry->window_id);  if(!stream) { cur_entry->status = MK_UNABLE_TO_CONVERT; PR_Free(buffer); return; }    #define PUT_PART(part)													\ cur_entry->status = (*stream->put_block)(stream,			\ part ? part : "Unknown",		\ part ? PL_strlen(part) : 7);	\ if(cur_entry->status < 0)												\ goto END;    net_remove_expired_cookies(); numOfCookies=XP_ListCount(net_cookie_list);   g = PR_snprintf(buffer, BUFLEN, "<TITLE>%s</TITLE>\n" "<h2>%s</h2>\n" "<TABLE>\n" "<TR>\n", XP_GetString(MK_ACCESS_YOUR_COOKIES), XP_GetString(MK_ACCESS_YOUR_COOKIES));  g += PR_snprintf(buffer+g, BUFLEN-g, "<TD ALIGN=RIGHT><b>%s</TD>\n" "<TD>%ld</TD>\n" "</TR>\n" "<TR>\n", XP_GetString(MK_ACCESS_MAXIMUM_COOKS), MAX_NUMBER_OF_COOKIES);  g += PR_snprintf(buffer+g, BUFLEN-g, "<TD ALIGN=RIGHT><b>%s</TD>\n" "<TD>%ld</TD>\n" "</TR>\n" "<TR>\n", XP_GetString(MK_ACCESS_COOK_COUNT), numOfCookies);  g += PR_snprintf(buffer+g, BUFLEN-g, "<TD ALIGN=RIGHT><b>%s</TD>\n" "<TD>%ld</TD>\n" "</TR>\n" "<TR>\n", XP_GetString(MK_ACCESS_MAXIMUM_COOKS_PER_SERV), MAX_COOKIES_PER_SERVER);  g += PR_snprintf(buffer+g, BUFLEN-g, "<TD ALIGN=RIGHT><b>%s</TD>\n" "<TD>%ld</TD>\n" "</TR>\n" "</TABLE>\n" "<HR>", XP_GetString(MK_ACCESS_MAXIMUM_COOK_SIZE), MAX_BYTES_PER_COOKIE);   PUT_PART(buffer);  if(!numOfCookies) { PL_strcpy(buffer, XP_GetString(MK_ACCESS_NO_COOKIES)); PUT_PART(buffer); goto END; }   #define HEADING(arg1)					\ PL_strcpy(buffer, "<tt>");			\ for(i=PL_strlen(arg1); i < 16; i++)	\ PL_strcat(buffer, "&nbsp;");	\ PL_strcat(buffer, arg1);			\ PL_strcat(buffer, " </tt>");		\ PUT_PART(buffer);  #define BRCRLF					\ PL_strcpy(buffer, "<BR>\n");		\ PUT_PART(buffer);    while ( (cookie=(net_CookieStruct *) XP_ListNextObject(list)) ) {  HEADING(XP_GetString(MK_ACCESS_NAME)); PL_strcpy(buffer, cookie->name); PUT_PART(buffer); BRCRLF;  HEADING(XP_GetString(MK_ACCESS_VALUE)); PL_strcpy(buffer, cookie->cookie); PUT_PART(buffer); BRCRLF;  HEADING(XP_GetString(MK_ACCESS_HOST)); PL_strcpy(buffer, cookie->host); PUT_PART(buffer); BRCRLF;  HEADING(XP_GetString(MK_ACCESS_SEND_TO_HOST)); if(cookie->is_domain) PL_strcpy(buffer, XP_GetString(MK_ACCESS_IS_DOMAIN)); else PL_strcpy(buffer, XP_GetString(MK_ACCESS_IS_NOT_DOMAIN)); PUT_PART(buffer); BRCRLF;  HEADING(XP_GetString(MK_ACCESS_SEND_TO_PATH)); PL_strcpy(buffer, cookie->path); PUT_PART(buffer); PL_strcpy(buffer, XP_GetString(MK_ACCESS_AND_BELOW)); PUT_PART(buffer); BRCRLF;  HEADING(XP_GetString(MK_ACCESS_SECURE)); if(cookie->secure) PL_strcpy(buffer, "Yes"); else PL_strcpy(buffer, "No"); PUT_PART(buffer); BRCRLF;  HEADING(XP_GetString(MK_ACCESS_EXPIRES)); if(cookie->expires) { expireDate=ctime(&(cookie->expires)); if(expireDate) PL_strcpy(buffer, expireDate); else PL_strcpy(buffer, "NULL"); } else { PL_strcpy(buffer, XP_GetString(MK_ACCESS_END_OF_SESSION)); } PUT_PART(buffer); PL_strcpy(buffer, " GMT"); PUT_PART(buffer); BRCRLF;  PL_strcpy(buffer, "\n<P>\n"); PUT_PART(buffer); }   END: PR_Free(buffer); if(cur_entry->status < 0) (*stream->abort)(stream, cur_entry->status); else (*stream->complete)(stream); return;
NET_DisplayCookieInfoAsHTML(ActiveEntry * cur_entry) {
NET_DisplayCookieInfoAsHTML(ActiveEntry * cur_entry) {	char *buffer=(char*)PR_Malloc(BUFLEN), *expireDate=NULL;   	NET_StreamClass *stream;	int i, g, numOfCookies;	XP_List *list=net_cookie_list;	net_CookieStruct *cookie;	if(!buffer) {		cur_entry->status = MK_UNABLE_TO_CONVERT;		return;	  }	/* The the current entry's content type */	StrAllocCopy(cur_entry->URL_s->content_type, TEXT_HTML);	cur_entry->format_out = CLEAR_CACHE_BIT(cur_entry->format_out);	stream = NET_StreamBuilder(cur_entry->format_out, 							   cur_entry->URL_s, 							   cur_entry->window_id);	if(!stream) {		cur_entry->status = MK_UNABLE_TO_CONVERT;		PR_Free(buffer);		return;	  }/* define a macro to push a string up the stream and handle errors */#define PUT_PART(part)													\cur_entry->status = (*stream->put_block)(stream,			\										part ? part : "Unknown",		\										part ? PL_strlen(part) : 7);	\	if(cur_entry->status < 0)												\	  goto END;/* End PUT_PART macro */	/* Get rid of any expired cookies now so user doesn't	 * think/see that we're keeping cookies in mem.	 */	net_remove_expired_cookies();	numOfCookies=XP_ListCount(net_cookie_list);	/* Write out the initial statistics. */	g = PR_snprintf(buffer, BUFLEN,"<TITLE>%s</TITLE>\n""<h2>%s</h2>\n""<TABLE>\n""<TR>\n",		XP_GetString(MK_ACCESS_YOUR_COOKIES),		XP_GetString(MK_ACCESS_YOUR_COOKIES));	g += PR_snprintf(buffer+g, BUFLEN-g,"<TD ALIGN=RIGHT><b>%s</TD>\n""<TD>%ld</TD>\n""</TR>\n""<TR>\n",		XP_GetString(MK_ACCESS_MAXIMUM_COOKS),		MAX_NUMBER_OF_COOKIES);	g += PR_snprintf(buffer+g, BUFLEN-g,"<TD ALIGN=RIGHT><b>%s</TD>\n""<TD>%ld</TD>\n""</TR>\n""<TR>\n",		XP_GetString(MK_ACCESS_COOK_COUNT),		numOfCookies);	g += PR_snprintf(buffer+g, BUFLEN-g,"<TD ALIGN=RIGHT><b>%s</TD>\n""<TD>%ld</TD>\n""</TR>\n""<TR>\n",		XP_GetString(MK_ACCESS_MAXIMUM_COOKS_PER_SERV),		MAX_COOKIES_PER_SERVER);	g += PR_snprintf(buffer+g, BUFLEN-g,"<TD ALIGN=RIGHT><b>%s</TD>\n""<TD>%ld</TD>\n""</TR>\n""</TABLE>\n""<HR>",		XP_GetString(MK_ACCESS_MAXIMUM_COOK_SIZE),		MAX_BYTES_PER_COOKIE);	PUT_PART(buffer);	if(!numOfCookies) {		PL_strcpy(buffer, XP_GetString(MK_ACCESS_NO_COOKIES));		PUT_PART(buffer);		goto END;	  }/* define some macros to help us output HTML */#define HEADING(arg1)					\	PL_strcpy(buffer, "<tt>");			\	for(i=PL_strlen(arg1); i < 16; i++)	\		PL_strcat(buffer, "&nbsp;");	\	PL_strcat(buffer, arg1);			\	PL_strcat(buffer, " </tt>");		\	PUT_PART(buffer);#define BRCRLF					\	PL_strcpy(buffer, "<BR>\n");		\	PUT_PART(buffer);/* End html macros */	/* Write out each cookie */	while ( (cookie=(net_CookieStruct *) XP_ListNextObject(list)) ) {		HEADING(XP_GetString(MK_ACCESS_NAME));		PL_strcpy(buffer, cookie->name);		PUT_PART(buffer);		BRCRLF;		HEADING(XP_GetString(MK_ACCESS_VALUE));		PL_strcpy(buffer, cookie->cookie);		PUT_PART(buffer);		BRCRLF;		HEADING(XP_GetString(MK_ACCESS_HOST));		PL_strcpy(buffer, cookie->host);		PUT_PART(buffer);		BRCRLF;		HEADING(XP_GetString(MK_ACCESS_SEND_TO_HOST));		if(cookie->is_domain)			PL_strcpy(buffer, XP_GetString(MK_ACCESS_IS_DOMAIN));		else			PL_strcpy(buffer, XP_GetString(MK_ACCESS_IS_NOT_DOMAIN));		PUT_PART(buffer);		BRCRLF;		HEADING(XP_GetString(MK_ACCESS_SEND_TO_PATH));		PL_strcpy(buffer, cookie->path);		PUT_PART(buffer);		PL_strcpy(buffer, XP_GetString(MK_ACCESS_AND_BELOW));		PUT_PART(buffer);		BRCRLF;		HEADING(XP_GetString(MK_ACCESS_SECURE));		if(cookie->secure)			PL_strcpy(buffer, "Yes");		else			PL_strcpy(buffer, "No");		PUT_PART(buffer);		BRCRLF;		HEADING(XP_GetString(MK_ACCESS_EXPIRES));		if(cookie->expires) {			expireDate=ctime(&(cookie->expires));			if(expireDate)				PL_strcpy(buffer, expireDate);			else				PL_strcpy(buffer, "NULL");		} else {			PL_strcpy(buffer, XP_GetString(MK_ACCESS_END_OF_SESSION));		}		PUT_PART(buffer);		PL_strcpy(buffer, " GMT");		PUT_PART(buffer);		BRCRLF;		PL_strcpy(buffer, "\n<P>\n");		PUT_PART(buffer);	}	/* End each cookie */END:	PR_Free(buffer);	if(cur_entry->status < 0)		(*stream->abort)(stream, cur_entry->status);	else		(*stream->complete)(stream);	return;}