PageRenderTime 139ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 1ms

/npapi/npunix.c

http://firefox-mac-pdf.googlecode.com/
C | 688 lines | 428 code | 94 blank | 166 comment | 16 complexity | c079ef92ef22b901a6ba608f05a0043e MD5 | raw file
  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  2. *
  3. * ***** BEGIN LICENSE BLOCK *****
  4. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  5. *
  6. * The contents of this file are subject to the Mozilla Public License Version
  7. * 1.1 (the "License"); you may not use this file except in compliance with
  8. * the License. You may obtain a copy of the License at
  9. * http://www.mozilla.org/MPL/
  10. *
  11. * Software distributed under the License is distributed on an "AS IS" basis,
  12. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  13. * for the specific language governing rights and limitations under the
  14. * License.
  15. *
  16. * The Original Code is mozilla.org code.
  17. *
  18. * The Initial Developer of the Original Code is
  19. * Netscape Communications Corporation.
  20. * Portions created by the Initial Developer are Copyright (C) 1998
  21. * the Initial Developer. All Rights Reserved.
  22. *
  23. * Contributor(s):
  24. * Stephen Mak <smak@sun.com>
  25. *
  26. * Alternatively, the contents of this file may be used under the terms of
  27. * either of the GNU General Public License Version 2 or later (the "GPL"),
  28. * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  29. * in which case the provisions of the GPL or the LGPL are applicable instead
  30. * of those above. If you wish to allow use of your version of this file only
  31. * under the terms of either the GPL or the LGPL, and not to allow others to
  32. * use your version of this file under the terms of the MPL, indicate your
  33. * decision by deleting the provisions above and replace them with the notice
  34. * and other provisions required by the GPL or the LGPL. If you do not delete
  35. * the provisions above, a recipient may use your version of this file under
  36. * the terms of any one of the MPL, the GPL or the LGPL.
  37. *
  38. * ***** END LICENSE BLOCK ***** */
  39. /*
  40. * npunix.c
  41. *
  42. * Netscape Client Plugin API
  43. * - Wrapper function to interface with the Netscape Navigator
  44. *
  45. * dp Suresh <dp@netscape.com>
  46. *
  47. *----------------------------------------------------------------------
  48. * PLUGIN DEVELOPERS:
  49. * YOU WILL NOT NEED TO EDIT THIS FILE.
  50. *----------------------------------------------------------------------
  51. */
  52. /*
  53. * Modified by Sam Gross for Firefox PDF Plugin for Mac
  54. */
  55. #define XP_UNIX 1
  56. #include <stdio.h>
  57. #include "npapi.h"
  58. #include "npfunctions.h"
  59. /*
  60. * Define PLUGIN_TRACE to have the wrapper functions print
  61. * messages to stderr whenever they are called.
  62. */
  63. #ifdef PLUGIN_TRACE
  64. #include <stdio.h>
  65. #define PLUGINDEBUGSTR(msg) fprintf(stderr, "%s\n", msg)
  66. #else
  67. #define PLUGINDEBUGSTR(msg)
  68. #endif
  69. /***********************************************************************
  70. *
  71. * Globals
  72. *
  73. ***********************************************************************/
  74. static NPNetscapeFuncs gNetscapeFuncs; /* Netscape Function table */
  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. void
  85. NPN_Version(int* plugin_major, int* plugin_minor,
  86. int* netscape_major, int* netscape_minor)
  87. {
  88. *plugin_major = NP_VERSION_MAJOR;
  89. *plugin_minor = NP_VERSION_MINOR;
  90. /* Major version is in high byte */
  91. *netscape_major = gNetscapeFuncs.version >> 8;
  92. /* Minor version is in low byte */
  93. *netscape_minor = gNetscapeFuncs.version & 0xFF;
  94. }
  95. NPError
  96. NPN_GetValue(NPP instance, NPNVariable variable, void *r_value)
  97. {
  98. return (*gNetscapeFuncs.getvalue)(instance, variable, r_value);
  99. }
  100. NPError
  101. NPN_SetValue(NPP instance, NPPVariable variable, void *value)
  102. {
  103. return (*gNetscapeFuncs.setvalue)(instance, variable, value);
  104. }
  105. NPError
  106. NPN_GetURL(NPP instance, const char* url, const char* window)
  107. {
  108. return (*gNetscapeFuncs.geturl)(instance, url, window);
  109. }
  110. NPError
  111. NPN_GetURLNotify(NPP instance, const char* url, const char* window, void* notifyData)
  112. {
  113. return (*gNetscapeFuncs.geturlnotify)(instance, url, window, notifyData);
  114. }
  115. NPError
  116. NPN_PostURL(NPP instance, const char* url, const char* window,
  117. uint32_t len, const char* buf, NPBool file)
  118. {
  119. return (*gNetscapeFuncs.posturl)(instance, url, window, len, buf, file);
  120. }
  121. NPError
  122. NPN_PostURLNotify(NPP instance, const char* url, const char* window, uint32_t len,
  123. const char* buf, NPBool file, void* notifyData)
  124. {
  125. return (*gNetscapeFuncs.posturlnotify)(instance, url, window, len, buf, file, notifyData);
  126. }
  127. NPError
  128. NPN_RequestRead(NPStream* stream, NPByteRange* rangeList)
  129. {
  130. return (*gNetscapeFuncs.requestread)(stream, rangeList);
  131. }
  132. NPError
  133. NPN_NewStream(NPP instance, NPMIMEType type, const char *window,
  134. NPStream** stream_ptr)
  135. {
  136. return (*gNetscapeFuncs.newstream)(instance, type, window, stream_ptr);
  137. }
  138. int32_t
  139. NPN_Write(NPP instance, NPStream* stream, int32_t len, void* buffer)
  140. {
  141. return (*gNetscapeFuncs.write)(instance, stream, len, buffer);
  142. }
  143. NPError
  144. NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason)
  145. {
  146. return (*gNetscapeFuncs.destroystream)(instance, stream, reason);
  147. }
  148. void
  149. NPN_Status(NPP instance, const char* message)
  150. {
  151. (*gNetscapeFuncs.status)(instance, message);
  152. }
  153. const char*
  154. NPN_UserAgent(NPP instance)
  155. {
  156. return (*gNetscapeFuncs.uagent)(instance);
  157. }
  158. void*
  159. NPN_MemAlloc(uint32_t size)
  160. {
  161. return (*gNetscapeFuncs.memalloc)(size);
  162. }
  163. void NPN_MemFree(void* ptr)
  164. {
  165. (*gNetscapeFuncs.memfree)(ptr);
  166. }
  167. uint32_t NPN_MemFlush(uint32_t size)
  168. {
  169. return (*gNetscapeFuncs.memflush)(size);
  170. }
  171. void NPN_ReloadPlugins(NPBool reloadPages)
  172. {
  173. (*gNetscapeFuncs.reloadplugins)(reloadPages);
  174. }
  175. void
  176. NPN_InvalidateRect(NPP instance, NPRect *invalidRect)
  177. {
  178. (*gNetscapeFuncs.invalidaterect)(instance, invalidRect);
  179. }
  180. void
  181. NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion)
  182. {
  183. (*gNetscapeFuncs.invalidateregion)(instance, invalidRegion);
  184. }
  185. void
  186. NPN_ForceRedraw(NPP instance)
  187. {
  188. (*gNetscapeFuncs.forceredraw)(instance);
  189. }
  190. void NPN_PushPopupsEnabledState(NPP instance, NPBool enabled)
  191. {
  192. (*gNetscapeFuncs.pushpopupsenabledstate)(instance, enabled);
  193. }
  194. void NPN_PopPopupsEnabledState(NPP instance)
  195. {
  196. (*gNetscapeFuncs.poppopupsenabledstate)(instance);
  197. }
  198. NPIdentifier NPN_GetStringIdentifier(const NPUTF8 *name)
  199. {
  200. return (*gNetscapeFuncs.getstringidentifier)(name);
  201. }
  202. void NPN_GetStringIdentifiers(const NPUTF8 **names, int32_t nameCount,
  203. NPIdentifier *identifiers)
  204. {
  205. (*gNetscapeFuncs.getstringidentifiers)(names, nameCount, identifiers);
  206. }
  207. NPIdentifier NPN_GetIntIdentifier(int32_t intid)
  208. {
  209. return (*gNetscapeFuncs.getintidentifier)(intid);
  210. }
  211. bool NPN_IdentifierIsString(NPIdentifier identifier)
  212. {
  213. return (*gNetscapeFuncs.identifierisstring)(identifier);
  214. }
  215. NPUTF8 *NPN_UTF8FromIdentifier(NPIdentifier identifier)
  216. {
  217. return (*gNetscapeFuncs.utf8fromidentifier)(identifier);
  218. }
  219. int32_t NPN_IntFromIdentifier(NPIdentifier identifier)
  220. {
  221. return (*gNetscapeFuncs.intfromidentifier)(identifier);
  222. }
  223. NPObject *NPN_CreateObject(NPP npp, NPClass *aClass)
  224. {
  225. return (*gNetscapeFuncs.createobject)(npp, aClass);
  226. }
  227. NPObject *NPN_RetainObject(NPObject *obj)
  228. {
  229. return (*gNetscapeFuncs.retainobject)(obj);
  230. }
  231. void NPN_ReleaseObject(NPObject *obj)
  232. {
  233. (*gNetscapeFuncs.releaseobject)(obj);
  234. }
  235. bool NPN_Invoke(NPP npp, NPObject* obj, NPIdentifier methodName,
  236. const NPVariant *args, uint32_t argCount, NPVariant *result)
  237. {
  238. return (*gNetscapeFuncs.invoke)(npp, obj, methodName, args, argCount, result);
  239. }
  240. bool NPN_InvokeDefault(NPP npp, NPObject* obj, const NPVariant *args,
  241. uint32_t argCount, NPVariant *result)
  242. {
  243. return (*gNetscapeFuncs.invokeDefault)(npp, obj, args, argCount, result);
  244. }
  245. bool NPN_Evaluate(NPP npp, NPObject* obj, NPString *script,
  246. NPVariant *result)
  247. {
  248. return (*gNetscapeFuncs.evaluate)(npp, obj, script, result);
  249. }
  250. bool NPN_GetProperty(NPP npp, NPObject* obj, NPIdentifier propertyName,
  251. NPVariant *result)
  252. {
  253. return (*gNetscapeFuncs.getproperty)(npp, obj, propertyName, result);
  254. }
  255. bool NPN_SetProperty(NPP npp, NPObject* obj, NPIdentifier propertyName,
  256. const NPVariant *value)
  257. {
  258. return (*gNetscapeFuncs.setproperty)(npp, obj, propertyName, value);
  259. }
  260. bool NPN_RemoveProperty(NPP npp, NPObject* obj, NPIdentifier propertyName)
  261. {
  262. return (*gNetscapeFuncs.removeproperty)(npp, obj, propertyName);
  263. }
  264. bool NPN_HasProperty(NPP npp, NPObject* obj, NPIdentifier propertyName)
  265. {
  266. return (*gNetscapeFuncs.hasproperty)(npp, obj, propertyName);
  267. }
  268. bool NPN_HasMethod(NPP npp, NPObject* obj, NPIdentifier methodName)
  269. {
  270. return (*gNetscapeFuncs.hasmethod)(npp, obj, methodName);
  271. }
  272. void NPN_ReleaseVariantValue(NPVariant *variant)
  273. {
  274. (*gNetscapeFuncs.releasevariantvalue)(variant);
  275. }
  276. void NPN_SetException(NPObject* obj, const NPUTF8 *message)
  277. {
  278. (*gNetscapeFuncs.setexception)(obj, message);
  279. }
  280. /***********************************************************************
  281. *
  282. * Wrapper functions : Netscape Navigator -> plugin
  283. *
  284. * These functions let the plugin developer just create the APIs
  285. * as documented and defined in npapi.h, without needing to
  286. * install those functions in the function table or worry about
  287. * setting up globals for 68K plugins.
  288. *
  289. ***********************************************************************/
  290. NPError
  291. Private_New(NPMIMEType pluginType, NPP instance, uint16_t mode,
  292. int16_t argc, char* argn[], char* argv[], NPSavedData* saved)
  293. {
  294. NPError ret;
  295. PLUGINDEBUGSTR("New");
  296. ret = NPP_New(pluginType, instance, mode, argc, argn, argv, saved);
  297. return ret;
  298. }
  299. NPError
  300. Private_Destroy(NPP instance, NPSavedData** save)
  301. {
  302. PLUGINDEBUGSTR("Destroy");
  303. return NPP_Destroy(instance, save);
  304. }
  305. NPError
  306. Private_SetWindow(NPP instance, NPWindow* window)
  307. {
  308. NPError err;
  309. PLUGINDEBUGSTR("SetWindow");
  310. err = NPP_SetWindow(instance, window);
  311. return err;
  312. }
  313. NPError
  314. Private_NewStream(NPP instance, NPMIMEType type, NPStream* stream,
  315. NPBool seekable, uint16_t* stype)
  316. {
  317. NPError err;
  318. PLUGINDEBUGSTR("NewStream");
  319. err = NPP_NewStream(instance, type, stream, seekable, stype);
  320. return err;
  321. }
  322. int32_t
  323. Private_WriteReady(NPP instance, NPStream* stream)
  324. {
  325. unsigned int result;
  326. PLUGINDEBUGSTR("WriteReady");
  327. result = NPP_WriteReady(instance, stream);
  328. return result;
  329. }
  330. int32_t
  331. Private_Write(NPP instance, NPStream* stream, int32_t offset, int32_t len,
  332. void* buffer)
  333. {
  334. unsigned int result;
  335. PLUGINDEBUGSTR("Write");
  336. result = NPP_Write(instance, stream, offset, len, buffer);
  337. return result;
  338. }
  339. void
  340. Private_StreamAsFile(NPP instance, NPStream* stream, const char* fname)
  341. {
  342. PLUGINDEBUGSTR("StreamAsFile");
  343. NPP_StreamAsFile(instance, stream, fname);
  344. }
  345. NPError
  346. Private_DestroyStream(NPP instance, NPStream* stream, NPError reason)
  347. {
  348. NPError err;
  349. PLUGINDEBUGSTR("DestroyStream");
  350. err = NPP_DestroyStream(instance, stream, reason);
  351. return err;
  352. }
  353. void
  354. Private_URLNotify(NPP instance, const char* url,
  355. NPReason reason, void* notifyData)
  356. {
  357. PLUGINDEBUGSTR("URLNotify");
  358. NPP_URLNotify(instance, url, reason, notifyData);
  359. }
  360. void
  361. Private_Print(NPP instance, NPPrint* platformPrint)
  362. {
  363. PLUGINDEBUGSTR("Print");
  364. NPP_Print(instance, platformPrint);
  365. }
  366. int16_t
  367. Private_HandleEvent(NPP instance, void* event)
  368. {
  369. PLUGINDEBUGSTR("HandleEvent");
  370. return NPP_HandleEvent(instance, event);
  371. }
  372. /***********************************************************************
  373. *
  374. * These functions are located automagically by netscape.
  375. *
  376. ***********************************************************************/
  377. /*
  378. * NP_GetPluginVersion [optional]
  379. * - The browser uses the return value to indicate to the user what version of
  380. * this plugin is installed.
  381. */
  382. char *
  383. NP_GetPluginVersion(void)
  384. {
  385. return "1.0.0.15";
  386. }
  387. /*
  388. * NP_GetMIMEDescription
  389. * - Netscape needs to know about this symbol
  390. * - Netscape uses the return value to identify when an object instance
  391. * of this plugin should be created.
  392. */
  393. //char *
  394. //NP_GetMIMEDescription(void)
  395. //{
  396. // return NPP_GetMIMEDescription();
  397. //}
  398. /*
  399. * NP_GetValue [optional]
  400. * - Netscape needs to know about this symbol.
  401. * - Interfaces with plugin to get values for predefined variables
  402. * that the navigator needs.
  403. */
  404. NPError
  405. NP_GetValue(void* future, NPPVariable variable, void *value)
  406. {
  407. return NPP_GetValue(future, variable, value);
  408. }
  409. /*
  410. * NP_Initialize
  411. * - Netscape needs to know about this symbol.
  412. * - It calls this function after looking up its symbol before it
  413. * is about to create the first ever object of this kind.
  414. *
  415. * PARAMETERS
  416. * nsTable - The netscape function table. If developers just use these
  417. * wrappers, they don't need to worry about all these function
  418. * tables.
  419. * RETURN
  420. * pluginFuncs
  421. * - This functions needs to fill the plugin function table
  422. * pluginFuncs and return it. Netscape Navigator plugin
  423. * library will use this function table to call the plugin.
  424. *
  425. */
  426. NPError
  427. NP_Initialize(NPNetscapeFuncs* nsTable)
  428. {
  429. NPError err = NPERR_NO_ERROR;
  430. PLUGINDEBUGSTR("NP_Initialize");
  431. /* validate input parameters */
  432. if (nsTable == NULL)
  433. err = NPERR_INVALID_FUNCTABLE_ERROR;
  434. /*
  435. * Check the major version passed in Netscape's function table.
  436. * We won't load if the major version is newer than what we expect.
  437. * Also check that the function tables passed in are big enough for
  438. * all the functions we need (they could be bigger, if Netscape added
  439. * new APIs, but that's OK with us -- we'll just ignore them).
  440. *
  441. */
  442. if (err == NPERR_NO_ERROR) {
  443. if ((nsTable->version >> 8) > NP_VERSION_MAJOR)
  444. err = NPERR_INCOMPATIBLE_VERSION_ERROR;
  445. if (nsTable->size < ((char *)&nsTable->posturlnotify - (char *)nsTable))
  446. err = NPERR_INVALID_FUNCTABLE_ERROR;
  447. }
  448. if (err == NPERR_NO_ERROR) {
  449. /*
  450. * Copy all the fields of Netscape function table into our
  451. * copy so we can call back into Netscape later. Note that
  452. * we need to copy the fields one by one, rather than assigning
  453. * the whole structure, because the Netscape function table
  454. * could actually be bigger than what we expect.
  455. */
  456. gNetscapeFuncs.version = nsTable->version;
  457. gNetscapeFuncs.size = nsTable->size;
  458. gNetscapeFuncs.posturl = nsTable->posturl;
  459. gNetscapeFuncs.geturl = nsTable->geturl;
  460. gNetscapeFuncs.geturlnotify = nsTable->geturlnotify;
  461. gNetscapeFuncs.requestread = nsTable->requestread;
  462. gNetscapeFuncs.newstream = nsTable->newstream;
  463. gNetscapeFuncs.write = nsTable->write;
  464. gNetscapeFuncs.destroystream = nsTable->destroystream;
  465. gNetscapeFuncs.status = nsTable->status;
  466. gNetscapeFuncs.uagent = nsTable->uagent;
  467. gNetscapeFuncs.memalloc = nsTable->memalloc;
  468. gNetscapeFuncs.memfree = nsTable->memfree;
  469. gNetscapeFuncs.memflush = nsTable->memflush;
  470. gNetscapeFuncs.reloadplugins = nsTable->reloadplugins;
  471. gNetscapeFuncs.getvalue = nsTable->getvalue;
  472. gNetscapeFuncs.setvalue = nsTable->setvalue;
  473. gNetscapeFuncs.posturlnotify = nsTable->posturlnotify;
  474. if (nsTable->size >= ((char *)&nsTable->setexception - (char *)nsTable))
  475. {
  476. gNetscapeFuncs.invalidaterect = nsTable->invalidaterect;
  477. gNetscapeFuncs.invalidateregion = nsTable->invalidateregion;
  478. gNetscapeFuncs.forceredraw = nsTable->forceredraw;
  479. gNetscapeFuncs.getstringidentifier = nsTable->getstringidentifier;
  480. gNetscapeFuncs.getstringidentifiers = nsTable->getstringidentifiers;
  481. gNetscapeFuncs.getintidentifier = nsTable->getintidentifier;
  482. gNetscapeFuncs.identifierisstring = nsTable->identifierisstring;
  483. gNetscapeFuncs.utf8fromidentifier = nsTable->utf8fromidentifier;
  484. gNetscapeFuncs.intfromidentifier = nsTable->intfromidentifier;
  485. gNetscapeFuncs.createobject = nsTable->createobject;
  486. gNetscapeFuncs.retainobject = nsTable->retainobject;
  487. gNetscapeFuncs.releaseobject = nsTable->releaseobject;
  488. gNetscapeFuncs.invoke = nsTable->invoke;
  489. gNetscapeFuncs.invokeDefault = nsTable->invokeDefault;
  490. gNetscapeFuncs.evaluate = nsTable->evaluate;
  491. gNetscapeFuncs.getproperty = nsTable->getproperty;
  492. gNetscapeFuncs.setproperty = nsTable->setproperty;
  493. gNetscapeFuncs.removeproperty = nsTable->removeproperty;
  494. gNetscapeFuncs.hasproperty = nsTable->hasproperty;
  495. gNetscapeFuncs.hasmethod = nsTable->hasmethod;
  496. gNetscapeFuncs.releasevariantvalue = nsTable->releasevariantvalue;
  497. gNetscapeFuncs.setexception = nsTable->setexception;
  498. }
  499. else
  500. {
  501. gNetscapeFuncs.invalidaterect = NULL;
  502. gNetscapeFuncs.invalidateregion = NULL;
  503. gNetscapeFuncs.forceredraw = NULL;
  504. gNetscapeFuncs.getstringidentifier = NULL;
  505. gNetscapeFuncs.getstringidentifiers = NULL;
  506. gNetscapeFuncs.getintidentifier = NULL;
  507. gNetscapeFuncs.identifierisstring = NULL;
  508. gNetscapeFuncs.utf8fromidentifier = NULL;
  509. gNetscapeFuncs.intfromidentifier = NULL;
  510. gNetscapeFuncs.createobject = NULL;
  511. gNetscapeFuncs.retainobject = NULL;
  512. gNetscapeFuncs.releaseobject = NULL;
  513. gNetscapeFuncs.invoke = NULL;
  514. gNetscapeFuncs.invokeDefault = NULL;
  515. gNetscapeFuncs.evaluate = NULL;
  516. gNetscapeFuncs.getproperty = NULL;
  517. gNetscapeFuncs.setproperty = NULL;
  518. gNetscapeFuncs.removeproperty = NULL;
  519. gNetscapeFuncs.hasproperty = NULL;
  520. gNetscapeFuncs.releasevariantvalue = NULL;
  521. gNetscapeFuncs.setexception = NULL;
  522. }
  523. if (nsTable->size >=
  524. ((char *)&nsTable->poppopupsenabledstate - (char *)nsTable))
  525. {
  526. gNetscapeFuncs.pushpopupsenabledstate = nsTable->pushpopupsenabledstate;
  527. gNetscapeFuncs.poppopupsenabledstate = nsTable->poppopupsenabledstate;
  528. }
  529. else
  530. {
  531. gNetscapeFuncs.pushpopupsenabledstate = NULL;
  532. gNetscapeFuncs.poppopupsenabledstate = NULL;
  533. }
  534. }
  535. return err;
  536. }
  537. /*
  538. * NP_GetEntryPoints
  539. * - [sgross]: split from NP_Initialize
  540. */
  541. NPError
  542. NP_GetEntryPoints(NPPluginFuncs* pluginFuncs)
  543. {
  544. NPError err = NPERR_NO_ERROR;
  545. PLUGINDEBUGSTR("NP_GetEntryPoints");
  546. /* validate input parameters */
  547. if (pluginFuncs == NULL)
  548. err = NPERR_INVALID_FUNCTABLE_ERROR;
  549. if (err == NPERR_NO_ERROR) {
  550. //if (pluginFuncs->size < sizeof(NPPluginFuncs))
  551. // err = NPERR_INVALID_FUNCTABLE_ERROR;
  552. }
  553. if (err == NPERR_NO_ERROR) {
  554. /*
  555. * Set up the plugin function table that Netscape will use to
  556. * call us. Netscape needs to know about our version and size
  557. * and have a UniversalProcPointer for every function we
  558. * implement.
  559. */
  560. pluginFuncs->version = (NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR;
  561. pluginFuncs->size = sizeof(NPPluginFuncs);
  562. pluginFuncs->newp = (NPP_NewProcPtr)(Private_New);
  563. pluginFuncs->destroy = (NPP_DestroyProcPtr)(Private_Destroy);
  564. pluginFuncs->setwindow = (NPP_SetWindowProcPtr)(Private_SetWindow);
  565. pluginFuncs->newstream = (NPP_NewStreamProcPtr)(Private_NewStream);
  566. pluginFuncs->destroystream = (NPP_DestroyStreamProcPtr)(Private_DestroyStream);
  567. pluginFuncs->asfile = (NPP_StreamAsFileProcPtr)(Private_StreamAsFile);
  568. pluginFuncs->writeready = (NPP_WriteReadyProcPtr)(Private_WriteReady);
  569. pluginFuncs->write = (NPP_WriteProcPtr)(Private_Write);
  570. pluginFuncs->print = (NPP_PrintProcPtr)(Private_Print);
  571. pluginFuncs->event = (NPP_HandleEventProcPtr)(Private_HandleEvent);
  572. pluginFuncs->urlnotify = (NPP_URLNotifyProcPtr)(Private_URLNotify);
  573. pluginFuncs->javaClass = NULL;
  574. // This function is supposedly loaded magically, but that doesn't
  575. // seem to be true.
  576. pluginFuncs->getvalue = (NPP_GetValueProcPtr)(NP_GetValue);
  577. err = NPP_Initialize();
  578. }
  579. return err;
  580. }
  581. /*
  582. * NP_Shutdown [optional]
  583. * - Netscape needs to know about this symbol.
  584. * - It calls this function after looking up its symbol after
  585. * the last object of this kind has been destroyed.
  586. *
  587. */
  588. NPError
  589. NP_Shutdown(void)
  590. {
  591. PLUGINDEBUGSTR("NP_Shutdown");
  592. NPP_Shutdown();
  593. return NPERR_NO_ERROR;
  594. }