1
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2
/* ***** BEGIN LICENSE BLOCK *****
3
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
5
* The contents of this file are subject to the Netscape Public License
6
* Version 1.1 (the "License"); you may not use this file except in
7
* compliance with the License. You may obtain a copy of the License at
8
* http://www.mozilla.org/NPL/
10
* Software distributed under the License is distributed on an "AS IS" basis,
11
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
* for the specific language governing rights and limitations under the
15
* The Original Code is mozilla.org code.
17
* The Initial Developer of the Original Code is
18
* Netscape Communications Corporation.
19
* Portions created by the Initial Developer are Copyright (C) 1998
20
* the Initial Developer. All Rights Reserved.
24
* Alternatively, the contents of this file may be used under the terms of
25
* either the GNU General Public License Version 2 or later (the "GPL"), or
26
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27
* in which case the provisions of the GPL or the LGPL are applicable instead
28
* of those above. If you wish to allow use of your version of this file only
29
* under the terms of either the GPL or the LGPL, and not to allow others to
30
* use your version of this file under the terms of the NPL, indicate your
31
* decision by deleting the provisions above and replace them with the notice
32
* and other provisions required by the GPL or the LGPL. If you do not delete
33
* the provisions above, a recipient may use your version of this file under
34
* the terms of any one of the NPL, the GPL or the LGPL.
36
* ***** END LICENSE BLOCK ***** */
38
//////////////////////////////////////////////////////////////
40
// Main plugin entry point implementation
43
#include <npfunctions.h>
47
#define HIBYTE(x) ((((uint32_t)(x)) & 0xff00) >> 8)
50
NPNetscapeFuncs NPNFuncs;
54
NPError OSCALL NP_GetEntryPoints(NPPluginFuncs * pFuncs)
57
return NPERR_INVALID_FUNCTABLE_ERROR;
59
if (pFuncs->size < sizeof(NPPluginFuncs))
60
return NPERR_INVALID_FUNCTABLE_ERROR;
62
pFuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
63
pFuncs->newp = NPP_New;
64
pFuncs->destroy = NPP_Destroy;
65
pFuncs->setwindow = NPP_SetWindow;
66
pFuncs->newstream = NPP_NewStream;
67
pFuncs->destroystream = NPP_DestroyStream;
68
pFuncs->asfile = NPP_StreamAsFile;
69
pFuncs->writeready = NPP_WriteReady;
70
pFuncs->write = NPP_Write;
71
pFuncs->print = NPP_Print;
72
pFuncs->event = NPP_HandleEvent;
73
pFuncs->urlnotify = NPP_URLNotify;
74
pFuncs->getvalue = NPP_GetValue;
75
pFuncs->setvalue = NPP_SetValue;
76
pFuncs->javaClass = NULL;
78
return NPERR_NO_ERROR;
83
char *NPP_GetMIMEDescription();
85
char *NP_GetMIMEDescription()
87
return NPP_GetMIMEDescription();
90
NPError NP_GetValue(void *future, NPPVariable variable, void *value)
92
return NPP_GetValue((NPP_t *) future, variable, value);
95
NPError OSCALL NP_Initialize(NPNetscapeFuncs * pFuncs
97
, NPPluginFuncs * pluginFuncs
102
return NPERR_INVALID_FUNCTABLE_ERROR;
104
if (HIBYTE(pFuncs->version) > NP_VERSION_MAJOR)
105
return NPERR_INCOMPATIBLE_VERSION_ERROR;
107
if (pFuncs->size < sizeof(NPNetscapeFuncs))
108
return NPERR_INVALID_FUNCTABLE_ERROR;
110
NPNFuncs.size = pFuncs->size;
111
NPNFuncs.version = pFuncs->version;
112
NPNFuncs.geturlnotify = pFuncs->geturlnotify;
113
NPNFuncs.geturl = pFuncs->geturl;
114
NPNFuncs.posturlnotify = pFuncs->posturlnotify;
115
NPNFuncs.posturl = pFuncs->posturl;
116
NPNFuncs.requestread = pFuncs->requestread;
117
NPNFuncs.newstream = pFuncs->newstream;
118
NPNFuncs.write = pFuncs->write;
119
NPNFuncs.destroystream = pFuncs->destroystream;
120
NPNFuncs.status = pFuncs->status;
121
NPNFuncs.uagent = pFuncs->uagent;
122
NPNFuncs.memalloc = pFuncs->memalloc;
123
NPNFuncs.memfree = pFuncs->memfree;
124
NPNFuncs.memflush = pFuncs->memflush;
125
NPNFuncs.reloadplugins = pFuncs->reloadplugins;
126
NPNFuncs.getJavaEnv = pFuncs->getJavaEnv;
127
NPNFuncs.getJavaPeer = pFuncs->getJavaPeer;
128
NPNFuncs.getvalue = pFuncs->getvalue;
129
NPNFuncs.setvalue = pFuncs->setvalue;
130
NPNFuncs.invalidaterect = pFuncs->invalidaterect;
131
NPNFuncs.invalidateregion = pFuncs->invalidateregion;
132
NPNFuncs.forceredraw = pFuncs->forceredraw;
133
NPNFuncs.getstringidentifier = pFuncs->getstringidentifier;
134
NPNFuncs.getstringidentifiers = pFuncs->getstringidentifiers;
135
NPNFuncs.getintidentifier = pFuncs->getintidentifier;
136
NPNFuncs.identifierisstring = pFuncs->identifierisstring;
137
NPNFuncs.utf8fromidentifier = pFuncs->utf8fromidentifier;
138
NPNFuncs.intfromidentifier = pFuncs->intfromidentifier;
139
NPNFuncs.createobject = pFuncs->createobject;
140
NPNFuncs.retainobject = pFuncs->retainobject;
141
NPNFuncs.releaseobject = pFuncs->releaseobject;
142
NPNFuncs.invoke = pFuncs->invoke;
143
NPNFuncs.invokeDefault = pFuncs->invokeDefault;
144
NPNFuncs.evaluate = pFuncs->evaluate;
145
NPNFuncs.getproperty = pFuncs->getproperty;
146
NPNFuncs.setproperty = pFuncs->setproperty;
147
NPNFuncs.removeproperty = pFuncs->removeproperty;
148
NPNFuncs.hasproperty = pFuncs->hasproperty;
149
NPNFuncs.hasmethod = pFuncs->hasmethod;
150
NPNFuncs.releasevariantvalue = pFuncs->releasevariantvalue;
151
NPNFuncs.setexception = pFuncs->setexception;
155
* Set up the plugin function table that Netscape will use to
156
* call us. Netscape needs to know about our version and size
157
* and have a UniversalProcPointer for every function we
160
pluginFuncs->version = (NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR;
161
pluginFuncs->size = sizeof(NPPluginFuncs);
162
pluginFuncs->newp = NewNPP_NewProc(NPP_New);
163
pluginFuncs->destroy = NewNPP_DestroyProc(NPP_Destroy);
164
pluginFuncs->setwindow = NewNPP_SetWindowProc(NPP_SetWindow);
165
pluginFuncs->newstream = NewNPP_NewStreamProc(NPP_NewStream);
166
pluginFuncs->destroystream = NewNPP_DestroyStreamProc(NPP_DestroyStream);
167
pluginFuncs->asfile = NewNPP_StreamAsFileProc(NPP_StreamAsFile);
168
pluginFuncs->writeready = NewNPP_WriteReadyProc(NPP_WriteReady);
169
pluginFuncs->write = NewNPP_WriteProc(NPP_Write);
170
pluginFuncs->print = NewNPP_PrintProc(NPP_Print);
171
pluginFuncs->urlnotify = NewNPP_URLNotifyProc(NPP_URLNotify);
172
pluginFuncs->event = NULL;
173
pluginFuncs->getvalue = NewNPP_GetValueProc(NPP_GetValue);
175
pluginFuncs->javaClass = NPP_GetJavaClass();
181
return NPERR_NO_ERROR;
184
NPError OSCALL NP_Shutdown()
186
return NPERR_NO_ERROR;