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