PA_LOCK(str, char *, buff); fileInfo = NET_cinfo_find_type(str);  str = fileInfo->type; if((appletName = NPL_FindAppletEnabledForMimetype(str)) != NULL) {  type = LO_EMBED; sub_type = LO_JAVA;     lo_SetArgs((char*)tag->data, top); lo_RemoveParam(tag, "type"); lo_RemoveParam(tag, "src"); lo_RemoveParam(tag, "data"); lo_AddParam(tag, "TYPE", JAVA_PLUGIN_MIMETYPE); lo_AddParam(tag, "CODE", appletName);   if(top->clone_tag) { lo_AddParam(top->clone_tag, "CODE", appletName); lo_RemoveParam(top->clone_tag, "type"); lo_RemoveParam(top->clone_tag, "src"); lo_RemoveParam(top->clone_tag, "data"); lo_AddParam(top->clone_tag, "TYPE", JAVA_PLUGIN_MIMETYPE); }  XP_FREE(appletName);			 } if(buff) XP_FREE(buff); }
if (buff) { PA_LOCK(str, char *, buff); fileInfo = NET_cinfo_find_type(str);  str = fileInfo->type; if((appletName = NPL_FindAppletEnabledForMimetype(str)) != NULL) {  type = LO_EMBED; sub_type = LO_JAVA;     lo_SetArgs((char*)tag->data, top); lo_RemoveParam(tag, "type"); lo_RemoveParam(tag, "src"); lo_RemoveParam(tag, "data"); lo_AddParam(tag, "TYPE", JAVA_PLUGIN_MIMETYPE); lo_AddParam(tag, "CODE", appletName);   if(top->clone_tag) { lo_AddParam(top->clone_tag, "CODE", appletName); lo_RemoveParam(top->clone_tag, "type"); lo_RemoveParam(top->clone_tag, "src"); lo_RemoveParam(top->clone_tag, "data"); lo_AddParam(top->clone_tag, "TYPE", JAVA_PLUGIN_MIMETYPE); } XP_FREE(appletName);			 } if(buff) XP_FREE(buff); } }
lo_FormatObject(MWContext* context, lo_DocState* state, PA_Tag* tag){	lo_TopState* top_state = state->top_state;	lo_ObjectStack* top;	LO_ObjectStruct* object;	PA_Block buff;	int16 type = LO_NONE;	int16 sub_type = LO_NONE;	char* str;	char* pluginName;#ifdef	ANTHRAX	char* appletName;	NET_cinfo* fileInfo;#endif /* ANTHRAX */		/*	 * Make a new default object.  Passing LO_OBJECT will create an	 * LO_Element, which being a union of all other layout element types	 * is guaranteed to be big enough to transmogrify into one of these	 * specific types later if necessary.	 */	object = (LO_ObjectStruct*) lo_NewElement(context, state, LO_OBJECT, NULL, 0);	if (object == NULL)	{		state->top_state->out_of_memory = TRUE;		return;	}		top = top_state->object_stack;	top->object = object;	/*	 * Set up default fields for this object that are common	 * to all possible object types.	 */	object->lo_element.lo_plugin.type = LO_NONE;	object->lo_element.lo_plugin.ele_id = NEXT_ELEMENT;	object->lo_element.lo_plugin.x = state->x;	object->lo_element.lo_plugin.x_offset = 0;	object->lo_element.lo_plugin.y = state->y;	object->lo_element.lo_plugin.y_offset = 0;	object->lo_element.lo_plugin.width = 0;	object->lo_element.lo_plugin.height = 0;	object->lo_element.lo_plugin.next = NULL;	object->lo_element.lo_plugin.prev = NULL;		/*	 * Now attempt to figure out what type of object we have.	 * If the type can be determined here, great; otherwise	 * we have to block until the type can be determined by	 * reading in additional data.	 *	 * Initially the type of the object is LO_NONE.  When	 * we figure out enough to know the type, we set it to	 * LO_EMBED, LO_JAVA, or LO_IMAGE.  If the type had	 * already been changed to a different incompatible type,	 * then the tag is malformed and we should ignore it, so	 * set the type to LO_UNKNOWN.	 */	#if 0 	/*	 * Check the "codetype" attribute, which optionally determines	 * the MIME type of the object code itself (as opposed to its	 * data).  The only code type we know about right now is	 * application/java-vm for Java applets.	 */	buff = lo_FetchParamValue(context, tag, PARAM_CODETYPE);	if (buff != NULL)	{		PA_LOCK(str, char *, buff);		if (pa_TagEqual(APPLICATION_JAVAVM, str))		{			/* It's a Java applet */			if (type == LO_NONE)				type = LO_JAVA;			else if (type != LO_JAVA)				type = LO_UNKNOWN;		}		else if (pa_TagEqual(APPLICATION_OLEOBJECT, str) ||				 pa_TagEqual(APPLICATION_OLEOBJECT2, str))		{			/* It's an OLE object */			if (type == LO_NONE)				type = LO_EMBED;			else if (type != LO_EMBED)				type = LO_UNKNOWN;		}		PA_UNLOCK(buff);		XP_FREE(buff);	}#endif	/*	 * Check the "classid" attribute, which optionally determines	 * the specific implementation of the object.  The classid	 * could be a normal URL, in which case we have to retrieve	 * that URL and match it against a known code type (see above).	 * There are also two "magic" URL types supported for classid:	 * "clsid:", which indicates a COM 376-hex-digit class ID,	 * and "java:", which indicates a specific java class to run.	 * Note that the "java:" URL is different from the APPLET	 * "code" attribute: the "java:" URL specifies a particular	 * method (e.g. "java:program.run"), while the APPLET CODE	 * attribute specifies an applet subclass (e.g. "MyApplet.class").     *     * Further notes about "java:"     * We are adding two related "magic" protocol selectors to     * augment "java:". These are "javaprogram:" and "javabean:".     * They are used with embedded applications and application     * objects. "javaprogram:" identifies an object as being a     * subclass of netscape.application.Application, and is used     * to start an instance of such application. "javabean:" is     * used to add an embedded object to an application.	 */	buff = lo_FetchParamValue(context, tag, PARAM_CLASSID);	if (buff != NULL)	{		PA_LOCK(str, char *, buff);		if (XP_STRNCASECMP(str, "clsid:", 6) == 0)		{			/*			 * It's a COM class ID, so make sure we have an			 * appropriate plug-in to handle ActiveX controls.			 */			if ((pluginName = NPL_FindPluginEnabledForType(APPLICATION_OLEOBJECT)) != NULL)			{				XP_FREE(pluginName);				if (type == LO_NONE)					type = LO_EMBED;				else if (type != LO_EMBED)					type = LO_UNKNOWN;			}		}		else if ( (XP_STRNCASECMP(str, "java:", 5) == 0) ||                  (XP_STRNCASECMP(str, "javaprogram:", 12) == 0) ||                  (XP_STRNCASECMP(str, "javabean:", 9) == 0) )		{			/* It's a Java class */#ifdef OJI			if (type == LO_NONE)   {				 type = LO_EMBED;     sub_type = LO_JAVA;   }			else if (type != LO_EMBED) /* XXX */#else			if (type == LO_NONE)				type = LO_JAVA;			else if (type != LO_JAVA)#endif				type = LO_UNKNOWN;		}		else		{			/*			 * Must be a URL to the code; we'll need to fetch it to			 * determine the type.  bing: How should we do this?			 */		}		PA_UNLOCK(buff);		XP_FREE(buff);	}	/*	 * Check the "type" attribute, which optionally determines	 * the type of the data for the object.  The data type	 * can be used to infer the object implementation type if	 * the implementation hasn't been specified via "classid"	 * or "codetype" (see above).  The two kinds of objects	 * we currently support with typed data are plug-ins and	 * images; for plug-ins we can ask libplug if the type is	 * currently handled by a plug-in; for images we just check	 * against a hard-coded list of image types we natively	 * support (yuck).	 */	buff = lo_FetchParamValue(context, tag, PARAM_TYPE);	if (buff != NULL)	{		PA_LOCK(str, char *, buff);		if ((pluginName = NPL_FindPluginEnabledForType(str)) != NULL)		{		XP_FREE(pluginName);			/* It's a plug-in */			if (type == LO_NONE)   {				type = LO_EMBED;#ifdef OJI#define JAVA_PLUGIN_MIMETYPE "application/x-java-vm"			 if (XP_STRCMP(JAVA_PLUGIN_MIMETYPE, str)==0)    {      sub_type = LO_JAVA;    }#endif   }			else if (type != LO_EMBED)				type = LO_UNKNOWN;		}		/*  			Adding a check for applets that handle mimetypes.			The pref is stored based on the particular mimetype.			We do a lookup and if there is an association, the name			of the applet is placed into "appletName".  						NOTE: NPL_FindAppletEnabledForMimetype() allocates memory for appletName					and we must free it.								9.23.97		amusil		*/#ifdef	ANTHRAX		if((appletName = NPL_FindAppletEnabledForMimetype(str)) != NULL)			{			/* Set the type */			type = LO_EMBED;			sub_type = LO_JAVA;						/* set the CLASSID to whatever was put into "appletName" */			/*lo_SetClassID(tag, appletName);*/						lo_AddParam(tag, "CODE", appletName);			lo_SetArgs((char*)tag->data, top);			lo_RemoveParam(tag, "type");			lo_RemoveParam(tag, "src");			lo_RemoveParam(tag, "data");			lo_AddParam(tag, "TYPE", JAVA_PLUGIN_MIMETYPE);												/* do the same for the clone_tag */			if(top->clone_tag)				{				lo_AddParam(top->clone_tag, "CODE", appletName);				lo_RemoveParam(top->clone_tag, "type");				lo_RemoveParam(top->clone_tag, "src");				lo_RemoveParam(top->clone_tag, "data");				lo_AddParam(top->clone_tag, "TYPE", JAVA_PLUGIN_MIMETYPE);				}						/* set this so that we know later to translate the DATA/SRC param to a Java arg */			XP_FREE(appletName);			}#endif	/* ANTHRAX */			#if 0		else if (XP_STRNCASECMP(str, "image/", 6) == 0)		{			if (XP_STRCASECMP(str, IMAGE_GIF) ||				XP_STRCASECMP(str, IMAGE_JPG) ||				XP_STRCASECMP(str, IMAGE_PJPG) ||				XP_STRCASECMP(str, IMAGE_XBM) ||				XP_STRCASECMP(str, IMAGE_XBM2) ||				XP_STRCASECMP(str, IMAGE_XBM3))			{				/* It's an image */				if (type == LO_NONE)					type = LO_IMAGE;				else if (type != LO_IMAGE)					type = LO_UNKNOWN;			}		}#endif /* if 0 */		if (XP_STRNCASECMP(str, "builtin/", 8) == 0)		{			if (type == LO_NONE)				type = LO_BUILTIN;			else if (type != LO_BUILTIN)				type = LO_UNKNOWN;		}		PA_UNLOCK(buff);		XP_FREE(buff);	}#ifdef	ANTHRAX	else /* we didn't find a TYPE param, so check the filename to get the type - amusil */		{		buff = lo_FetchParamValue(context, tag, PARAM_SRC);		/* if no src, check if there's a DATA param */		if(buff == NULL)			buff = lo_FetchParamValue(context, tag, PARAM_DATA);							/* extract the mimetype info */		PA_LOCK(str, char *, buff);		fileInfo = NET_cinfo_find_type(str);				str = fileInfo->type;		if((appletName = NPL_FindAppletEnabledForMimetype(str)) != NULL)			{			/* Set the type */			type = LO_EMBED;			sub_type = LO_JAVA;						/* set the CLASSID to whatever was put into "appletName" */			/*lo_SetClassID(tag, appletName);*/						lo_SetArgs((char*)tag->data, top);			lo_RemoveParam(tag, "type");			lo_RemoveParam(tag, "src");			lo_RemoveParam(tag, "data");			lo_AddParam(tag, "TYPE", JAVA_PLUGIN_MIMETYPE);			lo_AddParam(tag, "CODE", appletName);						/* do the same for the clone_tag */			if(top->clone_tag)				{				lo_AddParam(top->clone_tag, "CODE", appletName);				lo_RemoveParam(top->clone_tag, "type");				lo_RemoveParam(top->clone_tag, "src");				lo_RemoveParam(top->clone_tag, "data");				lo_AddParam(top->clone_tag, "TYPE", JAVA_PLUGIN_MIMETYPE);				}						XP_FREE(appletName);			/* do we need to free this regardless? */			}		if(buff)			XP_FREE(buff);		}#endif	/* ANTRHAX */	if (type == LO_EMBED)	{		object->lo_element.lo_plugin.type = LO_EMBED;  		if(sub_type == LO_JAVA)  		{    	object->lo_element.lo_plugin.sub_type = LO_JAVA;  		}	}	else if (type == LO_BUILTIN)	{		object->lo_element.type = LO_BUILTIN;	}#ifdef JAVA	else if (type == LO_JAVA)	{		if (LJ_GetJavaEnabled() != FALSE)		{			/*			 * Close out the current applet if necessary			 * (people tend to forget "</APPLET>").			 */			if (state->current_java != NULL)				lo_CloseJavaApp(context, state, state->current_java);							object->lo_element.lo_plugin.type = LO_JAVA;			lo_FormatJavaObject(context, state, tag, (LO_JavaAppStruct*) object);		}	}#endif /* JAVA */#if 0	else if (type == LO_IMAGE)	{		object->lo_element.lo_plugin.type = LO_IMAGE;		lo_FormatImageObject(context, state, tag, (LO_ImageStruct*) object);	}#endif /* if 0 */	else	{		/*		 * Check for a "data" attribute; if it exists, we can get		 * the URL later to see what the type of the object should be.		 */		buff = lo_FetchParamValue(context, tag, PARAM_DATA);		if (buff != NULL)		{			PA_LOCK(str, char *, buff);			if (XP_STRNCASECMP(str, "data:", 5) == 0)			{				/* bing: deal with magic data URLs here */				PA_UNLOCK(buff);				XP_FREE(buff);			}			else			{								/*				 * Block layout until we can read the PARAM tags				 * and closing </OBJECT> tag, go get the data URL,				 * and determine its type.  At that point (in				 * either LO_NewObjectStream, or lo_ObjectURLExit),				 * we know the object type and can unblock.				 */				top->data_url = str;				state->top_state->layout_blocking_element = (LO_Element*) object;				PA_UNLOCK(buff);				/* Don't free buff; we stored it in the object stack */			}		}		else		{			/*			 * Otherwise we just don't know what to do with this!			 */			object->lo_element.lo_plugin.type = LO_UNKNOWN;		}	}}