Advertisement
Guest User

Untitled

a guest
Jul 21st, 2011
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.63 KB | None | 0 0
  1. // Define callbacks do plugin
  2. EXPORT NPError WINAPI OSCALL
  3. NP_GetEntryPoints(NPPluginFuncs *nppFuncs) {
  4.     _log("called");
  5.     nppFuncs->version   = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
  6.     nppFuncs->newp      = plugin_new;
  7.     nppFuncs->destroy   = plugin_destroy;
  8.     nppFuncs->getvalue  = plugin_getValue;
  9.     nppFuncs->event     = plugin_handleEvent;
  10.     nppFuncs->setwindow = plugin_setWindow;
  11.     nppFuncs->size      = sizeof(*nppFuncs);
  12.     nppFuncs->newstream = plugin_newStream;
  13.     nppFuncs->destroystream = plugin_destroyStream;
  14.     nppFuncs->asfile = plugin_streamAsFile;
  15.     nppFuncs->writeready = plugin_writeReady;
  16.     nppFuncs->write = plugin_write;
  17.     nppFuncs->print = plugin_print;
  18.     nppFuncs->urlnotify = plugin_URLNotify;
  19.     nppFuncs->setvalue = plugin_setValue;
  20.  
  21.     return NPERR_NO_ERROR;
  22. }
  23.  
  24. #ifndef _WIN32
  25. #define HIBYTE(x) ((((uint32_t)(x)) & 0xff00) >> 8)
  26. #endif
  27.  
  28. #ifndef _WIN32
  29. NPError OSCALL WINAPI
  30. NP_Initialize(NPNetscapeFuncs *npnf, NPPluginFuncs *nppfuncs) {
  31.     _log("called");
  32.     if (npnf == 0)
  33.         return NPERR_INVALID_FUNCTABLE_ERROR;
  34.     if (HIBYTE(npnf->version) > NP_VERSION_MAJOR)
  35.         return NPERR_INVALID_FUNCTABLE_ERROR;
  36.     npnfuncs = npnf;
  37.     NP_GetEntryPoints(nppfuncs);
  38.     return NPERR_NO_ERROR;
  39. }
  40. #else
  41. EXPORT NPError OSCALL
  42. NP_Initialize(NPNetscapeFuncs* bFuncs) {
  43.     _log("called");
  44.     npnfuncs = bFuncs;
  45. }
  46. #endif
  47.  
  48. EXPORT NPError WINAPI OSCALL
  49. NP_Shutdown() {
  50.     _log("called");
  51.     return NPERR_NO_ERROR;
  52. }
  53.  
  54. EXPORT const char *
  55. NP_GetMIMEDescription(void) {
  56.     _log("called");
  57.     return "application/x-example-info:.npexample:example@ex.com";
  58. }
  59.  
  60. EXPORT NPError WINAPI OSCALL
  61. NP_GetValue(void *npp, NPPVariable variable, void *value) {
  62.     _log("called");
  63.     inst = (NPP) npp;
  64.     return plugin_getValue((NPP) npp, variable, value);
  65. }
  66.  
  67. #ifdef _WIN32
  68. BOOL WINAPI
  69. DllMain (HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
  70. {
  71.     switch (dwReason)
  72.     {
  73.         case DLL_PROCESS_ATTACH:
  74.             // Code to run when the DLL is loaded
  75.             break;
  76.  
  77.         case DLL_PROCESS_DETACH:
  78.             // Code to run when the DLL is freed
  79.             break;
  80.  
  81.         case DLL_THREAD_ATTACH:
  82.             // Code to run when a thread is created during the DLL's lifetime
  83.             break;
  84.  
  85.         case DLL_THREAD_DETACH:
  86.             // Code to run when a thread ends normally.
  87.             break;
  88.     }
  89.     return TRUE;
  90. }
  91.  
  92. #define STDAPI_EXPORTED EXPORT HRESULT
  93.  
  94. //Not implemented yet
  95. STDAPI_EXPORTED DllRegisterServer(void)
  96. {
  97. return S_OK;
  98. }
  99.  
  100. //Not implemented yet
  101. STDAPI_EXPORTED DllUnregisterServer(void)
  102. {
  103. return S_OK;
  104. }
  105.  
  106. BOOL WINAPI DllEntryPoint(HINSTANCE hInstance, ULONG ulReason, LPVOID pv) {
  107.     return TRUE;
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement