home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / os2plug.exe / INCLUDE / npapi.h next >
Text File  |  1996-12-14  |  16KB  |  479 lines

  1. /* -*- Mode: C; tab-width: 4; -*- */
  2. /*
  3.  *  npapi.h $Revision: 1.77.6.1 $
  4.  *  Netscape client plug-in API spec
  5.  */
  6.  
  7. #ifndef _NPAPI_H_
  8. #define _NPAPI_H_
  9.  
  10. #ifdef __OS2__
  11. #pragma pack(1)
  12. #endif
  13.  
  14. #ifdef _WINDOWS
  15. #       ifndef XP_PC
  16. #               define XP_PC 1
  17. #       endif /* XP_PC */
  18. #endif /* _WINDOWS */
  19.  
  20. #ifdef __MWERKS__
  21. #       define _declspec __declspec
  22. #       ifdef macintosh
  23. #               ifndef XP_MAC
  24. #                       define XP_MAC 1
  25. #               endif /* XP_MAC */
  26. #       endif /* macintosh */
  27. #       ifdef __INTEL__
  28. #               undef NULL
  29. #               ifndef XP_PC
  30. #                       define XP_PC 1
  31. #               endif /* __INTEL__ */
  32. #       endif /* XP_PC */
  33. #endif /* __MWERKS__ */
  34.  
  35. #if !defined(__OS2__) && !defined(RC_INVOKED)
  36. #include "jri.h"                /* Java Runtime Interface */
  37. #endif
  38.  
  39.  
  40. /*----------------------------------------------------------------------*/
  41. /*                   Plugin Version Constants                           */
  42. /*----------------------------------------------------------------------*/
  43.  
  44. #define NP_VERSION_MAJOR 0
  45. #define NP_VERSION_MINOR 9
  46.  
  47. /* The OS/2 version of Netscape uses RC_DATA to define the
  48.    mime types, file extentions, etc that are required.
  49.    Use a vertical bar to seperate types, end types with \0.
  50.    FileVersion and ProductVersion are 32bit ints, all other
  51.    entries are strings the MUST be terminated wwith a \0.
  52.  
  53. AN EXAMPLE:
  54.  
  55. RCDATA NP_INFO_ProductVersion { 1,0,0,1,}
  56.  
  57. RCDATA NP_INFO_MIMEType    { "video/x-video|",
  58.                              "video/x-flick\0" }
  59. RCDATA NP_INFO_FileExtents { "avi|",
  60.                              "flc\0" }
  61. RCDATA NP_INFO_FileOpenName{ "MMOS2 video player(*.avi)|",
  62.                              "MMOS2 Flc/Fli player(*.flc)\0" }
  63.  
  64. RCDATA NP_INFO_FileVersion       { 1,0,0,1 }
  65. RCDATA NP_INFO_CompanyName       { "Netscape Communications\0" }
  66. RCDATA NP_INFO_FileDescription   { "NPAVI32 Extension DLL\0"
  67. RCDATA NP_INFO_InternalName      { "NPAVI32\0" )
  68. RCDATA NP_INFO_LegalCopyright    { "Copyright Netscape Communications \251 1996\0"
  69. RCDATA NP_INFO_OriginalFilename  { "NVAPI32.DLL" }
  70. RCDATA NP_INFO_ProductName       { "NPAVI32 Dynamic Link Library\0" }
  71.  
  72. */
  73.  
  74.  
  75. /* RC_DATA types for version info - required */
  76. #define NP_INFO_ProductVersion      1
  77. #define NP_INFO_MIMEType            2
  78. #define NP_INFO_FileOpenName        3
  79. #define NP_INFO_FileExtents         4
  80.  
  81. /* RC_DATA types for version info - used if found */
  82. #define NP_INFO_FileDescription     5
  83. #define NP_INFO_ProductName         6
  84.  
  85. /* RC_DATA types for version info - optional */
  86. #define NP_INFO_CompanyName         7
  87. #define NP_INFO_FileVersion         8
  88. #define NP_INFO_InternalName        9
  89. #define NP_INFO_LegalCopyright      10
  90. #define NP_INFO_OriginalFilename    11
  91.  
  92. #ifndef RC_INVOKED
  93.  
  94.  
  95. /*----------------------------------------------------------------------*/
  96. /*                   Definition of Basic Types                          */
  97. /*----------------------------------------------------------------------*/
  98.  
  99. #ifndef _UINT16
  100. typedef unsigned short uint16;
  101. #endif
  102. #ifndef _UINT32
  103. #if defined(__alpha)
  104. typedef unsigned int uint32;
  105. #else /* __alpha */
  106. typedef unsigned long uint32;
  107. #endif /* __alpha */
  108. #endif
  109. #ifndef _INT16
  110. typedef short int16;
  111. #endif
  112. #ifndef _INT32
  113. #if defined(__alpha)
  114. typedef int int32;
  115. #else /* __alpha */
  116. typedef long int32;
  117. #endif /* __alpha */
  118. #endif
  119.  
  120. #ifndef FALSE
  121. #define FALSE (0)
  122. #endif
  123. #ifndef TRUE
  124. #define TRUE (1)
  125. #endif
  126. #ifndef NULL
  127. #define NULL (0L)
  128. #endif
  129.  
  130. typedef unsigned char   NPBool;
  131. typedef void*           NPEvent;
  132. typedef int16            NPError;
  133. typedef int16           NPReason;
  134. typedef char*           NPMIMEType;
  135.  
  136.  
  137.  
  138. /*----------------------------------------------------------------------*/
  139. /*                   Structures and definitions                         */
  140. /*----------------------------------------------------------------------*/
  141.  
  142. /*
  143.  *  NPP is a plug-in's opaque instance handle
  144.  */
  145. typedef struct _NPP
  146. {
  147.     void*       pdata;                  /* plug-in private data */
  148.     void*       ndata;                  /* netscape private data */
  149. } NPP_t;
  150.  
  151. typedef NPP_t*  NPP;
  152.  
  153.  
  154. typedef struct _NPStream
  155. {
  156.     void*               pdata;          /* plug-in private data */
  157.     void*               ndata;          /* netscape private data */
  158.     const char*         url;
  159.     uint32              end;
  160.     uint32              lastmodified;
  161.     void*               notifyData;
  162. } NPStream;
  163.  
  164.  
  165. typedef struct _NPByteRange
  166. {
  167.     int32       offset;                 /* negative offset means from the end */
  168.     uint32      length;
  169.     struct _NPByteRange* next;
  170. } NPByteRange;
  171.  
  172.  
  173. typedef struct _NPSavedData
  174. {
  175.     int32       len;
  176.     void*       buf;
  177. } NPSavedData;
  178.  
  179.  
  180. typedef struct _NPRect
  181. {
  182.     uint16      top;
  183.     uint16      left;
  184.     uint16      bottom;
  185.     uint16      right;
  186. } NPRect;
  187.  
  188.  
  189. #ifdef XP_UNIX
  190. /*
  191.  * Unix specific structures and definitions
  192.  */
  193. #include <X11/Xlib.h>
  194.  
  195. /*
  196.  * Callback Structures.
  197.  *
  198.  * These are used to pass additional platform specific information.
  199.  */
  200. enum {
  201.         NP_SETWINDOW = 1,
  202.         NP_PRINT
  203. };
  204.  
  205. typedef struct
  206. {
  207.     int32               type;
  208. } NPAnyCallbackStruct;
  209.  
  210. typedef struct
  211. {
  212.     int32                       type;
  213.     Display*            display;
  214.     Visual*                     visual;
  215.     Colormap            colormap;
  216.     unsigned int        depth;
  217. } NPSetWindowCallbackStruct;
  218.  
  219. typedef struct
  220. {
  221.     int32                       type;
  222.     FILE*                       fp;
  223. } NPPrintCallbackStruct;
  224.  
  225. /*
  226.  * List of variable names for which NPP_GetValue shall be implemented
  227.  */
  228. typedef enum {
  229.         NPPVpluginNameString = 1,
  230.         NPPVpluginDescriptionString
  231. } NPPVariable;
  232.  
  233. /*
  234.  * List of variable names for which NPN_GetValue is implemented by Mozilla
  235.  */
  236. typedef enum {
  237.         NPNVxDisplay = 1,
  238.         NPNVxtAppContext
  239. } NPNVariable;
  240.  
  241. #endif /* XP_UNIX */
  242.  
  243.  
  244. typedef struct _NPWindow
  245. {
  246.     void*       window;         /* Platform specific window handle */
  247.     uint32      x;              /* OS/2: Position of bottom left corner  */
  248.     uint32      y;              /* OS/2: relative to visible netscape window */
  249.     uint32      width;          /* Maximum window size */
  250.     uint32      height;
  251.     NPRect      clipRect;       /* Clipping rectangle in port coordinates */
  252.                                                  /* Used by MAC only.                      */
  253. #ifdef XP_UNIX
  254.     void *      ws_info;        /* Platform-dependent additonal data */
  255. #endif /* XP_UNIX */
  256. } NPWindow;
  257.  
  258.  
  259. typedef struct _NPFullPrint
  260. {
  261.     NPBool      pluginPrinted;  /* Set TRUE if plugin handled fullscreen */
  262.                                                     /* printing                    */
  263.     NPBool      printOne;               /* TRUE if plugin should print one copy  */
  264.                                                          /* to default printer                                   */
  265.     void*       platformPrint;  /* Platform-specific printing info */
  266. } NPFullPrint;
  267.  
  268. typedef struct _NPEmbedPrint
  269. {
  270.     NPWindow    window;
  271.     void*       platformPrint;  /* Platform-specific printing info */
  272. } NPEmbedPrint;
  273.  
  274. typedef struct _NPPrint
  275. {
  276.     uint16      mode;                                           /* NP_FULL or NP_EMBED */
  277.     union
  278.     {
  279.                 NPFullPrint             fullPrint;              /* if mode is NP_FULL */
  280.                 NPEmbedPrint    embedPrint;             /* if mode is NP_EMBED */
  281.     } print;
  282. } NPPrint;
  283.  
  284.  
  285. #ifdef XP_MAC
  286. /*
  287.  *  Mac-specific structures and definitions.
  288.  */
  289.  
  290. #include <Quickdraw.h>
  291. #include <Events.h>
  292.  
  293. typedef struct NP_Port
  294. {
  295.     CGrafPtr    port;           /* Grafport */
  296.     int32               portx;          /* position inside the topmost window */
  297.     int32               porty;
  298. } NP_Port;
  299.  
  300. /*
  301.  *  Non-standard event types that can be passed to HandleEvent
  302.  */
  303. #define getFocusEvent       (osEvt + 16)
  304. #define loseFocusEvent      (osEvt + 17)
  305. #define adjustCursorEvent   (osEvt + 18)
  306.  
  307. #endif /* XP_MAC */
  308.  
  309.  
  310. /*
  311.  * Values for mode passed to NPP_New:
  312.  */
  313. #define NP_EMBED                1
  314. #define NP_FULL                 2
  315.  
  316. /*
  317.  * Values for stream type passed to NPP_NewStream:
  318.  */
  319. #define NP_NORMAL               1
  320. #define NP_SEEK                 2
  321. #define NP_ASFILE               3
  322. #define NP_ASFILEONLY           4
  323.  
  324. #define NP_MAXREADY     (((unsigned)(~0)<<1)>>1)
  325.  
  326.  
  327.  
  328. /*----------------------------------------------------------------------*/
  329. /*                   Error and Reason Code definitions                  */
  330. /*----------------------------------------------------------------------*/
  331.  
  332. /*
  333.  *      Values of type NPError:
  334.  */
  335. #define NPERR_BASE                                                      0
  336. #define NPERR_NO_ERROR                                          (NPERR_BASE + 0)
  337. #define NPERR_GENERIC_ERROR                                     (NPERR_BASE + 1)
  338. #define NPERR_INVALID_INSTANCE_ERROR            (NPERR_BASE + 2)
  339. #define NPERR_INVALID_FUNCTABLE_ERROR           (NPERR_BASE + 3)
  340. #define NPERR_MODULE_LOAD_FAILED_ERROR          (NPERR_BASE + 4)
  341. #define NPERR_OUT_OF_MEMORY_ERROR                       (NPERR_BASE + 5)
  342. #define NPERR_INVALID_PLUGIN_ERROR                      (NPERR_BASE + 6)
  343. #define NPERR_INVALID_PLUGIN_DIR_ERROR          (NPERR_BASE + 7)
  344. #define NPERR_INCOMPATIBLE_VERSION_ERROR        (NPERR_BASE + 8)
  345. #define NPERR_INVALID_PARAM                             (NPERR_BASE + 9)
  346. #define NPERR_INVALID_URL                                       (NPERR_BASE + 10)
  347. #define NPERR_FILE_NOT_FOUND                            (NPERR_BASE + 11)
  348. #define NPERR_NO_DATA                                           (NPERR_BASE + 12)
  349. #define NPERR_STREAM_NOT_SEEKABLE                       (NPERR_BASE + 13)
  350.  
  351. /*
  352.  *      Values of type NPReason:
  353.  */
  354. #define NPRES_BASE                              0
  355. #define NPRES_DONE                                      (NPRES_BASE + 0)
  356. #define NPRES_NETWORK_ERR                       (NPRES_BASE + 1)
  357. #define NPRES_USER_BREAK                        (NPRES_BASE + 2)
  358.  
  359. /*
  360.  *      Don't use these obsolete error codes any more.
  361.  */
  362. #define NP_NOERR  NP_NOERR_is_obsolete_use_NPERR_NO_ERROR
  363. #define NP_EINVAL NP_EINVAL_is_obsolete_use_NPERR_GENERIC_ERROR
  364. #define NP_EABORT NP_EABORT_is_obsolete_use_NPRES_USER_BREAK
  365.  
  366. /*
  367.  * Version feature information
  368.  */
  369. #define NPVERS_HAS_STREAMOUTPUT                         8
  370. #define NPVERS_HAS_NOTIFICATION                         9
  371. #define NPVERS_HAS_LIVECONNECT                          9
  372. #define NPVERS_WIN16_HAS_LIVECONNECT            10
  373.  
  374.  
  375. /*----------------------------------------------------------------------*/
  376. /*                   Function Prototypes                                */
  377. /*----------------------------------------------------------------------*/
  378.  
  379. #if defined(_WINDOWS) && !defined(WIN32)
  380. #define NP_LOADDS  _loadds
  381. #else
  382. #if defined(__OS2__)
  383. #define NP_LOADDS _System
  384. #else
  385. #define NP_LOADDS
  386. #endif
  387. #endif
  388.  
  389. #ifdef __cplusplus
  390. extern "C" {
  391. #endif
  392.  
  393. /*
  394.  * NPP_* functions are provided by the plugin and called by the navigator.
  395.  */
  396.  
  397. #ifdef XP_UNIX
  398. char*                     NPP_GetMIMEDescription(void);
  399. NPError                     NPP_GetValue(void *instance, NPPVariable variable,
  400.                                                                          void *value);
  401. #endif /* XP_UNIX */
  402. NPError     NP_LOADDS   NPP_Initialize(void);
  403. void        NP_LOADDS   NPP_Shutdown(void);
  404. NPError     NP_LOADDS   NPP_New(NPMIMEType pluginType, NPP instance,
  405.                                                                 uint16 mode, int16 argc, char* argn[],
  406.                                                                 char* argv[], NPSavedData* saved);
  407. NPError     NP_LOADDS   NPP_Destroy(NPP instance, NPSavedData** save);
  408. NPError     NP_LOADDS   NPP_SetWindow(NPP instance, NPWindow* window);
  409. NPError     NP_LOADDS   NPP_NewStream(NPP instance, NPMIMEType type,
  410.                                                                           NPStream* stream, NPBool seekable,
  411.                                                                           uint16* stype);
  412. NPError     NP_LOADDS   NPP_DestroyStream(NPP instance, NPStream* stream,
  413.                                                                                   NPReason reason);
  414. int32       NP_LOADDS   NPP_WriteReady(NPP instance, NPStream* stream);
  415. int32       NP_LOADDS   NPP_Write(NPP instance, NPStream* stream, int32 offset,
  416.                                                                   int32 len, void* buffer);
  417. void        NP_LOADDS   NPP_StreamAsFile(NPP instance, NPStream* stream,
  418.                                                                                  const char* fname);
  419. void        NP_LOADDS   NPP_Print(NPP instance, NPPrint* platformPrint);
  420. int16       NP_LOADDS   NPP_HandleEvent(NPP instance, void* event);
  421. void        NP_LOADDS   NPP_URLNotify(NPP instance, const char* url,
  422.                                                                           NPReason reason, void* notifyData);
  423. #ifndef __OS2__
  424. jref                    NP_LOADDS       NPP_GetJavaClass(void);
  425. #endif
  426.  
  427.  
  428. /*
  429.  * NPN_* functions are provided by the navigator and called by the plugin.
  430.  */
  431.  
  432. #ifdef XP_UNIX
  433. NPError                 NPN_GetValue(NPP instance, NPNVariable variable,
  434.                                                          void *value);
  435. #endif /* XP_UNIX */
  436. void            NP_LOADDS NPN_Version(int* plugin_major, int* plugin_minor,
  437.                                                         int* netscape_major, int* netscape_minor);
  438. NPError         NP_LOADDS NPN_GetURLNotify(NPP instance, const char* url,
  439.                                                                  const char* target, void* notifyData);
  440. NPError         NP_LOADDS NPN_GetURL(NPP instance, const char* url,
  441.                                                    const char* target);
  442. NPError         NP_LOADDS NPN_PostURLNotify(NPP instance, const char* url,
  443.                                                                   const char* target, uint32 len,
  444.                                                                   const char* buf, NPBool file,
  445.                                                                   void* notifyData);
  446. NPError         NP_LOADDS NPN_PostURL(NPP instance, const char* url,
  447.                                                         const char* target, uint32 len,
  448.                                                         const char* buf, NPBool file);
  449. NPError         NP_LOADDS NPN_RequestRead(NPStream* stream, NPByteRange* rangeList);
  450. NPError         NP_LOADDS NPN_NewStream(NPP instance, NPMIMEType type,
  451.                                                           const char* target, NPStream** stream);
  452. int32           NP_LOADDS NPN_Write(NPP instance, NPStream* stream, int32 len,
  453.                                                   void* buffer);
  454. NPError                 NP_LOADDS NPN_DestroyStream(NPP instance, NPStream* stream,
  455.                                                                   NPReason reason);
  456. void            NP_LOADDS NPN_Status(NPP instance, const char* message);
  457. const char*     NP_LOADDS NPN_UserAgent(NPP instance);
  458. void*           NP_LOADDS NPN_MemAlloc(uint32 size);
  459. void            NP_LOADDS NPN_MemFree(void* ptr);
  460. uint32          NP_LOADDS NPN_MemFlush(uint32 size);
  461. void                  NP_LOADDS NPN_ReloadPlugins(NPBool reloadPages);
  462. #ifndef __OS2__
  463. JRIEnv*                 NP_LOADDS NPN_GetJavaEnv(void);
  464. jref                  NP_LOADDS NPN_GetJavaPeer(NPP instance);
  465. #endif
  466.  
  467.  
  468. #ifdef __cplusplus
  469. }  /* end extern "C" */
  470. #endif
  471.  
  472. #endif                  // RC_INVOKED
  473. #ifdef __OS2__
  474. #pragma pack()
  475. #endif
  476.  
  477. #endif /* _NPAPI_H_ */
  478.  
  479.