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