FreeWRL / FreeX3D 4.3.0
np_entry.cpp
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
4 *
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/
9 *
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
13 * License.
14 *
15 * The Original Code is mozilla.org code.
16 *
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.
21 *
22 * Contributor(s):
23 *
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.
35 *
36 * ***** END LICENSE BLOCK ***** */
37
39//
40// Main plugin entry point implementation
41//
42#include "npapi.h"
43#include "npfunctions.h"
44
45#ifndef HIBYTE
46#define HIBYTE(x) ((((uint32_t)(x)) & 0xff00) >> 8)
47#endif
48
49NPNetscapeFuncs NPNFuncs;
50
51#ifdef XP_WIN
52
55NPError OSCALL NP_GetEntryPoints(NPPluginFuncs* pFuncs)
56{
57 if(pFuncs == NULL)
58 return NPERR_INVALID_FUNCTABLE_ERROR;
59
60 if(pFuncs->size < sizeof(NPPluginFuncs))
61 return NPERR_INVALID_FUNCTABLE_ERROR;
62
63 pFuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
64 pFuncs->newp = NPP_New;
65 pFuncs->destroy = NPP_Destroy;
66 pFuncs->setwindow = NPP_SetWindow;
67 pFuncs->newstream = NPP_NewStream;
68 pFuncs->destroystream = NPP_DestroyStream;
69 pFuncs->asfile = NPP_StreamAsFile;
70 pFuncs->writeready = NPP_WriteReady;
71 pFuncs->write = NPP_Write;
72 pFuncs->print = NPP_Print;
73 pFuncs->event = NPP_HandleEvent;
74 pFuncs->urlnotify = NPP_URLNotify;
75 pFuncs->getvalue = NPP_GetValue;
76 pFuncs->setvalue = NPP_SetValue;
77 pFuncs->javaClass = NULL;
78
79 return NPERR_NO_ERROR;
80}
81
82#endif /* XP_WIN */
83
84char *NPP_GetMIMEDescription();
85
88char *
89NP_GetMIMEDescription()
90{
91 return NPP_GetMIMEDescription();
92}
93
94NPError
95NP_GetValue(void* future, NPPVariable variable, void *value)
96{
97 return NPP_GetValue((NPP_t *)future, variable, value);
98}
99
103NPError OSCALL
104NP_Initialize(NPNetscapeFuncs* pFuncs
105#ifdef XP_UNIX
106 , NPPluginFuncs* pluginFuncs
107#endif
108 )
109{
110 if(pFuncs == NULL)
111 return NPERR_INVALID_FUNCTABLE_ERROR;
112
113 if(HIBYTE(pFuncs->version) > NP_VERSION_MAJOR)
114 return NPERR_INCOMPATIBLE_VERSION_ERROR;
115
116 if(pFuncs->size < sizeof(NPNetscapeFuncs))
117 return NPERR_INVALID_FUNCTABLE_ERROR;
118
119 NPNFuncs.size = pFuncs->size;
120 NPNFuncs.version = pFuncs->version;
121 NPNFuncs.geturlnotify = pFuncs->geturlnotify;
122 NPNFuncs.geturl = pFuncs->geturl;
123 NPNFuncs.posturlnotify = pFuncs->posturlnotify;
124 NPNFuncs.posturl = pFuncs->posturl;
125 NPNFuncs.requestread = pFuncs->requestread;
126 NPNFuncs.newstream = pFuncs->newstream;
127 NPNFuncs.write = pFuncs->write;
128 NPNFuncs.destroystream = pFuncs->destroystream;
129 NPNFuncs.status = pFuncs->status;
130 NPNFuncs.uagent = pFuncs->uagent;
131 NPNFuncs.memalloc = pFuncs->memalloc;
132 NPNFuncs.memfree = pFuncs->memfree;
133 NPNFuncs.memflush = pFuncs->memflush;
134 NPNFuncs.reloadplugins = pFuncs->reloadplugins;
135 NPNFuncs.getJavaEnv = pFuncs->getJavaEnv;
136 NPNFuncs.getJavaPeer = pFuncs->getJavaPeer;
137 NPNFuncs.getvalue = pFuncs->getvalue;
138 NPNFuncs.setvalue = pFuncs->setvalue;
139 NPNFuncs.invalidaterect = pFuncs->invalidaterect;
140 NPNFuncs.invalidateregion = pFuncs->invalidateregion;
141 NPNFuncs.forceredraw = pFuncs->forceredraw;
142 NPNFuncs.getstringidentifier = pFuncs->getstringidentifier;
143 NPNFuncs.getstringidentifiers = pFuncs->getstringidentifiers;
144 NPNFuncs.getintidentifier = pFuncs->getintidentifier;
145 NPNFuncs.identifierisstring = pFuncs->identifierisstring;
146 NPNFuncs.utf8fromidentifier = pFuncs->utf8fromidentifier;
147 NPNFuncs.intfromidentifier = pFuncs->intfromidentifier;
148 NPNFuncs.createobject = pFuncs->createobject;
149 NPNFuncs.retainobject = pFuncs->retainobject;
150 NPNFuncs.releaseobject = pFuncs->releaseobject;
151 NPNFuncs.invoke = pFuncs->invoke;
152 NPNFuncs.invokeDefault = pFuncs->invokeDefault;
153 NPNFuncs.evaluate = pFuncs->evaluate;
154 NPNFuncs.getproperty = pFuncs->getproperty;
155 NPNFuncs.setproperty = pFuncs->setproperty;
156 NPNFuncs.removeproperty = pFuncs->removeproperty;
157 NPNFuncs.hasproperty = pFuncs->hasproperty;
158 NPNFuncs.hasmethod = pFuncs->hasmethod;
159 NPNFuncs.releasevariantvalue = pFuncs->releasevariantvalue;
160 NPNFuncs.setexception = pFuncs->setexception;
161
162#ifdef XP_UNIX
163 /*
164 * Set up the plugin function table that Netscape will use to
165 * call us. Netscape needs to know about our version and size
166 * and have a UniversalProcPointer for every function we
167 * implement.
168 */
169 pluginFuncs->version = (NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR;
170 pluginFuncs->size = sizeof(NPPluginFuncs);
171 pluginFuncs->newp = NewNPP_NewProc(NPP_New);
172 pluginFuncs->destroy = NewNPP_DestroyProc(NPP_Destroy);
173 pluginFuncs->setwindow = NewNPP_SetWindowProc(NPP_SetWindow);
174 pluginFuncs->newstream = NewNPP_NewStreamProc(NPP_NewStream);
175 pluginFuncs->destroystream = NewNPP_DestroyStreamProc(NPP_DestroyStream);
176 pluginFuncs->asfile = NewNPP_StreamAsFileProc(NPP_StreamAsFile);
177 pluginFuncs->writeready = NewNPP_WriteReadyProc(NPP_WriteReady);
178 pluginFuncs->write = NewNPP_WriteProc(NPP_Write);
179 pluginFuncs->print = NewNPP_PrintProc(NPP_Print);
180 pluginFuncs->urlnotify = NewNPP_URLNotifyProc(NPP_URLNotify);
181 pluginFuncs->event = NULL;
182 pluginFuncs->getvalue = NewNPP_GetValueProc(NPP_GetValue);
183#ifdef OJI
184 pluginFuncs->javaClass = NPP_GetJavaClass();
185#endif
186
187 NPP_Initialize();
188#endif
189
190 return NPERR_NO_ERROR;
191}
192
194NPError OSCALL NP_Shutdown()
195{
196 return NPERR_NO_ERROR;
197}
Definition npapi.h:149