source: trunk/poppler/mypoppler/poppler/XpdfPluginAPI.h @ 515

Last change on this file since 515 was 515, checked in by Silvan Scherrer, 9 years ago

updated poppler to 0.20.3

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