]> git.sesse.net Git - vlc/blob - projects/mozilla/support/npunix.c
mozilla: Resolve files with conflicting licensing terms
[vlc] / projects / mozilla / support / npunix.c
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2  *
3  * ***** BEGIN LICENSE BLOCK *****
4  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5  *
6  * The contents of this file are subject to the Mozilla Public License Version
7  * 1.1 (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  * http://www.mozilla.org/MPL/
10  *
11  * Software distributed under the License is distributed on an "AS IS" basis,
12  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13  * for the specific language governing rights and limitations under the
14  * License.
15  *
16  * The Original Code is mozilla.org code.
17  *
18  * The Initial Developer of the Original Code is
19  * Netscape Communications Corporation.
20  * Portions created by the Initial Developer are Copyright (C) 1998
21  * the Initial Developer. All Rights Reserved.
22  *
23  * Contributor(s):
24  *   Stephen Mak <smak@sun.com>
25  *
26  * Alternatively, the contents of this file may be used under the terms of
27  * either of the GNU General Public License Version 2 or later (the "GPL"),
28  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29  * in which case the provisions of the GPL or the LGPL are applicable instead
30  * of those above. If you wish to allow use of your version of this file only
31  * under the terms of either the GPL or the LGPL, and not to allow others to
32  * use your version of this file under the terms of the MPL, indicate your
33  * decision by deleting the provisions above and replace them with the notice
34  * and other provisions required by the GPL or the LGPL. If you do not delete
35  * the provisions above, a recipient may use your version of this file under
36  * the terms of any one of the MPL, the GPL or the LGPL.
37  *
38  * ***** END LICENSE BLOCK ***** */
39
40 /*
41  * npunix.c
42  *
43  * Netscape Client Plugin API
44  * - Wrapper function to interface with the Netscape Navigator
45  *
46  * dp Suresh <dp@netscape.com>
47  *
48  *----------------------------------------------------------------------
49  * PLUGIN DEVELOPERS:
50  *  YOU WILL NOT NEED TO EDIT THIS FILE.
51  *----------------------------------------------------------------------
52  */
53
54 #define XP_UNIX 1
55
56 #include <stdio.h>
57 #include "npapi.h"
58 #include "npupp.h"
59
60 /*
61  * Define PLUGIN_TRACE to have the wrapper functions print
62  * messages to stderr whenever they are called.
63  */
64
65 #ifdef PLUGIN_TRACE
66 #include <stdio.h>
67 #define PLUGINDEBUGSTR(msg) fprintf(stderr, "%s\n", msg)
68 #else
69 #define PLUGINDEBUGSTR(msg)
70 #endif
71
72
73 /***********************************************************************
74  *
75  * Globals
76  *
77  ***********************************************************************/
78
79 static NPNetscapeFuncs   gNetscapeFuncs;    /* Netscape Function table */
80
81
82 /***********************************************************************
83  *
84  * Wrapper functions : plugin calling Netscape Navigator
85  *
86  * These functions let the plugin developer just call the APIs
87  * as documented and defined in npapi.h, without needing to know
88  * about the function table and call macros in npupp.h.
89  *
90  ***********************************************************************/
91
92 void
93 NPN_Version(int* plugin_major, int* plugin_minor,
94          int* netscape_major, int* netscape_minor)
95 {
96     *plugin_major = NP_VERSION_MAJOR;
97     *plugin_minor = NP_VERSION_MINOR;
98
99     /* Major version is in high byte */
100     *netscape_major = gNetscapeFuncs.version >> 8;
101     /* Minor version is in low byte */
102     *netscape_minor = gNetscapeFuncs.version & 0xFF;
103 }
104
105 NPError
106 NPN_GetValue(NPP instance, NPNVariable variable, void *r_value)
107 {
108     return CallNPN_GetValueProc(gNetscapeFuncs.getvalue,
109                     instance, variable, r_value);
110 }
111
112 NPError
113 NPN_SetValue(NPP instance, NPPVariable variable, void *value)
114 {
115     return CallNPN_SetValueProc(gNetscapeFuncs.setvalue,
116                     instance, variable, value);
117 }
118
119 NPError
120 NPN_GetURL(NPP instance, const char* url, const char* window)
121 {
122     return CallNPN_GetURLProc(gNetscapeFuncs.geturl, instance, url, window);
123 }
124
125 NPError
126 NPN_GetURLNotify(NPP instance, const char* url, const char* window, void* notifyData)
127 {
128     return CallNPN_GetURLNotifyProc(gNetscapeFuncs.geturlnotify, instance, url, window, notifyData);
129 }
130
131 NPError
132 NPN_PostURL(NPP instance, const char* url, const char* window,
133          uint32 len, const char* buf, NPBool file)
134 {
135     return CallNPN_PostURLProc(gNetscapeFuncs.posturl, instance,
136                     url, window, len, buf, file);
137 }
138
139 NPError
140 NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32 len,
141                   const char* buf, NPBool file, void* notifyData)
142 {
143     return CallNPN_PostURLNotifyProc(gNetscapeFuncs.posturlnotify,
144             instance, url, window, len, buf, file, notifyData);
145 }
146
147 NPError
148 NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
149 {
150     return CallNPN_RequestReadProc(gNetscapeFuncs.requestread,
151                     stream, rangeList);
152 }
153
154 NPError
155 NPN_NewStream(NPP instance, NPMIMEType type, const char *window,
156           NPStream** stream_ptr)
157 {
158     return CallNPN_NewStreamProc(gNetscapeFuncs.newstream, instance,
159                     type, window, stream_ptr);
160 }
161
162 int32
163 NPN_Write(NPP instance, NPStream* stream, int32 len, void* buffer)
164 {
165     return CallNPN_WriteProc(gNetscapeFuncs.write, instance,
166                     stream, len, buffer);
167 }
168
169 NPError
170 NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
171 {
172     return CallNPN_DestroyStreamProc(gNetscapeFuncs.destroystream,
173                         instance, stream, reason);
174 }
175
176 void
177 NPN_Status(NPP instance, const char* message)
178 {
179     CallNPN_StatusProc(gNetscapeFuncs.status, instance, message);
180 }
181
182 const char*
183 NPN_UserAgent(NPP instance)
184 {
185     return CallNPN_UserAgentProc(gNetscapeFuncs.uagent, instance);
186 }
187
188 void*
189 NPN_MemAlloc(uint32 size)
190 {
191     return CallNPN_MemAllocProc(gNetscapeFuncs.memalloc, size);
192 }
193
194 void NPN_MemFree(void* ptr)
195 {
196     CallNPN_MemFreeProc(gNetscapeFuncs.memfree, ptr);
197 }
198
199 uint32 NPN_MemFlush(uint32 size)
200 {
201     return CallNPN_MemFlushProc(gNetscapeFuncs.memflush, size);
202 }
203
204 void NPN_ReloadPlugins(NPBool reloadPages)
205 {
206     CallNPN_ReloadPluginsProc(gNetscapeFuncs.reloadplugins, reloadPages);
207 }
208
209 #ifdef OJI
210 JRIEnv* NPN_GetJavaEnv()
211 {
212     return CallNPN_GetJavaEnvProc(gNetscapeFuncs.getJavaEnv);
213 }
214
215 jref NPN_GetJavaPeer(NPP instance)
216 {
217     return CallNPN_GetJavaPeerProc(gNetscapeFuncs.getJavaPeer,
218                        instance);
219 }
220 #endif
221
222 void
223 NPN_InvalidateRect(NPP instance, NPRect *invalidRect)
224 {
225     CallNPN_InvalidateRectProc(gNetscapeFuncs.invalidaterect, instance,
226         invalidRect);
227 }
228
229 void
230 NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion)
231 {
232     CallNPN_InvalidateRegionProc(gNetscapeFuncs.invalidateregion, instance,
233         invalidRegion);
234 }
235
236 void
237 NPN_ForceRedraw(NPP instance)
238 {
239     CallNPN_ForceRedrawProc(gNetscapeFuncs.forceredraw, instance);
240 }
241
242 void NPN_PushPopupsEnabledState(NPP instance, NPBool enabled)
243 {
244     CallNPN_PushPopupsEnabledStateProc(gNetscapeFuncs.pushpopupsenabledstate,
245         instance, enabled);
246 }
247
248 void NPN_PopPopupsEnabledState(NPP instance)
249 {
250     CallNPN_PopPopupsEnabledStateProc(gNetscapeFuncs.poppopupsenabledstate,
251         instance);
252 }
253
254 NPIdentifier NPN_GetStringIdentifier(const NPUTF8 *name)
255 {
256     return CallNPN_GetStringIdentifierProc(gNetscapeFuncs.getstringidentifier,
257                                            name);
258 }
259
260 void NPN_GetStringIdentifiers(const NPUTF8 **names, int32_t nameCount,
261                               NPIdentifier *identifiers)
262 {
263     CallNPN_GetStringIdentifiersProc(gNetscapeFuncs.getstringidentifiers,
264         names, nameCount, identifiers);
265 }
266
267 NPIdentifier NPN_GetIntIdentifier(int32_t intid)
268 {
269     return CallNPN_GetIntIdentifierProc(gNetscapeFuncs.getintidentifier, intid);
270 }
271
272 bool NPN_IdentifierIsString(NPIdentifier identifier)
273 {
274     return CallNPN_IdentifierIsStringProc(gNetscapeFuncs.identifierisstring,
275         identifier);
276 }
277
278 NPUTF8 *NPN_UTF8FromIdentifier(NPIdentifier identifier)
279 {
280     return CallNPN_UTF8FromIdentifierProc(gNetscapeFuncs.utf8fromidentifier,
281         identifier);
282 }
283
284 int32_t NPN_IntFromIdentifier(NPIdentifier identifier)
285 {
286     return CallNPN_IntFromIdentifierProc(gNetscapeFuncs.intfromidentifier,
287         identifier);
288 }
289
290 NPObject *NPN_CreateObject(NPP npp, NPClass *aClass)
291 {
292     return CallNPN_CreateObjectProc(gNetscapeFuncs.createobject, npp, aClass);
293 }
294
295 NPObject *NPN_RetainObject(NPObject *obj)
296 {
297     return CallNPN_RetainObjectProc(gNetscapeFuncs.retainobject, obj);
298 }
299
300 void NPN_ReleaseObject(NPObject *obj)
301 {
302     CallNPN_ReleaseObjectProc(gNetscapeFuncs.releaseobject, obj);
303 }
304
305 bool NPN_Invoke(NPP npp, NPObject* obj, NPIdentifier methodName,
306                 const NPVariant *args, uint32_t argCount, NPVariant *result)
307 {
308     return CallNPN_InvokeProc(gNetscapeFuncs.invoke, npp, obj, methodName,
309         args, argCount, result);
310 }
311
312 bool NPN_InvokeDefault(NPP npp, NPObject* obj, const NPVariant *args,
313                        uint32_t argCount, NPVariant *result)
314 {
315     return CallNPN_InvokeDefaultProc(gNetscapeFuncs.invokeDefault, npp, obj,
316         args, argCount, result);
317 }
318
319 bool NPN_Evaluate(NPP npp, NPObject* obj, NPString *script,
320                   NPVariant *result)
321 {
322     return CallNPN_EvaluateProc(gNetscapeFuncs.evaluate, npp, obj, script, result);
323 }
324
325 bool NPN_GetProperty(NPP npp, NPObject* obj, NPIdentifier propertyName,
326                      NPVariant *result)
327 {
328     return CallNPN_GetPropertyProc(gNetscapeFuncs.getproperty, npp, obj,
329         propertyName, result);
330 }
331
332 bool NPN_SetProperty(NPP npp, NPObject* obj, NPIdentifier propertyName,
333                      const NPVariant *value)
334 {
335     return CallNPN_SetPropertyProc(gNetscapeFuncs.setproperty, npp, obj,
336         propertyName, value);
337 }
338
339 bool NPN_RemoveProperty(NPP npp, NPObject* obj, NPIdentifier propertyName)
340 {
341     return CallNPN_RemovePropertyProc(gNetscapeFuncs.removeproperty, npp, obj,
342         propertyName);
343 }
344
345 bool NPN_HasProperty(NPP npp, NPObject* obj, NPIdentifier propertyName)
346 {
347     return CallNPN_HasPropertyProc(gNetscapeFuncs.hasproperty, npp, obj,
348         propertyName);
349 }
350
351 bool NPN_HasMethod(NPP npp, NPObject* obj, NPIdentifier methodName)
352 {
353     return CallNPN_HasMethodProc(gNetscapeFuncs.hasmethod, npp, obj, methodName);
354 }
355
356 void NPN_ReleaseVariantValue(NPVariant *variant)
357 {
358     CallNPN_ReleaseVariantValueProc(gNetscapeFuncs.releasevariantvalue, variant);
359 }
360
361 void NPN_SetException(NPObject* obj, const NPUTF8 *message)
362 {
363     CallNPN_SetExceptionProc(gNetscapeFuncs.setexception, obj, message);
364 }
365
366
367 /***********************************************************************
368  *
369  * Wrapper functions : Netscape Navigator -> plugin
370  *
371  * These functions let the plugin developer just create the APIs
372  * as documented and defined in npapi.h, without needing to 
373  * install those functions in the function table or worry about
374  * setting up globals for 68K plugins.
375  *
376  ***********************************************************************/
377
378 NPError
379 Private_New(NPMIMEType pluginType, NPP instance, uint16 mode,
380         int16 argc, char* argn[], char* argv[], NPSavedData* saved)
381 {
382     NPError ret;
383     PLUGINDEBUGSTR("New");
384     ret = NPP_New(pluginType, instance, mode, argc, argn, argv, saved);
385     return ret; 
386 }
387
388 NPError
389 Private_Destroy(NPP instance, NPSavedData** save)
390 {
391     PLUGINDEBUGSTR("Destroy");
392     return NPP_Destroy(instance, save);
393 }
394
395 NPError
396 Private_SetWindow(NPP instance, NPWindow* window)
397 {
398     NPError err;
399     PLUGINDEBUGSTR("SetWindow");
400     err = NPP_SetWindow(instance, window);
401     return err;
402 }
403
404 NPError
405 Private_NewStream(NPP instance, NPMIMEType type, NPStream* stream,
406             NPBool seekable, uint16* stype)
407 {
408     NPError err;
409     PLUGINDEBUGSTR("NewStream");
410     err = NPP_NewStream(instance, type, stream, seekable, stype);
411     return err;
412 }
413
414 int32
415 Private_WriteReady(NPP instance, NPStream* stream)
416 {
417     unsigned int result;
418     PLUGINDEBUGSTR("WriteReady");
419     result = NPP_WriteReady(instance, stream);
420     return result;
421 }
422
423 int32
424 Private_Write(NPP instance, NPStream* stream, int32 offset, int32 len,
425         void* buffer)
426 {
427     unsigned int result;
428     PLUGINDEBUGSTR("Write");
429     result = NPP_Write(instance, stream, offset, len, buffer);
430     return result;
431 }
432
433 void
434 Private_StreamAsFile(NPP instance, NPStream* stream, const char* fname)
435 {
436     PLUGINDEBUGSTR("StreamAsFile");
437     NPP_StreamAsFile(instance, stream, fname);
438 }
439
440
441 NPError
442 Private_DestroyStream(NPP instance, NPStream* stream, NPError reason)
443 {
444     NPError err;
445     PLUGINDEBUGSTR("DestroyStream");
446     err = NPP_DestroyStream(instance, stream, reason);
447     return err;
448 }
449
450 void
451 Private_URLNotify(NPP instance, const char* url,
452                 NPReason reason, void* notifyData)
453                 
454 {
455     PLUGINDEBUGSTR("URLNotify");
456     NPP_URLNotify(instance, url, reason, notifyData);
457 }
458
459
460
461 void
462 Private_Print(NPP instance, NPPrint* platformPrint)
463 {
464     PLUGINDEBUGSTR("Print");
465     NPP_Print(instance, platformPrint);
466 }
467
468 #ifdef OJI
469 JRIGlobalRef
470 Private_GetJavaClass(void)
471 {
472     jref clazz = NPP_GetJavaClass();
473     if (clazz) {
474     JRIEnv* env = NPN_GetJavaEnv();
475     return JRI_NewGlobalRef(env, clazz);
476     }
477     return NULL;
478 }
479 #endif
480
481 /*********************************************************************** 
482  *
483  * These functions are located automagically by netscape.
484  *
485  ***********************************************************************/
486
487 /*
488  * NP_GetMIMEDescription
489  *  - Netscape needs to know about this symbol
490  *  - Netscape uses the return value to identify when an object instance
491  *    of this plugin should be created.
492  */
493 char *
494 NP_GetMIMEDescription(void)
495 {
496     return NPP_GetMIMEDescription();
497 }
498
499 /*
500  * NP_GetValue [optional]
501  *  - Netscape needs to know about this symbol.
502  *  - Interfaces with plugin to get values for predefined variables
503  *    that the navigator needs.
504  */
505 NPError
506 NP_GetValue(void* future, NPPVariable variable, void *value)
507 {
508     return NPP_GetValue(future, variable, value);
509 }
510
511 /*
512  * NP_Initialize
513  *  - Netscape needs to know about this symbol.
514  *  - It calls this function after looking up its symbol before it
515  *    is about to create the first ever object of this kind.
516  *
517  * PARAMETERS
518  *    nsTable   - The netscape function table. If developers just use these
519  *        wrappers, they don't need to worry about all these function
520  *        tables.
521  * RETURN
522  *    pluginFuncs
523  *      - This functions needs to fill the plugin function table
524  *        pluginFuncs and return it. Netscape Navigator plugin
525  *        library will use this function table to call the plugin.
526  *
527  */
528 NPError
529 NP_Initialize(NPNetscapeFuncs* nsTable, NPPluginFuncs* pluginFuncs)
530 {
531     NPError err = NPERR_NO_ERROR;
532
533     PLUGINDEBUGSTR("NP_Initialize");
534     
535     /* validate input parameters */
536
537     if ((nsTable == NULL) || (pluginFuncs == NULL))
538         err = NPERR_INVALID_FUNCTABLE_ERROR;
539     
540     /*
541      * Check the major version passed in Netscape's function table.
542      * We won't load if the major version is newer than what we expect.
543      * Also check that the function tables passed in are big enough for
544      * all the functions we need (they could be bigger, if Netscape added
545      * new APIs, but that's OK with us -- we'll just ignore them).
546      *
547      */
548
549     if (err == NPERR_NO_ERROR) {
550         if ((nsTable->version >> 8) > NP_VERSION_MAJOR)
551             err = NPERR_INCOMPATIBLE_VERSION_ERROR;
552         if (nsTable->size < ((char *)&nsTable->posturlnotify - (char *)nsTable))
553             err = NPERR_INVALID_FUNCTABLE_ERROR;
554         if (pluginFuncs->size < sizeof(NPPluginFuncs))      
555             err = NPERR_INVALID_FUNCTABLE_ERROR;
556     }
557         
558     
559     if (err == NPERR_NO_ERROR) {
560         /*
561          * Copy all the fields of Netscape function table into our
562          * copy so we can call back into Netscape later.  Note that
563          * we need to copy the fields one by one, rather than assigning
564          * the whole structure, because the Netscape function table
565          * could actually be bigger than what we expect.
566          */
567         gNetscapeFuncs.version       = nsTable->version;
568         gNetscapeFuncs.size          = nsTable->size;
569         gNetscapeFuncs.posturl       = nsTable->posturl;
570         gNetscapeFuncs.geturl        = nsTable->geturl;
571         gNetscapeFuncs.geturlnotify  = nsTable->geturlnotify;
572         gNetscapeFuncs.requestread   = nsTable->requestread;
573         gNetscapeFuncs.newstream     = nsTable->newstream;
574         gNetscapeFuncs.write         = nsTable->write;
575         gNetscapeFuncs.destroystream = nsTable->destroystream;
576         gNetscapeFuncs.status        = nsTable->status;
577         gNetscapeFuncs.uagent        = nsTable->uagent;
578         gNetscapeFuncs.memalloc      = nsTable->memalloc;
579         gNetscapeFuncs.memfree       = nsTable->memfree;
580         gNetscapeFuncs.memflush      = nsTable->memflush;
581         gNetscapeFuncs.reloadplugins = nsTable->reloadplugins;
582 #ifdef OJI
583         gNetscapeFuncs.getJavaEnv    = nsTable->getJavaEnv;
584         gNetscapeFuncs.getJavaPeer   = nsTable->getJavaPeer;
585 #endif
586         gNetscapeFuncs.getvalue      = nsTable->getvalue;
587         gNetscapeFuncs.setvalue      = nsTable->setvalue;
588         gNetscapeFuncs.posturlnotify = nsTable->posturlnotify;
589
590         if (nsTable->size >= ((char *)&nsTable->setexception - (char *)nsTable))
591         {
592           gNetscapeFuncs.invalidaterect = nsTable->invalidaterect;
593           gNetscapeFuncs.invalidateregion = nsTable->invalidateregion;
594           gNetscapeFuncs.forceredraw = nsTable->forceredraw;
595           gNetscapeFuncs.getstringidentifier = nsTable->getstringidentifier;
596           gNetscapeFuncs.getstringidentifiers = nsTable->getstringidentifiers;
597           gNetscapeFuncs.getintidentifier = nsTable->getintidentifier;
598           gNetscapeFuncs.identifierisstring = nsTable->identifierisstring;
599           gNetscapeFuncs.utf8fromidentifier = nsTable->utf8fromidentifier;
600           gNetscapeFuncs.intfromidentifier = nsTable->intfromidentifier;
601           gNetscapeFuncs.createobject = nsTable->createobject;
602           gNetscapeFuncs.retainobject = nsTable->retainobject;
603           gNetscapeFuncs.releaseobject = nsTable->releaseobject;
604           gNetscapeFuncs.invoke = nsTable->invoke;
605           gNetscapeFuncs.invokeDefault = nsTable->invokeDefault;
606           gNetscapeFuncs.evaluate = nsTable->evaluate;
607           gNetscapeFuncs.getproperty = nsTable->getproperty;
608           gNetscapeFuncs.setproperty = nsTable->setproperty;
609           gNetscapeFuncs.removeproperty = nsTable->removeproperty;
610           gNetscapeFuncs.hasproperty = nsTable->hasproperty;
611           gNetscapeFuncs.hasmethod = nsTable->hasmethod;
612           gNetscapeFuncs.releasevariantvalue = nsTable->releasevariantvalue;
613           gNetscapeFuncs.setexception = nsTable->setexception;
614         }
615          else
616         {
617           gNetscapeFuncs.invalidaterect = NULL;
618           gNetscapeFuncs.invalidateregion = NULL;
619           gNetscapeFuncs.forceredraw = NULL;
620           gNetscapeFuncs.getstringidentifier = NULL;
621           gNetscapeFuncs.getstringidentifiers = NULL;
622           gNetscapeFuncs.getintidentifier = NULL;
623           gNetscapeFuncs.identifierisstring = NULL;
624           gNetscapeFuncs.utf8fromidentifier = NULL;
625           gNetscapeFuncs.intfromidentifier = NULL;
626           gNetscapeFuncs.createobject = NULL;
627           gNetscapeFuncs.retainobject = NULL;
628           gNetscapeFuncs.releaseobject = NULL;
629           gNetscapeFuncs.invoke = NULL;
630           gNetscapeFuncs.invokeDefault = NULL;
631           gNetscapeFuncs.evaluate = NULL;
632           gNetscapeFuncs.getproperty = NULL;
633           gNetscapeFuncs.setproperty = NULL;
634           gNetscapeFuncs.removeproperty = NULL;
635           gNetscapeFuncs.hasproperty = NULL;
636           gNetscapeFuncs.releasevariantvalue = NULL;
637           gNetscapeFuncs.setexception = NULL;
638         }
639         if (nsTable->size >=
640             ((char *)&nsTable->poppopupsenabledstate - (char *)nsTable))
641         {
642           gNetscapeFuncs.pushpopupsenabledstate = nsTable->pushpopupsenabledstate;
643           gNetscapeFuncs.poppopupsenabledstate  = nsTable->poppopupsenabledstate;
644         }
645          else
646         {
647           gNetscapeFuncs.pushpopupsenabledstate = NULL;
648           gNetscapeFuncs.poppopupsenabledstate  = NULL;
649         }
650
651         /*
652          * Set up the plugin function table that Netscape will use to
653          * call us.  Netscape needs to know about our version and size
654          * and have a UniversalProcPointer for every function we
655          * implement.
656          */
657         pluginFuncs->version    = (NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR;
658         pluginFuncs->size       = sizeof(NPPluginFuncs);
659         pluginFuncs->newp       = NewNPP_NewProc(Private_New);
660         pluginFuncs->destroy    = NewNPP_DestroyProc(Private_Destroy);
661         pluginFuncs->setwindow  = NewNPP_SetWindowProc(Private_SetWindow);
662         pluginFuncs->newstream  = NewNPP_NewStreamProc(Private_NewStream);
663         pluginFuncs->destroystream = NewNPP_DestroyStreamProc(Private_DestroyStream);
664         pluginFuncs->asfile     = NewNPP_StreamAsFileProc(Private_StreamAsFile);
665         pluginFuncs->writeready = NewNPP_WriteReadyProc(Private_WriteReady);
666         pluginFuncs->write      = NewNPP_WriteProc(Private_Write);
667         pluginFuncs->print      = NewNPP_PrintProc(Private_Print);
668         pluginFuncs->urlnotify  = NewNPP_URLNotifyProc(Private_URLNotify);
669         pluginFuncs->event      = NULL;
670 #ifdef OJI
671         pluginFuncs->javaClass  = Private_GetJavaClass();
672 #endif
673         // This function is supposedly loaded magically, but that doesn't
674         // seem to be true.
675         pluginFuncs->getvalue      = NewNPP_GetValueProc(NP_GetValue);
676
677         err = NPP_Initialize();
678     }
679     
680     return err;
681 }
682
683 /*
684  * NP_Shutdown [optional]
685  *  - Netscape needs to know about this symbol.
686  *  - It calls this function after looking up its symbol after
687  *    the last object of this kind has been destroyed.
688  *
689  */
690 NPError
691 NP_Shutdown(void)
692 {
693     PLUGINDEBUGSTR("NP_Shutdown");
694     NPP_Shutdown();
695     return NPERR_NO_ERROR;
696 }