beta-0.89.2
[luatex.git] / source / libs / poppler / poppler-src / poppler / XpdfPluginAPI.h
blob6ed890a8f1fee72552924d0272d732dca0eb7aa0
1 /*
2 * XpdfPluginAPI.h
4 * Copyright 2004 Glyph & Cog, LLC
5 */
7 //========================================================================
8 //
9 // Modified under the Poppler project - http://poppler.freedesktop.org
11 // All changes made under the Poppler project to this file are licensed
12 // under GPL version 2 or later
14 // Copyright (C) 2012 Albert Astals Cid <aacid@kde.org>
15 // Copyright (C) 2014 Bogdan Cristea <cristeab@gmail.com>
16 // Copyright (C) 2014 Peter Breitenlohner <peb@mppmu.mpg.de>
18 // To see a description of the changes please see the Changelog file that
19 // came with your tarball or type make ChangeLog if you are building from git
21 //========================================================================
23 #ifndef XPDFPLUGINAPI_H
24 #define XPDFPLUGINAPI_H
26 #ifdef _WIN32
27 #ifndef NOMINMAX
28 #define NOMINMAX
29 #endif
30 #include <windows.h>
31 #else
32 #define Object XtObject
33 #include <X11/Intrinsic.h>
34 #undef Object
35 #endif
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
41 /*------------------------------------------------------------------------
42 * Macros
43 *------------------------------------------------------------------------*/
46 * The current API version.
48 #define xpdfPluginAPIVersion 1
50 #ifdef _WIN32
51 # ifdef __cplusplus
52 # define PLUGINFUNC(retType) extern "C" __declspec(dllexport) retType
53 # else
54 # define PLUGINFUNC(retType) extern __declspec(dllexport) retType
55 # endif
56 #else
57 # ifdef __cplusplus
58 # define PLUGINFUNC(retType) extern "C" retType
59 # else
60 # define PLUGINFUNC(retType) extern retType
61 # endif
62 #endif
64 /*------------------------------------------------------------------------
65 * Plugin setup/cleanup
66 *------------------------------------------------------------------------*/
69 * All plugins are required to implement two functions:
71 * -- Initialize the plugin. Returns non-zero if successful.
72 * PLUGINFUNC(XpdfBool) xpdfInitPlugin(void);
74 * -- Free the plugin.
75 * PLUGINFUNC(void) xpdfFreePlugin(void);
78 /*------------------------------------------------------------------------
79 * Types
80 *------------------------------------------------------------------------*/
83 * Standard C boolean -- zero = false, non-zero = true.
85 typedef int XpdfBool;
86 #define xpdfTrue 1
87 #define xpdfFalse 0
90 * PDF document handle.
92 typedef struct _XpdfDoc *XpdfDoc;
95 * PDF object handle.
97 typedef struct _XpdfObject *XpdfObject;
100 * Document access permissions. Any of these can be bitwise 'or'ed
101 * together. If xpdfPermissionOpen is not included, the document
102 * cannot be opened at all, and the other bits are ignored.
104 typedef unsigned int XpdfPermission;
105 #define xpdfPermissionOpen (1 << 0)
106 #define xpdfPermissionPrint (1 << 2)
107 #define xpdfPermissionChange (1 << 3)
108 #define xpdfPermissionCopy (1 << 4)
109 #define xpdfPermissionNotes (1 << 5)
111 /*------------------------------------------------------------------------
112 * Security handler
113 *------------------------------------------------------------------------*/
116 * XpdfSecurityHandler - a security handler plugin should create one
117 * of these and pass it to xpdfRegisterSecurityHandler.
119 #ifdef __cplusplus
120 struct XpdfSecurityHandler {
121 #else
122 typedef struct {
123 #endif
126 * Version of the security handler spec (this document) -- use
127 * xpdfPluginAPIVersion.
129 int version;
132 * Security handler name.
134 char *name;
137 * Any global data the security handler needs. XpdfViewer will pass
138 * this pointer to all handler functions as the <handlerData>
139 * argument.
141 void *handlerData;
144 * Allocate and initialize data for a new document. XpdfViewer will
145 * pass the returned pointer to all other handler functions as the
146 * <docData> argument. Returns non-zero if successful.
148 XpdfBool (*newDoc)(void *handlerData, XpdfDoc doc,
149 XpdfObject encryptDict, void **docData);
152 * Free the data allocated by newDoc.
154 void (*freeDoc)(void *handlerData, void *docData);
157 * Construct authorization data based on the supplied owner and user
158 * passwords (either or both of which may be NULL). This function
159 * is called in "batch" mode, i.e., if the password was supplied on
160 * the command line or via an Xpdf library API. It should not
161 * generate any user interaction (e.g., a password dialog). It is
162 * not required to support this function: the makeAuthData function
163 * pointer can be set to NULL. Returns non-zero if successful.
165 XpdfBool (*makeAuthData)(void *handlerData, void *docData,
166 char *ownerPassword, char *userPassword,
167 void **authData);
170 * Request any needed information (e.g., a password) from the user,
171 * and construct an authorization data object. Returns non-zero if
172 * successful.
174 XpdfBool (*getAuthData)(void *handlerData, void *docData,
175 void **authData);
178 * Free the data allocated by getAuthData.
180 void (*freeAuthData)(void *handlerData, void *docData,
181 void *authData);
184 * Request permission to access the document. This returns all
185 * permissions granted by authData.
187 XpdfPermission (*authorize)(void *handlerData, void *docData,
188 void *authData);
191 * Get the decryption key and algorithm version associated with the
192 * document. Returns non-zero if successful.
194 XpdfBool (*getKey)(void *handlerData, void *docData,
195 char **key, int *keyLen, int *cryptVersion, int *cryptRevision);
198 * Free the data allocated by getKey.
200 void (*freeKey)(void *handlerData, void *docData,
201 char *key, int keyLen);
203 #ifdef __cplusplus
205 #else
206 } XpdfSecurityHandler;
207 #endif
209 /*------------------------------------------------------------------------*/
211 typedef struct {
212 int version;
214 /*------------------------------------------------------------------------
215 * Document access functions
216 *------------------------------------------------------------------------*/
219 * Get a document's info dictionary. (The returned object must be
220 * freed with xpdfFreeObj.)
222 XpdfObject (*_xpdfGetInfoDict)(XpdfDoc doc);
225 * Get a document's catalog ("root") dictionary. (The returned object
226 * must be freed with xpdfFreeObj.)
228 XpdfObject (*_xpdfGetCatalog)(XpdfDoc doc);
230 /*------------------------------------------------------------------------
231 * Object access functions
232 *------------------------------------------------------------------------*/
235 * Check an object's type.
237 XpdfBool (*_xpdfObjIsBool)(XpdfObject obj);
238 XpdfBool (*_xpdfObjIsInt)(XpdfObject obj);
239 XpdfBool (*_xpdfObjIsReal)(XpdfObject obj);
240 XpdfBool (*_xpdfObjIsString)(XpdfObject obj);
241 XpdfBool (*_xpdfObjIsName)(XpdfObject obj);
242 XpdfBool (*_xpdfObjIsNull)(XpdfObject obj);
243 XpdfBool (*_xpdfObjIsArray)(XpdfObject obj);
244 XpdfBool (*_xpdfObjIsDict)(XpdfObject obj);
245 XpdfBool (*_xpdfObjIsStream)(XpdfObject obj);
246 XpdfBool (*_xpdfObjIsRef)(XpdfObject obj);
249 * Value access.
250 * (Objects returned by xpdfArrayGet and xpdfDictGet must be freed
251 * with xpdfFreeObj.)
253 XpdfBool (*_xpdfBoolValue)(XpdfObject obj);
254 int (*_xpdfIntValue)(XpdfObject obj);
255 double (*_xpdfRealValue)(XpdfObject obj);
256 int (*_xpdfStringLength)(XpdfObject obj);
257 char *(*_xpdfStringValue)(XpdfObject obj);
258 char *(*_xpdfNameValue)(XpdfObject obj);
259 int (*_xpdfArrayLength)(XpdfObject obj);
260 XpdfObject (*_xpdfArrayGet)(XpdfObject obj, int idx);
261 XpdfObject (*_xpdfDictGet)(XpdfObject obj, char *key);
264 * Object destruction. NB: *all* objects must be freed after use.
266 void (*_xpdfFreeObj)(XpdfObject obj);
268 /*------------------------------------------------------------------------
269 * Memory allocation functions
270 *------------------------------------------------------------------------*/
272 void *(*_xpdfMalloc)(int size);
273 void *(*_xpdfRealloc)(void *p, int size);
274 void (*_xpdfFree)(void *p);
276 /*------------------------------------------------------------------------
277 * Security handler functions
278 *------------------------------------------------------------------------*/
281 * Register a new security handler.
283 void (*_xpdfRegisterSecurityHandler)(XpdfSecurityHandler *handler);
285 /*------------------------------------------------------------------------*/
287 } XpdfPluginVecTable;
289 #ifdef _WIN32
291 extern __declspec(dllexport) XpdfPluginVecTable xpdfPluginVecTable;
293 #define xpdfPluginSetup \
294 extern __declspec(dllexport) \
295 XpdfPluginVecTable xpdfPluginVecTable = {xpdfPluginAPIVersion};
297 #else
299 extern XpdfPluginVecTable xpdfPluginVecTable;
301 #define xpdfPluginSetup \
302 XpdfPluginVecTable xpdfPluginVecTable = {xpdfPluginAPIVersion};
304 #endif
306 #define xpdfGetInfoDict (*xpdfPluginVecTable._xpdfGetInfoDict)
307 #define xpdfGetCatalog (*xpdfPluginVecTable._xpdfGetCatalog)
308 #ifdef _WIN32
309 #define xpdfWin32GetWindow (*xpdfPluginVecTable._xpdfWin32GetWindow)
310 #else
311 #define xpdfXGetWindow (*xpdfPluginVecTable._xpdfXGetWindow)
312 #endif
313 #define xpdfObjIsBool (*xpdfPluginVecTable._xpdfObjIsBool)
314 #define xpdfObjIsInt (*xpdfPluginVecTable._xpdfObjIsInt)
315 #define xpdfObjIsReal (*xpdfPluginVecTable._xpdfObjIsReal)
316 #define xpdfObjIsString (*xpdfPluginVecTable._xpdfObjIsString)
317 #define xpdfObjIsName (*xpdfPluginVecTable._xpdfObjIsName)
318 #define xpdfObjIsNull (*xpdfPluginVecTable._xpdfObjIsNull)
319 #define xpdfObjIsArray (*xpdfPluginVecTable._xpdfObjIsArray)
320 #define xpdfObjIsDict (*xpdfPluginVecTable._xpdfObjIsDict)
321 #define xpdfObjIsStream (*xpdfPluginVecTable._xpdfObjIsStream)
322 #define xpdfObjIsRef (*xpdfPluginVecTable._xpdfObjIsRef)
323 #define xpdfBoolValue (*xpdfPluginVecTable._xpdfBoolValue)
324 #define xpdfIntValue (*xpdfPluginVecTable._xpdfIntValue)
325 #define xpdfRealValue (*xpdfPluginVecTable._xpdfRealValue)
326 #define xpdfStringLength (*xpdfPluginVecTable._xpdfStringLength)
327 #define xpdfStringValue (*xpdfPluginVecTable._xpdfStringValue)
328 #define xpdfNameValue (*xpdfPluginVecTable._xpdfNameValue)
329 #define xpdfArrayLength (*xpdfPluginVecTable._xpdfArrayLength)
330 #define xpdfArrayGet (*xpdfPluginVecTable._xpdfArrayGet)
331 #define xpdfDictGet (*xpdfPluginVecTable._xpdfDictGet)
332 #define xpdfFreeObj (*xpdfPluginVecTable._xpdfFreeObj)
333 #define xpdfMalloc (*xpdfPluginVecTable._xpdfMalloc)
334 #define xpdfRealloc (*xpdfPluginVecTable._xpdfRealloc)
335 #define xpdfFree (*xpdfPluginVecTable._xpdfFree)
336 #define xpdfRegisterSecurityHandler (*xpdfPluginVecTable._xpdfRegisterSecurityHandler)
338 #ifdef __cplusplus
340 #endif
342 #endif