|
From: Ian P. <piu...@us...> - 2004-04-06 18:27:15
|
Update of /cvsroot/squeak/squeak/platforms/unix/npsqueak In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7725 Modified Files: npsqueak.c Log Message: Handle imageName and failureUrl tags when loading NPSqueak plugin. Index: npsqueak.c =================================================================== RCS file: /cvsroot/squeak/squeak/platforms/unix/npsqueak/npsqueak.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** npsqueak.c 7 Aug 2003 02:44:53 -0000 1.3 --- npsqueak.c 6 Apr 2004 18:14:23 -0000 1.4 *************** *** 5,11 **** * Author: Bert Freudenberg <be...@is...> * ! * Last edited: Wed 02 Oct 2002 14:43:26 by bert on balloon * * History: * Oct 2002 - system-wide install * Sep 2002 - create hard links for streamed files --- 5,12 ---- * Author: Bert Freudenberg <be...@is...> * ! * Last edited: 2004-04-06 20:19:06 by piumarta on emilia.local * * History: + * Apr 2004 - (ikp) handle imageName and failureUrl tags * Oct 2002 - system-wide install * Sep 2002 - create hard links for streamed files *************** *** 106,109 **** --- 107,111 ---- char* srcFilename; int srcId; /* if requested */ + char *failureUrl; } SqueakPlugin; *************** *** 178,181 **** --- 180,184 ---- SqueakPlugin *plugin; char basedir[PATH_MAX]; + char *failureUrl= 0; if (instance == NULL) return NPERR_INVALID_INSTANCE_ERROR; *************** *** 208,211 **** --- 211,215 ---- plugin->srcFilename= NULL; plugin->srcId= -1; + plugin->failureUrl= 0; strcpy(plugin->vmName, basedir); strcat(plugin->vmName, "npsqueakvm"); *************** *** 224,227 **** --- 228,240 ---- int i; for (i= 0; i < argc; i++) { + if (!strcasecmp(argn[i], "imagename")) + { + strcpy(plugin->imageName, basedir); + strcat(plugin->imageName, argv[i]); + NPN_MemFree(plugin->argv[6]); + plugin->argv[6]= NPN_StrDup(plugin->imageName); + } + else if (!strcasecmp(argn[i], "failureurl")) + failureUrl= argv[i]; plugin->argv[plugin->argc++]= NPN_StrDup(argn[i]); plugin->argv[plugin->argc++]= NPN_StrDup(argv[i] ? argv[i] : ""); *************** *** 231,239 **** if (!plugin->srcUrl) plugin->srcUrl= NPN_StrDup(""); /* we were embedded without a SRC */ } else { /* if not embedded srcUrl will be set in NewStream */ plugin->srcUrl= NULL; } ! plugin->argv[plugin->argc]= 0; if (pipe(&plugin->pipes[SQUEAK_READ]) || pipe(&plugin->pipes[PLUGIN_READ])) { --- 244,262 ---- if (!plugin->srcUrl) plugin->srcUrl= NPN_StrDup(""); /* we were embedded without a SRC */ + if (access(plugin->imageName, R_OK)) + { + if (failureUrl) + plugin->failureUrl= NPN_StrDup(failureUrl); + else + { + fprintf(stderr, "Squeak Plugin: Image file not found: %s\n", plugin->imageName); + return NPERR_GENERIC_ERROR; + } + } } else { /* if not embedded srcUrl will be set in NewStream */ plugin->srcUrl= NULL; } ! plugin->argv[plugin->argc]= 0; if (pipe(&plugin->pipes[SQUEAK_READ]) || pipe(&plugin->pipes[PLUGIN_READ])) { *************** *** 279,282 **** --- 302,309 ---- plugin->srcFilename= NULL; } + if (plugin->failureUrl) { + NPN_MemFree(plugin->failureUrl); + plugin->failureUrl= NULL; + } if (plugin->argv) { for (i=0; i<plugin->argc; i++) { *************** *** 307,310 **** --- 334,339 ---- if (!plugin) return NPERR_GENERIC_ERROR; + if (plugin->failureUrl) + return NPERR_NO_ERROR; if (pNPWindow == NULL) return NPERR_NO_ERROR; *************** *** 326,341 **** { SqueakPlugin *plugin= (SqueakPlugin*) instance->pdata; ! DPRINT("NP: NewStream(%s, id=%i)\n", stream->url, stream->notifyData ? ((SqueakStream*) stream->notifyData)->id : -1); ! if (!stream->notifyData && !plugin->srcUrl) { ! /* We did not request this stream, so it is our SRC file. */ ! plugin->srcUrl= NPN_StrDup(stream->url); ! plugin->argv[plugin->argc++]= NPN_StrDup("SRC"); ! plugin->argv[plugin->argc++]= NPN_StrDup(plugin->srcUrl); ! DPRINT("NP: got srcUrl=%s\n", plugin->srcUrl); ! Run(plugin); ! } ! ! *stype= NP_ASFILEONLY; /* We want the file after download */ return NPERR_NO_ERROR; } --- 355,374 ---- { SqueakPlugin *plugin= (SqueakPlugin*) instance->pdata; ! DPRINT("NP: NewStream(%s, id=%i)\n", stream->url, stream->notifyData ? ((SqueakStream*) stream->notifyData)->id : -1); ! if (plugin->failureUrl) ! NPN_GetURL(instance, plugin->failureUrl, "_self"); ! else ! { ! if (!stream->notifyData && !plugin->srcUrl) { ! /* We did not request this stream, so it is our SRC file. */ ! plugin->srcUrl= NPN_StrDup(stream->url); ! plugin->argv[plugin->argc++]= NPN_StrDup("SRC"); ! plugin->argv[plugin->argc++]= NPN_StrDup(plugin->srcUrl); ! DPRINT("NP: got srcUrl=%s\n", plugin->srcUrl); ! Run(plugin); ! } ! *stype= NP_ASFILEONLY; /* We want the file after download */ ! } return NPERR_NO_ERROR; } *************** *** 516,520 **** Run(SqueakPlugin *plugin) { ! if (plugin->pid || !plugin->nswindow || !plugin->srcUrl) return; --- 549,553 ---- Run(SqueakPlugin *plugin) { ! if (plugin->pid || !plugin->nswindow || !plugin->srcUrl || plugin->failureUrl) return; |