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

Last change on this file since 461 was 2, checked in by Eugene Romanenko, 16 years ago

First import

File size: 9.7 KB
Line 
1/*
2 * XpdfPluginAPI.h
3 *
4 * Copyright 2004 Glyph & Cog, LLC
5 */
6
7#ifndef XPDFPLUGINAPI_H
8#define XPDFPLUGINAPI_H
9
10#ifdef _WIN32
11#include <windows.h>
12#else
13#define Object XtObject
14#include <X11/Intrinsic.h>
15#undef Object
16#endif
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22/*------------------------------------------------------------------------
23 * Macros
24 *------------------------------------------------------------------------*/
25
26/*
27 * The current API version.
28 */
29#define xpdfPluginAPIVersion 1
30
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
44
45/*------------------------------------------------------------------------
46 * Plugin setup/cleanup
47 *------------------------------------------------------------------------*/
48
49/*
50 * All plugins are required to implement two functions:
51 *
52 * -- Initialize the plugin.  Returns non-zero if successful.
53 * PLUGINFUNC(XpdfBool) xpdfInitPlugin(void);
54 *
55 * -- Free the plugin.
56 * PLUGINFUNC(void) xpdfFreePlugin(void);
57 */
58
59/*------------------------------------------------------------------------
60 * Types
61 *------------------------------------------------------------------------*/
62
63/*
64 * Standard C boolean -- zero = false, non-zero = true.
65 */
66typedef int XpdfBool;
67#define xpdfTrue  1
68#define xpdfFalse 0
69
70/*
71 * PDF document handle.
72 */
73typedef struct _XpdfDoc *XpdfDoc;
74
75/*
76 * PDF object handle.
77 */
78typedef struct _XpdfObject *XpdfObject;
79
80/*
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.
84 */
85typedef 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)
91
92/*------------------------------------------------------------------------
93 * Security handler
94 *------------------------------------------------------------------------*/
95
96/*
97 * XpdfSecurityHandler - a security handler plugin should create one
98 * of these and pass it to xpdfRegisterSecurityHandler.
99 */
100#ifdef __cplusplus
101struct XpdfSecurityHandler {
102#else
103typedef struct {
104#endif
105
106  /*
107   * Version of the security handler spec (this document) -- use
108   * xpdfPluginAPIVersion.
109   */
110  int version;
111
112  /*
113   * Security handler name.
114   */
115  char *name;
116
117  /*
118   * Any global data the security handler needs.  XpdfViewer will pass
119   * this pointer to all handler functions as the <handlerData>
120   * argument.
121   */
122  void *handlerData;
123
124  /*
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.
128   */
129  XpdfBool (*newDoc)(void *handlerData, XpdfDoc doc,
130                     XpdfObject encryptDict, void **docData);
131
132  /*
133   * Free the data allocated by newDoc.
134   */
135  void (*freeDoc)(void *handlerData, void *docData);
136
137  /*
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.
145   */
146  XpdfBool (*makeAuthData)(void *handlerData, void *docData,
147                           char *ownerPassword, char *userPassword,
148                           void **authData);
149
150  /*
151   * Request any needed information (e.g., a password) from the user,
152   * and construct an authorization data object.  Returns non-zero if
153   * successful.
154   */
155  XpdfBool (*getAuthData)(void *handlerData, void *docData,
156                          void **authData);
157
158  /*
159   * Free the data allocated by getAuthData.
160   */
161  void (*freeAuthData)(void *handlerData, void *docData,
162                       void *authData);
163
164  /*
165   * Request permission to access the document.  This returns all
166   * permissions granted by authData.
167   */
168  XpdfPermission (*authorize)(void *handlerData, void *docData,
169                              void *authData);
170
171  /*
172   * Get the decryption key and algorithm version associated with the
173   * document.  Returns non-zero if successful.
174   */
175  XpdfBool (*getKey)(void *handlerData, void *docData,
176                     char **key, int *keyLen, int *cryptVersion);
177
178  /*
179   * Free the data allocated by getKey.
180   */
181  void (*freeKey)(void *handlerData, void *docData,
182                  char *key, int keyLen);
183
184#ifdef __cplusplus
185};
186#else
187} XpdfSecurityHandler;
188#endif
189
190/*------------------------------------------------------------------------*/
191
192typedef struct {
193  int version;
194
195/*------------------------------------------------------------------------
196 * Document access functions
197 *------------------------------------------------------------------------*/
198
199/*
200 * Get a document's info dictionary.  (The returned object must be
201 * freed with xpdfFreeObj.)
202 */
203XpdfObject (*_xpdfGetInfoDict)(XpdfDoc doc);
204
205/*
206 * Get a document's catalog ("root") dictionary.  (The returned object
207 * must be freed with xpdfFreeObj.)
208 */
209XpdfObject (*_xpdfGetCatalog)(XpdfDoc doc);
210
211#ifdef _WIN32
212
213/*
214 * Get the handle for the viewer window associated with the specified
215 * document.  [Win32 only]
216 */
217HWND (*_xpdfWin32GetWindow)(XpdfDoc doc);
218
219#else
220
221/*
222 * Get the Motif widget for the viewer window associated with the
223 * specified document.  [X only]
224 */
225Widget (*_xpdfXGetWindow)(XpdfDoc doc);
226
227#endif
228
229/*------------------------------------------------------------------------
230 * Object access functions
231 *------------------------------------------------------------------------*/
232
233/*
234 * Check an object's type.
235 */
236XpdfBool (*_xpdfObjIsBool)(XpdfObject obj);
237XpdfBool (*_xpdfObjIsInt)(XpdfObject obj);
238XpdfBool (*_xpdfObjIsReal)(XpdfObject obj);
239XpdfBool (*_xpdfObjIsString)(XpdfObject obj);
240XpdfBool (*_xpdfObjIsName)(XpdfObject obj);
241XpdfBool (*_xpdfObjIsNull)(XpdfObject obj);
242XpdfBool (*_xpdfObjIsArray)(XpdfObject obj);
243XpdfBool (*_xpdfObjIsDict)(XpdfObject obj);
244XpdfBool (*_xpdfObjIsStream)(XpdfObject obj);
245XpdfBool (*_xpdfObjIsRef)(XpdfObject obj);
246
247/*
248 * Value access.
249 * (Objects returned by xpdfArrayGet and xpdfDictGet must be freed
250 * with xpdfFreeObj.)
251 */
252XpdfBool (*_xpdfBoolValue)(XpdfObject obj);
253int (*_xpdfIntValue)(XpdfObject obj);
254double (*_xpdfRealValue)(XpdfObject obj);
255int (*_xpdfStringLength)(XpdfObject obj);
256char *(*_xpdfStringValue)(XpdfObject obj);
257char *(*_xpdfNameValue)(XpdfObject obj);
258int (*_xpdfArrayLength)(XpdfObject obj);
259XpdfObject (*_xpdfArrayGet)(XpdfObject obj, int idx);
260XpdfObject (*_xpdfDictGet)(XpdfObject obj, char *key);
261
262/*
263 * Object destruction.  NB: *all* objects must be freed after use.
264 */
265void (*_xpdfFreeObj)(XpdfObject obj);
266
267/*------------------------------------------------------------------------
268 * Memory allocation functions
269 *------------------------------------------------------------------------*/
270
271void *(*_xpdfMalloc)(int size);
272void *(*_xpdfRealloc)(void *p, int size);
273void (*_xpdfFree)(void *p);
274
275/*------------------------------------------------------------------------
276 * Security handler functions
277 *------------------------------------------------------------------------*/
278
279/*
280 * Register a new security handler.
281 */
282void (*_xpdfRegisterSecurityHandler)(XpdfSecurityHandler *handler);
283
284/*------------------------------------------------------------------------*/
285
286} XpdfPluginVecTable;
287
288#ifdef _WIN32
289
290extern __declspec(dllexport) XpdfPluginVecTable xpdfPluginVecTable;
291
292#define xpdfPluginSetup \
293  extern __declspec(dllexport) \
294  XpdfPluginVecTable xpdfPluginVecTable = {xpdfPluginAPIVersion};
295
296#else
297
298extern XpdfPluginVecTable xpdfPluginVecTable;
299
300#define xpdfPluginSetup \
301  XpdfPluginVecTable xpdfPluginVecTable = {xpdfPluginAPIVersion};
302
303#endif
304
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)
336
337#ifdef __cplusplus
338}
339#endif
340
341#endif
Note: See TracBrowser for help on using the repository browser.