Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / modules / plugin / sdk / samples / npthread / windows / npn_gate.cpp
blob3d7efbba59b2256e00bbca95bbe9643fff0f5637
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 #include "npapi.h"
39 #include "npfunctions.h"
40 #include "dbg.h"
42 extern NPNetscapeFuncs NPNFuncs;
44 void NPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major, int* netscape_minor)
46 dbgOut1("wrapper: NPN_Version");
48 *plugin_major = NP_VERSION_MAJOR;
49 *plugin_minor = NP_VERSION_MINOR;
50 *netscape_major = HIBYTE(NPNFuncs.version);
51 *netscape_minor = LOBYTE(NPNFuncs.version);
54 NPError NPN_GetURLNotify(NPP instance, const char *url, const char *target, void* notifyData)
56 dbgOut1("wrapper: NPN_GetURLNotify");
58 int navMinorVers = NPNFuncs.version & 0xFF;
60 NPError rv = NPERR_NO_ERROR;
62 if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
63 rv = NPNFuncs.geturlnotify(instance, url, target, notifyData);
64 else
65 rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
67 return rv;
70 NPError NPN_GetURL(NPP instance, const char *url, const char *target)
72 dbgOut1("wrapper: NPN_GetURL");
74 NPError rv = NPNFuncs.geturl(instance, url, target);
75 return rv;
78 NPError NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file, void* notifyData)
80 dbgOut1("wrapper: NPN_PostURLNotify");
82 int navMinorVers = NPNFuncs.version & 0xFF;
84 NPError rv = NPERR_NO_ERROR;
86 if( navMinorVers >= NPVERS_HAS_NOTIFICATION )
87 rv = NPNFuncs.posturlnotify(instance, url, window, len, buf, file, notifyData);
88 else
89 rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
91 return rv;
94 NPError NPN_PostURL(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file)
96 dbgOut1("wrapper: NPN_PostURL");
98 NPError rv = NPNFuncs.posturl(instance, url, window, len, buf, file);
99 return rv;
102 NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
104 dbgOut1("wrapper: NPN_RequestRead");
106 NPError rv = NPNFuncs.requestread(stream, rangeList);
107 return rv;
110 NPError NPN_NewStream(NPP instance, NPMIMEType type, const char* target, NPStream** stream)
112 dbgOut1("wrapper: NPN_NewStream");
114 int navMinorVersion = NPNFuncs.version & 0xFF;
116 NPError rv = NPERR_NO_ERROR;
118 if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
119 rv = NPNFuncs.newstream(instance, type, target, stream);
120 else
121 rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
123 return rv;
126 int32 NPN_Write(NPP instance, NPStream *stream, int32 len, void *buffer)
128 dbgOut1("wrapper: NPN_Write");
130 int navMinorVersion = NPNFuncs.version & 0xFF;
132 int32 rv = 0;
134 if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
135 rv = NPNFuncs.write(instance, stream, len, buffer);
136 else
137 rv = -1;
139 return rv;
142 NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
144 dbgOut1("wrapper: NPN_DestroyStream");
146 int navMinorVersion = NPNFuncs.version & 0xFF;
148 NPError rv = NPERR_NO_ERROR;
150 if( navMinorVersion >= NPVERS_HAS_STREAMOUTPUT )
151 rv = NPNFuncs.destroystream(instance, stream, reason);
152 else
153 rv = NPERR_INCOMPATIBLE_VERSION_ERROR;
155 return rv;
158 void NPN_Status(NPP instance, const char *message)
160 dbgOut1("wrapper: NPN_Status");
162 NPNFuncs.status(instance, message);
165 const char* NPN_UserAgent(NPP instance)
167 dbgOut1("wrapper: NPN_UserAgent");
169 const char * rv = NULL;
170 rv = NPNFuncs.uagent(instance);
171 return rv;
174 void* NPN_MemAlloc(uint32 size)
176 //bgOut1("wrapper: NPN_MemAlloc");
178 void * rv = NULL;
179 rv = NPNFuncs.memalloc(size);
180 return rv;
183 void NPN_MemFree(void* ptr)
185 //dbgOut1("wrapper: NPN_MemFree");
187 NPNFuncs.memfree(ptr);
190 uint32 NPN_MemFlush(uint32 size)
192 dbgOut1("wrapper: NPN_MemFlush");
194 uint32 rv = NPNFuncs.memflush(size);
195 return rv;
198 void NPN_ReloadPlugins(NPBool reloadPages)
200 dbgOut1("wrapper: NPN_ReloadPlugins");
202 NPNFuncs.reloadplugins(reloadPages);
205 NPError NPN_GetValue(NPP instance, NPNVariable variable, void *value)
207 dbgOut1("wrapper: NPN_GetValue");
209 NPError rv = NPERR_NO_ERROR;
210 rv = NPNFuncs.getvalue(instance, variable, value);
211 return rv;
214 NPError NPN_SetValue(NPP instance, NPPVariable variable, void *value)
216 dbgOut1("wrapper: NPN_SetValue");
218 NPError rv = NPERR_NO_ERROR;
219 rv = NPNFuncs.setvalue(instance, variable, value);
220 return rv;
223 void NPN_InvalidateRect(NPP instance, NPRect *invalidRect)
225 dbgOut1("wrapper: NPN_InvalidateRect");
227 NPNFuncs.invalidaterect(instance, invalidRect);
230 void NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion)
232 dbgOut1("wrapper: NPN_InvalidateRegion");
234 NPNFuncs.invalidateregion(instance, invalidRegion);
237 void NPN_ForceRedraw(NPP instance)
239 dbgOut1("wrapper: ForceRedraw");
241 NPNFuncs.forceredraw(instance);