1 line
16 KiB
C
1 line
16 KiB
C
|
/* Copyright (c) 2017, Computer History Museum
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted (subject to
the limitations in the disclaimer below) provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of Computer History Museum nor the names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE
COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE. */
/* Copyright (c) 1996 by Qualcomm, Inc. */
#include "netscapeplugins.h"
#include "npapi.h"
#include "npupp.h"
// !! This area needs work !!
static Byte sPluginFolder[] = "\pNetscape Plug-ins";
#define OPEN_NPLUGIN OPEN_SETTINGS
#define FILE_NUM 82
// <09><> Constants <20><>
enum { kMinorVersion = NPVERS_HAS_STREAMOUTPUT }; // This is the minimum version of Netscape we support
enum { kPluginResType = 'NSPL', kPluginResID = 128 }; // Code resource for 68K code
#pragma segment NPLUGINS
// <09><> Structs <20><>
// Info for an active plugin
typedef struct
{
ConnectionID connID; // Used for PPC code
Handle hCode; // Used for 68K code
short fRefNum; // Resource file refnum
NPPluginFuncs pluginFuncs;
NPP_ShutdownUPP unloadFunc;
NPSavedData *savedData;
} ActivePluginInfo, *ActivePluginPtr, **ActivePluginHandle;
typedef struct
{
NPWindow wind;
NP_Port npPort;
} ndataRec;
// Info for each plugin file
typedef struct
{
Str32 fileName;
Handle hMIMEandFileExt; // STR# resource 128
short instanceCount; // How many instances are active?
ActivePluginHandle hData;
} PluginFileInfo, *PluginFilePtr, **PluginFileHandle;
typedef struct
{
short pluginIdx; // Index into ghPlugins
NPP_t instance;
} InstanceInfo, *InstancePtr, **InstanceHandle;
// <09><> Globals <20><>
static short gPluginCount;
static PluginFileHandle ghPlugins;
static short gPVRefNum;
static long gPDirID;
static NPNetscapeFuncs gNetscapeFuncs;
// <09><> Prototypes <20><>
static void GetToken(StringPtr sPtr,StringPtr sToken,short *pIdx);
static Boolean InitPlugin(PluginFilePtr pPlugin);
static void RegisterPlugins(void);
/**********************************************************************
* CheckNetscapePlugin - Find any Netscape plugins
**********************************************************************/
Handle NPluginCheck(FSSpec *pSpec, Rect *pRect)
{
// Find a .extension
short i;
Str32 sExtension;
Str32 sToken;
StringPtr sPtr;
InstanceHandle hInstance=nil;
Str255 sMIMEcstring;
RegisterPlugins();
for(i=*pSpec->name,sPtr=pSpec->name+i;i;i--)
{
if (*sPtr--=='.')
{
BMD(sPtr+2,sExtension+1,*sExtension=*pSpec->name-i);
break;
}
}
if (i)
{
// Search for the plugin
short plugin;
for(plugin=0;plugin<gPluginCount;plugin++)
{
Handle hStrings;
short count,idx;
hStrings = (*ghPlugins)[plugin].hMIMEandFileExt;
sPtr = (StringPtr)*hStrings;
count = *(s
|