OLD | NEW |
(Empty) | |
| 1 // Copyright 2010 The Native Client SDK Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can |
| 3 // be found in the LICENSE file. |
| 4 #include <stdbool.h> |
| 5 #include <stdio.h> |
| 6 #include <stdlib.h> |
| 7 #include <string.h> |
| 8 |
| 9 #include <nacl/npupp.h> |
| 10 |
| 11 |
| 12 |
| 13 |
| 14 // These functions are called when a module instance is first loaded, and when |
| 15 // the module instance is finally deleted. They must use C-style linkage. |
| 16 |
| 17 extern "C" { |
| 18 // Populates |plugin_funcs| by calling InitializePluginFunctions. |
| 19 // Declaration: npupp.h |
| 20 // Web Reference: N/A |
| 21 NPError NP_GetEntryPoints(NPPluginFuncs* plugin_funcs) { |
| 22 extern NPError InitializePluginFunctions(NPPluginFuncs* plugin_funcs); |
| 23 return InitializePluginFunctions(plugin_funcs); |
| 24 } |
| 25 |
| 26 // Some platforms, including Native Client use the two-parameter version of |
| 27 // NP_Initialize(), and do not call NP_GetEntryPoints(). Others (Mac, e.g.) |
| 28 // use single-parameter version of NP_Initialize(), and then call |
| 29 // NP_GetEntryPoints() to get the NPP functions. Also, the NPN entry points |
| 30 // are defined by the Native Client loader, but are not defined in the trusted |
| 31 // plugin loader (and must be filled in in NP_Initialize()). |
| 32 // Called when the first instance of this plugin is first allocated to |
| 33 // initialize global state. The browser is hereby telling the plugin its |
| 34 // interface in |browser_functions| and expects the plugin to populate |
| 35 // |plugin_functions| in return. Memory allocated by this function may only |
| 36 // be cleaned up by NP_Shutdown. |
| 37 // returns an NPError if anything went wrong. |
| 38 // Declaration: npupp.h |
| 39 // Documentation URL: https://developer.mozilla.org/en/NP_Initialize |
| 40 NPError NP_Initialize(NPNetscapeFuncs* browser_functions, |
| 41 NPPluginFuncs* plugin_functions) { |
| 42 printf("Duality: NP_Initialize was called!\n"); |
| 43 fflush(stdout); |
| 44 return NP_GetEntryPoints(plugin_functions); |
| 45 } |
| 46 |
| 47 |
| 48 // Called just before the plugin itself is completely unloaded from the |
| 49 // browser. Should clean up anything allocated by NP_Initialize. |
| 50 // Declaration: npupp.h |
| 51 // Documentation URL: https://developer.mozilla.org/en/NP_Shutdown |
| 52 NPError NP_Shutdown() { |
| 53 printf("Duality: NP_Shutdown was called!\n"); |
| 54 fflush(stdout); |
| 55 return NPERR_NO_ERROR; |
| 56 } |
| 57 } // extern "C" |
OLD | NEW |