📄 npunix.c
字号:
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- * * The contents of this file are subject to the Mozilla Public * License Version 1.1 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * implied. See the License for the specific language governing * rights and limitations under the License. * * The Original Code is mozilla.org code. * * The Initial Developer of the Original Code is Netscape * Communications Corporation. Portions created by Netscape are * Copyright (C) 1998 Netscape Communications Corporation. All * Rights Reserved. * * Contributor(s): * Stephen Mak <smak@sun.com> *//* * npunix.c * * Netscape Client Plugin API * - Wrapper function to interface with the Netscape Navigator * * dp Suresh <dp@netscape.com> * *---------------------------------------------------------------------- * PLUGIN DEVELOPERS: * YOU WILL NOT NEED TO EDIT THIS FILE. * TO NETSCAPE DEVELOPERS: * OF COURSE I WILL NEED TO EDIT THIS FILE, YOU BORKED IT ALL AROUND YOU * IGNORANT FOOLS -- sam *---------------------------------------------------------------------- */#define XP_UNIX 1#define OJI 1#include <stdio.h>#include <npapi.h>#include <npupp.h>/* * Define PLUGIN_TRACE to have the wrapper functions print * messages to stderr whenever they are called. */#ifdef PLUGIN_TRACE#include <stdio.h>#define PLUGINDEBUGSTR(msg) fprintf(stderr, "%s\n", msg)#else#define PLUGINDEBUGSTR(msg)#endif/*********************************************************************** * * Globals * ***********************************************************************/static NPNetscapeFuncs gNetscapeFuncs; /* Netscape Function table *//*********************************************************************** * * Wrapper functions : plugin calling Netscape Navigator * * These functions let the plugin developer just call the APIs * as documented and defined in npapi.h, without needing to know * about the function table and call macros in npupp.h. * ***********************************************************************/voidNPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major, int* netscape_minor){ *plugin_major = NP_VERSION_MAJOR; *plugin_minor = NP_VERSION_MINOR; /* Major version is in high byte */ *netscape_major = gNetscapeFuncs.version >> 8; /* Minor version is in low byte */ *netscape_minor = gNetscapeFuncs.version & 0xFF;}NPErrorNPN_GetValue(NPP instance, NPNVariable variable, void *r_value){ return CallNPN_GetValueProc(gNetscapeFuncs.getvalue, instance, variable, r_value);}NPErrorNPN_SetValue(NPP instance, NPPVariable variable, void *value){ return CallNPN_SetValueProc(gNetscapeFuncs.setvalue, instance, variable, value);}NPErrorNPN_GetURL(NPP instance, const char* url, const char* window){ return CallNPN_GetURLProc(gNetscapeFuncs.geturl, instance, url, window);}NPErrorNPN_GetURLNotify(NPP instance, const char* url, const char* window, void* notifyData){ return CallNPN_GetURLNotifyProc(gNetscapeFuncs.geturlnotify, instance, url, window, notifyData);}NPErrorNPN_PostURL(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file){ return CallNPN_PostURLProc(gNetscapeFuncs.posturl, instance, url, window, len, buf, file);}NPErrorNPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file, void* notifyData){ return CallNPN_PostURLNotifyProc(gNetscapeFuncs.posturlnotify, instance, url, window, len, buf, file, notifyData);}NPErrorNPN_RequestRead(NPStream* stream, NPByteRange* rangeList){ return CallNPN_RequestReadProc(gNetscapeFuncs.requestread, stream, rangeList);}NPErrorNPN_NewStream(NPP instance, NPMIMEType type, const char *window, NPStream** stream_ptr){ return CallNPN_NewStreamProc(gNetscapeFuncs.newstream, instance, type, window, stream_ptr);}int32NPN_Write(NPP instance, NPStream* stream, int32 len, void* buffer){ return CallNPN_WriteProc(gNetscapeFuncs.write, instance, stream, len, buffer);}NPErrorNPN_DestroyStream(NPP instance, NPStream* stream, NPError reason){ return CallNPN_DestroyStreamProc(gNetscapeFuncs.destroystream, instance, stream, reason);}voidNPN_Status(NPP instance, const char* message){ CallNPN_StatusProc(gNetscapeFuncs.status, instance, message);}const char*NPN_UserAgent(NPP instance){ return CallNPN_UserAgentProc(gNetscapeFuncs.uagent, instance);}void*NPN_MemAlloc(uint32 size){ return CallNPN_MemAllocProc(gNetscapeFuncs.memalloc, size);}void NPN_MemFree(void* ptr){ CallNPN_MemFreeProc(gNetscapeFuncs.memfree, ptr);}uint32 NPN_MemFlush(uint32 size){ return CallNPN_MemFlushProc(gNetscapeFuncs.memflush, size);}void NPN_ReloadPlugins(NPBool reloadPages){ CallNPN_ReloadPluginsProc(gNetscapeFuncs.reloadplugins, reloadPages);}JRIEnv* NPN_GetJavaEnv(){ return CallNPN_GetJavaEnvProc(gNetscapeFuncs.getJavaEnv);}jref NPN_GetJavaPeer(NPP instance){ return CallNPN_GetJavaPeerProc(gNetscapeFuncs.getJavaPeer, instance);}voidNPN_InvalidateRect(NPP instance, NPRect *invalidRect){ CallNPN_InvalidateRectProc(gNetscapeFuncs.invalidaterect, instance, invalidRect);}voidNPN_InvalidateRegion(NPP instance, NPRegion invalidRegion){ CallNPN_InvalidateRegionProc(gNetscapeFuncs.invalidateregion, instance, invalidRegion);}voidNPN_ForceRedraw(NPP instance){ CallNPN_ForceRedrawProc(gNetscapeFuncs.forceredraw, instance);}NPIdentifier NPN_GetStringIdentifier(const NPUTF8 *name){ int navMinorVers = gNetscapeFuncs.version & 0xFF; if( navMinorVers >= 14 ) { return CallNPN_GetStringIdentifierProc( gNetscapeFuncs.getstringidentifier, name); } return NULL;}void NPN_GetStringIdentifiers(const NPUTF8 **names, int32_t nameCount, NPIdentifier *identifiers){ int navMinorVers = gNetscapeFuncs.version & 0xFF; if( navMinorVers >= 14 ) { CallNPN_GetStringIdentifiersProc( gNetscapeFuncs.getstringidentifiers, names, nameCount, identifiers); }}NPIdentifier NPN_GetIntIdentifier(int32_t intid){ int navMinorVers = gNetscapeFuncs.version & 0xFF; if( navMinorVers >= 14 ) { return CallNPN_GetIntIdentifierProc( gNetscapeFuncs.getintidentifier, intid); } return NULL;}bool NPN_IdentifierIsString(NPIdentifier identifier){ int navMinorVers = gNetscapeFuncs.version & 0xFF; if( navMinorVers >= 14 ) { return CallNPN_IdentifierIsStringProc( gNetscapeFuncs.identifierisstring, identifier); } return false;}NPUTF8 *NPN_UTF8FromIdentifier(NPIdentifier identifier){ int navMinorVers = gNetscapeFuncs.version & 0xFF; if( navMinorVers >= 14 ) { return CallNPN_UTF8FromIdentifierProc( gNetscapeFuncs.utf8fromidentifier, identifier); } return NULL;}int32_t NPN_IntFromIdentifier(NPIdentifier identifier){ int navMinorVers = gNetscapeFuncs.version & 0xFF; if( navMinorVers >= 14 ) { return CallNPN_IntFromIdentifierProc( gNetscapeFuncs.intfromidentifier, identifier); } return 0;}NPObject *NPN_CreateObject(NPP instance, NPClass *aClass){ int navMinorVers = gNetscapeFuncs.version & 0xFF; if( navMinorVers >= 14 ) { return CallNPN_CreateObjectProc( gNetscapeFuncs.createobject, instance, aClass); } return NULL;}NPObject *NPN_RetainObject(NPObject *npobj){ int navMinorVers = gNetscapeFuncs.version & 0xFF; if( navMinorVers >= 14 ) { return CallNPN_RetainObjectProc( gNetscapeFuncs.retainobject, npobj); } return NULL;}void NPN_ReleaseObject(NPObject *npobj){ int navMinorVers = gNetscapeFuncs.version & 0xFF; if( navMinorVers >= 14 ) { CallNPN_ReleaseObjectProc( gNetscapeFuncs.releaseobject, npobj); }}bool NPN_Invoke(NPP instance, NPObject *npobj, NPIdentifier methodName, const NPVariant *args, uint32_t argCount, NPVariant *result){ int navMinorVers = gNetscapeFuncs.version & 0xFF; if( navMinorVers >= 14 ) { return CallNPN_InvokeProc( gNetscapeFuncs.invoke, instance, npobj, methodName, args, argCount, result); } return false;}bool NPN_InvokeDefault(NPP instance, NPObject *npobj, const NPVariant *args, uint32_t argCount, NPVariant *result){ int navMinorVers = gNetscapeFuncs.version & 0xFF; if( navMinorVers >= 14 ) { return CallNPN_InvokeDefaultProc( gNetscapeFuncs.invokeDefault, instance, npobj, args, argCount, result); } return false;}bool NPN_Evaluate(NPP instance, NPObject *npobj, NPString *script, NPVariant *result){ int navMinorVers = gNetscapeFuncs.version & 0xFF; if( navMinorVers >= 14 ) { return CallNPN_EvaluateProc( gNetscapeFuncs.evaluate, instance, npobj, script, result); } return false;}bool NPN_GetProperty(NPP instance, NPObject *npobj, NPIdentifier propertyName, NPVariant *result){ int navMinorVers = gNetscapeFuncs.version & 0xFF; if( navMinorVers >= 14 ) { return CallNPN_GetPropertyProc( gNetscapeFuncs.getproperty, instance, npobj, propertyName, result); } return false;}bool NPN_SetProperty(NPP instance, NPObject *npobj, NPIdentifier propertyName, const NPVariant *value){ int navMinorVers = gNetscapeFuncs.version & 0xFF; if( navMinorVers >= 14 ) { return CallNPN_SetPropertyProc( gNetscapeFuncs.setproperty, instance, npobj, propertyName, value); } return false;}bool NPN_RemoveProperty(NPP instance, NPObject *npobj, NPIdentifier propertyName){ int navMinorVers = gNetscapeFuncs.version & 0xFF;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -