Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / modules / plugin / sdk / samples / npruntime / np_entry.cpp
blob9c7a9af4ed86b0b40afd11f62416cbc8b57795f2
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: NPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Netscape Public License
6 * Version 1.1 (the "License"); you may not use this file except in
7 * compliance with the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/NPL/
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 NPL, 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 NPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 //////////////////////////////////////////////////////////////
40 // Main plugin entry point implementation
42 #include "npapi.h"
43 #include "npfunctions.h"
45 #ifndef HIBYTE
46 #define HIBYTE(x) ((((uint32_t)(x)) & 0xff00) >> 8)
47 #endif
49 NPNetscapeFuncs NPNFuncs;
51 #ifdef XP_WIN
53 NPError OSCALL NP_GetEntryPoints(NPPluginFuncs* pFuncs)
55 if(pFuncs == NULL)
56 return NPERR_INVALID_FUNCTABLE_ERROR;
58 if(pFuncs->size < sizeof(NPPluginFuncs))
59 return NPERR_INVALID_FUNCTABLE_ERROR;
61 pFuncs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
62 pFuncs->newp = NPP_New;
63 pFuncs->destroy = NPP_Destroy;
64 pFuncs->setwindow = NPP_SetWindow;
65 pFuncs->newstream = NPP_NewStream;
66 pFuncs->destroystream = NPP_DestroyStream;
67 pFuncs->asfile = NPP_StreamAsFile;
68 pFuncs->writeready = NPP_WriteReady;
69 pFuncs->write = NPP_Write;
70 pFuncs->print = NPP_Print;
71 pFuncs->event = NPP_HandleEvent;
72 pFuncs->urlnotify = NPP_URLNotify;
73 pFuncs->getvalue = NPP_GetValue;
74 pFuncs->setvalue = NPP_SetValue;
75 pFuncs->javaClass = NULL;
77 return NPERR_NO_ERROR;
80 #endif /* XP_WIN */
82 char *NPP_GetMIMEDescription();
84 char *
85 NP_GetMIMEDescription()
87 return NPP_GetMIMEDescription();
90 NPError
91 NP_GetValue(void* future, NPPVariable variable, void *value)
93 return NPP_GetValue((NPP_t *)future, variable, value);
96 NPError OSCALL
97 NP_Initialize(NPNetscapeFuncs* pFuncs
98 #ifdef XP_UNIX
99 , NPPluginFuncs* pluginFuncs
100 #endif
103 if(pFuncs == NULL)
104 return NPERR_INVALID_FUNCTABLE_ERROR;
106 if(HIBYTE(pFuncs->version) > NP_VERSION_MAJOR)
107 return NPERR_INCOMPATIBLE_VERSION_ERROR;
109 if(pFuncs->size < sizeof(NPNetscapeFuncs))
110 return NPERR_INVALID_FUNCTABLE_ERROR;
112 NPNFuncs.size = pFuncs->size;
113 NPNFuncs.version = pFuncs->version;
114 NPNFuncs.geturlnotify = pFuncs->geturlnotify;
115 NPNFuncs.geturl = pFuncs->geturl;
116 NPNFuncs.posturlnotify = pFuncs->posturlnotify;
117 NPNFuncs.posturl = pFuncs->posturl;
118 NPNFuncs.requestread = pFuncs->requestread;
119 NPNFuncs.newstream = pFuncs->newstream;
120 NPNFuncs.write = pFuncs->write;
121 NPNFuncs.destroystream = pFuncs->destroystream;
122 NPNFuncs.status = pFuncs->status;
123 NPNFuncs.uagent = pFuncs->uagent;
124 NPNFuncs.memalloc = pFuncs->memalloc;
125 NPNFuncs.memfree = pFuncs->memfree;
126 NPNFuncs.memflush = pFuncs->memflush;
127 NPNFuncs.reloadplugins = pFuncs->reloadplugins;
128 NPNFuncs.getJavaEnv = NULL;
129 NPNFuncs.getJavaPeer = NULL;
130 NPNFuncs.getvalue = pFuncs->getvalue;
131 NPNFuncs.setvalue = pFuncs->setvalue;
132 NPNFuncs.invalidaterect = pFuncs->invalidaterect;
133 NPNFuncs.invalidateregion = pFuncs->invalidateregion;
134 NPNFuncs.forceredraw = pFuncs->forceredraw;
135 NPNFuncs.getstringidentifier = pFuncs->getstringidentifier;
136 NPNFuncs.getstringidentifiers = pFuncs->getstringidentifiers;
137 NPNFuncs.getintidentifier = pFuncs->getintidentifier;
138 NPNFuncs.identifierisstring = pFuncs->identifierisstring;
139 NPNFuncs.utf8fromidentifier = pFuncs->utf8fromidentifier;
140 NPNFuncs.intfromidentifier = pFuncs->intfromidentifier;
141 NPNFuncs.createobject = pFuncs->createobject;
142 NPNFuncs.retainobject = pFuncs->retainobject;
143 NPNFuncs.releaseobject = pFuncs->releaseobject;
144 NPNFuncs.invoke = pFuncs->invoke;
145 NPNFuncs.invokeDefault = pFuncs->invokeDefault;
146 NPNFuncs.evaluate = pFuncs->evaluate;
147 NPNFuncs.getproperty = pFuncs->getproperty;
148 NPNFuncs.setproperty = pFuncs->setproperty;
149 NPNFuncs.removeproperty = pFuncs->removeproperty;
150 NPNFuncs.hasproperty = pFuncs->hasproperty;
151 NPNFuncs.hasmethod = pFuncs->hasmethod;
152 NPNFuncs.releasevariantvalue = pFuncs->releasevariantvalue;
153 NPNFuncs.setexception = pFuncs->setexception;
155 #ifdef XP_UNIX
157 * Set up the plugin function table that Netscape will use to
158 * call us. Netscape needs to know about our version and size
159 * and have a UniversalProcPointer for every function we
160 * implement.
162 pluginFuncs->version = (NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR;
163 pluginFuncs->size = sizeof(NPPluginFuncs);
164 pluginFuncs->newp = (NPP_NewProcPtr)(NPP_New);
165 pluginFuncs->destroy = (NPP_DestroyProcPtr)(NPP_Destroy);
166 pluginFuncs->setwindow = (NPP_SetWindowProcPtr)(NPP_SetWindow);
167 pluginFuncs->newstream = (NPP_NewStreamProcPtr)(NPP_NewStream);
168 pluginFuncs->destroystream = (NPP_DestroyStreamProcPtr)(NPP_DestroyStream);
169 pluginFuncs->asfile = (NPP_StreamAsFileProcPtr)(NPP_StreamAsFile);
170 pluginFuncs->writeready = (NPP_WriteReadyProcPtr)(NPP_WriteReady);
171 pluginFuncs->write = (NPP_WriteProcPtr)(NPP_Write);
172 pluginFuncs->print = (NPP_PrintProcPtr)(NPP_Print);
173 pluginFuncs->urlnotify = (NPP_URLNotifyProcPtr)(NPP_URLNotify);
174 pluginFuncs->event = NULL;
175 pluginFuncs->getvalue = (NPP_GetValueProcPtr)(NPP_GetValue);
176 pluginFuncs->javaClass = NULL;
178 NPP_Initialize();
179 #endif
181 return NPERR_NO_ERROR;
184 NPError OSCALL NP_Shutdown()
186 return NPERR_NO_ERROR;