i hope the node casts are correct here.
[AROS-Contrib.git] / arospdf / xpdf / XpdfPluginAPI.h
blob7dea39dc3917b0e953d69a33f697ebd9ae2c101e
1 /*
2 * XpdfPluginAPI.h
4 * Copyright 2004 Glyph & Cog, LLC
5 */
7 #ifndef XPDFPLUGINAPI_H
8 #define XPDFPLUGINAPI_H
10 #ifdef _WIN32
11 #include <windows.h>
12 #else
13 #define xObject XtObject
14 #include <X11/Intrinsic.h>
15 #undef xObject
16 #endif
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
22 /*------------------------------------------------------------------------
23 * Macros
24 *------------------------------------------------------------------------*/
27 * The current API version.
29 #define xpdfPluginAPIVersion 1
31 #ifdef _WIN32
32 # ifdef __cplusplus
33 # define PLUGINFUNC(retType) extern "C" __declspec(dllexport) retType
34 # else
35 # define PLUGINFUNC(retType) extern __declspec(dllexport) retType
36 # endif
37 #else
38 # ifdef __cplusplus
39 # define PLUGINFUNC(retType) extern "C" retType
40 # else
41 # define PLUGINFUNC(retType) extern retType
42 # endif
43 #endif
45 /*------------------------------------------------------------------------
46 * Plugin setup/cleanup
47 *------------------------------------------------------------------------*/
50 * All plugins are required to implement two functions:
52 * -- Initialize the plugin. Returns non-zero if successful.
53 * PLUGINFUNC(XpdfBool) xpdfInitPlugin(void);
55 * -- Free the plugin.
56 * PLUGINFUNC(void) xpdfFreePlugin(void);
59 /*------------------------------------------------------------------------
60 * Types
61 *------------------------------------------------------------------------*/
64 * Standard C boolean -- zero = false, non-zero = true.
66 typedef int XpdfBool;
67 #define xpdfTrue 1
68 #define xpdfFalse 0
71 * PDF document handle.
73 typedef struct _XpdfDoc *XpdfDoc;
76 * PDF xObject handle.
78 typedef struct _XpdfObject *XpdfObject;
81 * Document access permissions. Any of these can be bitwise 'or'ed
82 * together. If xpdfPermissionOpen is not included, the document
83 * cannot be opened at all, and the other bits are ignored.
85 typedef unsigned int XpdfPermission;
86 #define xpdfPermissionOpen (1 << 0)
87 #define xpdfPermissionPrint (1 << 2)
88 #define xpdfPermissionChange (1 << 3)
89 #define xpdfPermissionCopy (1 << 4)
90 #define xpdfPermissionNotes (1 << 5)
92 /*------------------------------------------------------------------------
93 * Security handler
94 *------------------------------------------------------------------------*/
97 * XpdfSecurityHandler - a security handler plugin should create one
98 * of these and pass it to xpdfRegisterSecurityHandler.
100 #ifdef __cplusplus
101 struct XpdfSecurityHandler {
102 #else
103 typedef struct {
104 #endif
107 * Version of the security handler spec (this document) -- use
108 * xpdfPluginAPIVersion.
110 int version;
113 * Security handler name.
115 char *name;
118 * Any global data the security handler needs. XpdfViewer will pass
119 * this pointer to all handler functions as the <handlerData>
120 * argument.
122 void *handlerData;
125 * Allocate and initialize data for a new document. XpdfViewer will
126 * pass the returned pointer to all other handler functions as the
127 * <docData> argument. Returns non-zero if successful.
129 XpdfBool (*newDoc)(void *handlerData, XpdfDoc doc,
130 XpdfObject encryptDict, void **docData);
133 * Free the data allocated by newDoc.
135 void (*freeDoc)(void *handlerData, void *docData);
138 * Construct authorization data based on the supplied owner and user
139 * passwords (either or both of which may be NULL). This function
140 * is called in "batch" mode, i.e., if the password was supplied on
141 * the command line or via an Xpdf library API. It should not
142 * generate any user interaction (e.g., a password dialog). It is
143 * not required to support this function: the makeAuthData function
144 * pointer can be set to NULL. Returns non-zero if successful.
146 XpdfBool (*makeAuthData)(void *handlerData, void *docData,
147 char *ownerPassword, char *userPassword,
148 void **authData);
151 * Request any needed information (e.g., a password) from the user,
152 * and construct an authorization data xObject. Returns non-zero if
153 * successful.
155 XpdfBool (*getAuthData)(void *handlerData, void *docData,
156 void **authData);
159 * Free the data allocated by getAuthData.
161 void (*freeAuthData)(void *handlerData, void *docData,
162 void *authData);
165 * Request permission to access the document. This returns all
166 * permissions granted by authData.
168 XpdfPermission (*authorize)(void *handlerData, void *docData,
169 void *authData);
172 * Get the decryption key and algorithm version associated with the
173 * document. Returns non-zero if successful.
175 XpdfBool (*getKey)(void *handlerData, void *docData,
176 char **key, int *keyLen, int *cryptVersion);
179 * Free the data allocated by getKey.
181 void (*freeKey)(void *handlerData, void *docData,
182 char *key, int keyLen);
184 #ifdef __cplusplus
186 #else
187 } XpdfSecurityHandler;
188 #endif
190 /*------------------------------------------------------------------------*/
192 typedef struct {
193 int version;
195 /*------------------------------------------------------------------------
196 * Document access functions
197 *------------------------------------------------------------------------*/
200 * Get a document's info dictionary. (The returned xObject must be
201 * freed with xpdfFreeObj.)
203 XpdfObject (*_xpdfGetInfoDict)(XpdfDoc doc);
206 * Get a document's catalog ("root") dictionary. (The returned xObject
207 * must be freed with xpdfFreeObj.)
209 XpdfObject (*_xpdfGetCatalog)(XpdfDoc doc);
211 #ifdef _WIN32
214 * Get the handle for the viewer window associated with the specified
215 * document. [Win32 only]
217 HWND (*_xpdfWin32GetWindow)(XpdfDoc doc);
219 #else
222 * Get the Motif widget for the viewer window associated with the
223 * specified document. [X only]
225 Widget (*_xpdfXGetWindow)(XpdfDoc doc);
227 #endif
229 /*------------------------------------------------------------------------
230 * xObject access functions
231 *------------------------------------------------------------------------*/
234 * Check an xObject's type.
236 XpdfBool (*_xpdfObjIsBool)(XpdfObject obj);
237 XpdfBool (*_xpdfObjIsInt)(XpdfObject obj);
238 XpdfBool (*_xpdfObjIsReal)(XpdfObject obj);
239 XpdfBool (*_xpdfObjIsString)(XpdfObject obj);
240 XpdfBool (*_xpdfObjIsName)(XpdfObject obj);
241 XpdfBool (*_xpdfObjIsNull)(XpdfObject obj);
242 XpdfBool (*_xpdfObjIsArray)(XpdfObject obj);
243 XpdfBool (*_xpdfObjIsDict)(XpdfObject obj);
244 XpdfBool (*_xpdfObjIsStream)(XpdfObject obj);
245 XpdfBool (*_xpdfObjIsRef)(XpdfObject obj);
248 * Value access.
249 * (xObjects returned by xpdfArrayGet and xpdfDictGet must be freed
250 * with xpdfFreeObj.)
252 XpdfBool (*_xpdfBoolValue)(XpdfObject obj);
253 int (*_xpdfIntValue)(XpdfObject obj);
254 double (*_xpdfRealValue)(XpdfObject obj);
255 int (*_xpdfStringLength)(XpdfObject obj);
256 char *(*_xpdfStringValue)(XpdfObject obj);
257 char *(*_xpdfNameValue)(XpdfObject obj);
258 int (*_xpdfArrayLength)(XpdfObject obj);
259 XpdfObject (*_xpdfArrayGet)(XpdfObject obj, int idx);
260 XpdfObject (*_xpdfDictGet)(XpdfObject obj, char *key);
263 * xObject destruction. NB: *all* xObjects must be freed after use.
265 void (*_xpdfFreeObj)(XpdfObject obj);
267 /*------------------------------------------------------------------------
268 * Memory allocation functions
269 *------------------------------------------------------------------------*/
271 void *(*_xpdfMalloc)(int size);
272 void *(*_xpdfRealloc)(void *p, int size);
273 void (*_xpdfFree)(void *p);
275 /*------------------------------------------------------------------------
276 * Security handler functions
277 *------------------------------------------------------------------------*/
280 * Register a new security handler.
282 void (*_xpdfRegisterSecurityHandler)(XpdfSecurityHandler *handler);
284 /*------------------------------------------------------------------------*/
286 } XpdfPluginVecTable;
288 #ifdef _WIN32
290 extern __declspec(dllexport) XpdfPluginVecTable xpdfPluginVecTable;
292 #define xpdfPluginSetup \
293 extern __declspec(dllexport) \
294 XpdfPluginVecTable xpdfPluginVecTable = {xpdfPluginAPIVersion};
296 #else
298 extern XpdfPluginVecTable xpdfPluginVecTable;
300 #define xpdfPluginSetup \
301 XpdfPluginVecTable xpdfPluginVecTable = {xpdfPluginAPIVersion};
303 #endif
305 #define xpdfGetInfoDict (*xpdfPluginVecTable._xpdfGetInfoDict)
306 #define xpdfGetCatalog (*xpdfPluginVecTable._xpdfGetCatalog)
307 #ifdef _WIN32
308 #define xpdfWin32GetWindow (*xpdfPluginVecTable._xpdfWin32GetWindow)
309 #else
310 #define xpdfXGetWindow (*xpdfPluginVecTable._xpdfXGetWindow)
311 #endif
312 #define xpdfObjIsBool (*xpdfPluginVecTable._xpdfObjIsBool)
313 #define xpdfObjIsInt (*xpdfPluginVecTable._xpdfObjIsInt)
314 #define xpdfObjIsReal (*xpdfPluginVecTable._xpdfObjIsReal)
315 #define xpdfObjIsString (*xpdfPluginVecTable._xpdfObjIsString)
316 #define xpdfObjIsName (*xpdfPluginVecTable._xpdfObjIsName)
317 #define xpdfObjIsNull (*xpdfPluginVecTable._xpdfObjIsNull)
318 #define xpdfObjIsArray (*xpdfPluginVecTable._xpdfObjIsArray)
319 #define xpdfObjIsDict (*xpdfPluginVecTable._xpdfObjIsDict)
320 #define xpdfObjIsStream (*xpdfPluginVecTable._xpdfObjIsStream)
321 #define xpdfObjIsRef (*xpdfPluginVecTable._xpdfObjIsRef)
322 #define xpdfBoolValue (*xpdfPluginVecTable._xpdfBoolValue)
323 #define xpdfIntValue (*xpdfPluginVecTable._xpdfIntValue)
324 #define xpdfRealValue (*xpdfPluginVecTable._xpdfRealValue)
325 #define xpdfStringLength (*xpdfPluginVecTable._xpdfStringLength)
326 #define xpdfStringValue (*xpdfPluginVecTable._xpdfStringValue)
327 #define xpdfNameValue (*xpdfPluginVecTable._xpdfNameValue)
328 #define xpdfArrayLength (*xpdfPluginVecTable._xpdfArrayLength)
329 #define xpdfArrayGet (*xpdfPluginVecTable._xpdfArrayGet)
330 #define xpdfDictGet (*xpdfPluginVecTable._xpdfDictGet)
331 #define xpdfFreeObj (*xpdfPluginVecTable._xpdfFreeObj)
332 #define xpdfMalloc (*xpdfPluginVecTable._xpdfMalloc)
333 #define xpdfRealloc (*xpdfPluginVecTable._xpdfRealloc)
334 #define xpdfFree (*xpdfPluginVecTable._xpdfFree)
335 #define xpdfRegisterSecurityHandler (*xpdfPluginVecTable._xpdfRegisterSecurityHandler)
337 #ifdef __cplusplus
339 #endif
341 #endif