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