]> git.saurik.com Git - wxWidgets.git/blame - utils/nplugin/src/npapi.h
A fix for attribrute sorting, but it's still broken if there are
[wxWidgets.git] / utils / nplugin / src / npapi.h
CommitLineData
bbf1f0e5
KB
1/*
2 * npapi.h $Revision$
3 * Netscape client plug-in API spec
4 */
5
6#ifndef _NPAPI_H_
7#define _NPAPI_H_
8
9
10/* XXX this needs to get out of here */
11#if defined(__MWERKS__)
12#ifndef XP_MAC
13#define XP_MAC
14#endif
15#endif
16
17
18/*
19 * Version constants
20 */
21
22#define NP_VERSION_MAJOR 0
23#define NP_VERSION_MINOR 6
24
25
26
27/*
28 * Basic types
29 */
30
31#ifndef _UINT16
32typedef unsigned short uint16;
33#endif
34#ifndef _UINT32
35typedef unsigned long uint32;
36#endif
37#ifndef _INT16
38typedef short int16;
39#endif
40#ifndef _INT32
41typedef long int32;
42#endif
43
44#ifndef FALSE
45#define FALSE (0)
46#endif
47#ifndef TRUE
48#define TRUE (1)
49#endif
50#ifndef NULL
51#define NULL (0L)
52#endif
53
54typedef unsigned char NPBool;
55typedef void* NPEvent;
56typedef int16 NPError;
57typedef char* NPMIMEType;
58
59
60/*
61 * NPP is a plug-in's opaque instance handle
62 */
63typedef struct _NPP
64{
65 void* pdata; /* plug-in private data */
66 void* ndata; /* netscape private data */
67} NPP_t;
68
69typedef NPP_t* NPP;
70
71
72
73typedef struct _NPStream
74{
75 void* pdata; /* plug-in private data */
76 void* ndata; /* netscape private data */
77 const char* url;
78 uint32 end;
79 uint32 lastmodified;
80} NPStream;
81
82typedef struct _NPByteRange
83{
84 int32 offset; /* negative offset means from the end */
85 uint32 length;
86 struct _NPByteRange* next;
87} NPByteRange;
88
89
90typedef struct _NPSavedData
91{
92 int32 len;
93 void* buf;
94} NPSavedData;
95
96
97
98typedef struct _NPRect
99{
100 uint16 top;
101 uint16 left;
102 uint16 bottom;
103 uint16 right;
104} NPRect;
105
106typedef struct _NPWindow
107{
108 void* window; /* platform specific window handle */
109 uint32 x; /* position of top left corner relative to a netscape page */
110 uint32 y;
111 uint32 width; /* maximum window size */
112 uint32 height;
113 NPRect clipRect; /* clipping rectangle in port coordinates */
114} NPWindow;
115
116
117
118typedef struct _NPFullPrint
119{
120 NPBool pluginPrinted; /* Set TRUE if plugin handled fullscreen printing */
121 NPBool printOne; /* TRUE if plugin should print one copy to default printer */
122 void* platformPrint; /* Platform-specific printing info */
123} NPFullPrint;
124
125typedef struct _NPEmbedPrint
126{
127 NPWindow window;
128 void* platformPrint; /* Platform-specific printing info */
129} NPEmbedPrint;
130
131typedef struct _NPPrint
132{
133 uint16 mode; /* NP_FULL or NP_EMBED */
134 union
135 {
136 NPFullPrint fullPrint; /* if mode is NP_FULL */
137 NPEmbedPrint embedPrint; /* if mode is NP_EMBED */
138 } print;
139} NPPrint;
140
141
142
143
144#ifdef XP_MAC
145
146/*
147 * Mac-specific structures and definitions.
148 */
149
150#include <Quickdraw.h>
151#include <Events.h>
152
153typedef struct NP_Port
154{
155 CGrafPtr port; /* Grafport */
156 int32 portx; /* position inside the topmost window */
157 int32 porty;
158} NP_Port;
159
160/*
161 * Non-standard event types that can be passed to HandleEvent
162 */
163#define getFocusEvent (osEvt + 16)
164#define loseFocusEvent (osEvt + 17)
165#define adjustCursorEvent (osEvt + 18)
166
167#endif /* XP_MAC */
168
169
170
171
172#define NP_EMBED 1
173#define NP_FULL 2
174#define NP_BACKGROUND 3
175
176#define NP_NORMAL 1
177#define NP_SEEK 2
178#define NP_ASFILE 3
179
180#define NP_MAXREADY (((unsigned)(~0)<<1)>>1)
181
182
183/*
184 * Error and reason code definitions.
185 */
186
187#define NP_NOERR 0
188#define NP_EINVAL 1
189#define NP_EABORT 2
190
191#define NPERR_BASE 0
192#define NPERR_NO_ERROR (NPERR_BASE + 0)
193#define NPERR_GENERIC_ERROR (NPERR_BASE + 1)
194#define NPERR_INVALID_INSTANCE_ERROR (NPERR_BASE + 2)
195#define NPERR_INVALID_FUNCTABLE_ERROR (NPERR_BASE + 3)
196#define NPERR_MODULE_LOAD_FAILED_ERROR (NPERR_BASE + 4)
197#define NPERR_OUT_OF_MEMORY_ERROR (NPERR_BASE + 5)
198#define NPERR_INVALID_PLUGIN_ERROR (NPERR_BASE + 6)
199#define NPERR_INVALID_PLUGIN_DIR_ERROR (NPERR_BASE + 7)
200#define NPERR_INCOMPATIBLE_VERSION_ERROR (NPERR_BASE + 8)
201
202#define NPRES_BASE 0
203#define NPRES_NETWORK_ERR (NPRES_BASE + 0)
204#define NPRES_USER_BREAK (NPRES_BASE + 1)
205#define NPRES_DONE (NPRES_BASE + 3)
206
207
208
209/*
210 * Function prototypes.
211 * Functions beginning with 'NPP' are functions provided by the plugin that Netscape will call.
212 * Functions beginning with 'NPN' are functions provided by Netscape that the plugin will call.
213 */
214
215#if defined(_WINDOWS) && !defined(__WIN32__)
216#define NP_LOADDS _loadds
217#else
218#define NP_LOADDS
219#endif
220
221#ifdef __cplusplus
222extern "C" {
223#endif
224
225NPError NPP_Initialize(void);
226void NPP_Shutdown(void);
227NPError NP_LOADDS NPP_New(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved);
228NPError NP_LOADDS NPP_Destroy(NPP instance, NPSavedData** save);
229NPError NP_LOADDS NPP_SetWindow(NPP instance, NPWindow* window);
230NPError NP_LOADDS NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype);
231NPError NP_LOADDS NPP_DestroyStream(NPP instance, NPStream* stream, NPError reason);
232int32 NP_LOADDS NPP_WriteReady(NPP instance, NPStream* stream);
233int32 NP_LOADDS NPP_Write(NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer);
234void NP_LOADDS NPP_StreamAsFile(NPP instance, NPStream* stream, const char* fname);
235void NP_LOADDS NPP_Print(NPP instance, NPPrint* platformPrint);
236int16 NPP_HandleEvent(NPP instance, void* event);
237
238void NPN_Version(int* plugin_major, int* plugin_minor, int* netscape_major, int* netscape_minor);
239NPError NPN_GetURL(NPP instance, const char* url, const char* window);
240NPError NPN_PostURL(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file);
241NPError NPN_RequestRead(NPStream* stream, NPByteRange* rangeList);
242NPError NPN_NewStream(NPP instance, NPMIMEType type, NPStream* stream);
243int32 NPN_Write(NPP instance, NPStream* stream, int32 len, void* buffer);
244NPError NPN_DestroyStream(NPP instance, NPStream* stream, NPError reason);
245void NPN_Status(NPP instance, const char* message);
246const char* NPN_UserAgent(NPP instance);
247void* NPN_MemAlloc(uint32 size);
248void NPN_MemFree(void* ptr);
249uint32 NPN_MemFlush(uint32 size);
250void NPN_ReloadPlugins(NPBool reloadPages);
251
252#ifdef __cplusplus
253} /* end extern "C" */
254#endif
255
256
257#endif /* _NPAPI_H_ */
258