10 #define NP_EXPORT _export
13 static NPNetscapeFuncs
* g_pNavigatorFuncs
= NULL
;
16 /* PLUGIN DLL entry points */
17 /* These are the Windows specific DLL entry points, not the "normal" plugin
18 entry points. The "normal" ones are in NPSHELL.CPP
21 /* fills in the func table used by Navigator to call entry points in
22 plugin DLL. Note that these entry points ensure that DS is loaded
23 by using the NP_LOADDS macro, when compiling for Win16
25 NPError WINAPI NP_EXPORT
NP_GetEntryPoints(NPPluginFuncs
* pFuncs
)
29 return NPERR_INVALID_FUNCTABLE_ERROR
;
31 /* if the plugin's function table is smaller than the plugin expects,
32 then they are incompatible, and should return an error */
33 if(pFuncs
->size
< sizeof NPPluginFuncs
)
34 return NPERR_INVALID_FUNCTABLE_ERROR
;
36 pFuncs
->version
= (NP_VERSION_MAJOR
<< 8) | NP_VERSION_MINOR
;
37 pFuncs
->newp
= NPP_New
;
38 pFuncs
->destroy
= NPP_Destroy
;
39 pFuncs
->setwindow
= NPP_SetWindow
;
40 pFuncs
->newstream
= NPP_NewStream
;
41 pFuncs
->destroystream
= NPP_DestroyStream
;
42 pFuncs
->asfile
= NPP_StreamAsFile
;
43 pFuncs
->writeready
= NPP_WriteReady
;
44 pFuncs
->write
= NPP_Write
;
45 pFuncs
->print
= NPP_Print
;
46 pFuncs
->event
= NULL
; /* reserved */
48 return NPERR_NO_ERROR
;
51 /* called immediately after the plugin DLL is loaded
53 NPError WINAPI NP_EXPORT
NP_Initialize(NPNetscapeFuncs
* pFuncs
)
57 return NPERR_INVALID_FUNCTABLE_ERROR
;
59 g_pNavigatorFuncs
= pFuncs
; /* save it for future reference */
61 /* if the plugin's major ver level is lower than the Navigator's,
62 then they are incompatible, and should return an error */
63 if(HIBYTE(pFuncs
->version
) > NP_VERSION_MAJOR
)
64 return NPERR_INCOMPATIBLE_VERSION_ERROR
;
66 /* if the Navigator's function table is smaller than the plugin expects,
67 then they are incompatible, and should return an error */
68 if(pFuncs
->size
< sizeof NPNetscapeFuncs
)
69 return NPERR_INVALID_FUNCTABLE_ERROR
;
71 return NPP_Initialize();
74 /* called immediately before the plugin DLL is unloaded
76 NPError WINAPI NP_EXPORT
NP_Shutdown()
80 g_pNavigatorFuncs
= NULL
;
82 return NPERR_NO_ERROR
;
86 /* NAVIGATOR Entry points */
88 /* These entry points expect to be called from within the plugin. The
89 noteworthy assumption is that DS has already been set to point to the
90 plugin's DLL data segment. Don't call these functions from outside
91 the plugin without ensuring DS is set to the DLLs data segment first,
92 typically using the NP_LOADDS macro
95 /* returns the major/minor version numbers of the Plugin API for the plugin
98 void NPN_Version(int* plugin_major
, int* plugin_minor
, int* netscape_major
, int* netscape_minor
)
100 *plugin_major
= NP_VERSION_MAJOR
;
101 *plugin_minor
= NP_VERSION_MINOR
;
102 *netscape_major
= HIBYTE(g_pNavigatorFuncs
->version
);
103 *netscape_minor
= LOBYTE(g_pNavigatorFuncs
->version
);
106 /* causes the specified URL to be fetched and streamed in
108 NPError
NPN_GetURL(NPP instance
, const char *url
, const char *window
)
110 return g_pNavigatorFuncs
->geturl(instance
, url
, window
);
113 NPError
NPN_PostURL(NPP instance
, const char* url
, const char* window
, uint32 len
, const char* buf
, NPBool file
)
115 return g_pNavigatorFuncs
->posturl(instance
, url
, window
, len
, buf
, file
);
118 /* Requests that a number of bytes be provided on a stream. Typically
119 this would be used if a stream was in "pull" mode. An optional
120 position can be provided for streams which are seekable.
122 NPError
NPN_RequestRead(NPStream
* stream
, NPByteRange
* rangeList
)
124 return g_pNavigatorFuncs
->requestread(stream
, rangeList
);
127 /* Creates a new stream of data from the plug-in to be interpreted
128 by Netscape in the current window.
130 NPError
NPN_NewStream(NPP instance
, NPMIMEType type
, NPStream
*stream
)
132 return g_pNavigatorFuncs
->newstream(instance
, type
, stream
);
135 /* Provides len bytes of data.
137 int32
NPN_Write(NPP instance
, NPStream
*stream
,
138 int32 len
, void *buffer
)
140 return g_pNavigatorFuncs
->write(instance
, stream
, len
, buffer
);
143 /* Closes a stream object.
144 reason indicates why the stream was closed.
146 NPError
NPN_DestroyStream(NPP instance
, NPStream
* stream
, NPError reason
)
148 return g_pNavigatorFuncs
->destroystream(instance
, stream
, reason
);
151 /* Provides a text status message in the Netscape client user interface
153 void NPN_Status(NPP instance
, const char *message
)
155 g_pNavigatorFuncs
->status(instance
, message
);
158 /* returns the user agent string of Navigator, which contains version info
160 const char* NPN_UserAgent(NPP instance
)
162 return g_pNavigatorFuncs
->uagent(instance
);
165 /* allocates memory from the Navigator's memory space. Necessary so that
166 saved instance data may be freed by Navigator when exiting.
168 void* NPN_MemAlloc(uint32 size
)
170 return g_pNavigatorFuncs
->memalloc(size
);
173 /* reciprocal of MemAlloc() above
175 void NPN_MemFree(void* ptr
)
177 g_pNavigatorFuncs
->memfree(ptr
);
180 /* private function to Netscape. do not use!
182 void NPN_ReloadPlugins(NPBool reloadPages
)
184 g_pNavigatorFuncs
->reloadplugins(reloadPages
);