4 * Copyright 2004 Glyph & Cog, LLC
7 #ifndef XPDFPLUGINAPI_H
8 #define XPDFPLUGINAPI_H
13 #define xObject XtObject
14 #include <X11/Intrinsic.h>
22 /*------------------------------------------------------------------------
24 *------------------------------------------------------------------------*/
27 * The current API version.
29 #define xpdfPluginAPIVersion 1
33 # define PLUGINFUNC(retType) extern "C" __declspec(dllexport) retType
35 # define PLUGINFUNC(retType) extern __declspec(dllexport) retType
39 # define PLUGINFUNC(retType) extern "C" retType
41 # define PLUGINFUNC(retType) extern retType
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);
56 * PLUGINFUNC(void) xpdfFreePlugin(void);
59 /*------------------------------------------------------------------------
61 *------------------------------------------------------------------------*/
64 * Standard C boolean -- zero = false, non-zero = true.
71 * PDF document handle.
73 typedef struct _XpdfDoc
*XpdfDoc
;
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 /*------------------------------------------------------------------------
94 *------------------------------------------------------------------------*/
97 * XpdfSecurityHandler - a security handler plugin should create one
98 * of these and pass it to xpdfRegisterSecurityHandler.
101 struct XpdfSecurityHandler
{
107 * Version of the security handler spec (this document) -- use
108 * xpdfPluginAPIVersion.
113 * Security handler name.
118 * Any global data the security handler needs. XpdfViewer will pass
119 * this pointer to all handler functions as the <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
,
151 * Request any needed information (e.g., a password) from the user,
152 * and construct an authorization data xObject. Returns non-zero if
155 XpdfBool (*getAuthData
)(void *handlerData
, void *docData
,
159 * Free the data allocated by getAuthData.
161 void (*freeAuthData
)(void *handlerData
, void *docData
,
165 * Request permission to access the document. This returns all
166 * permissions granted by authData.
168 XpdfPermission (*authorize
)(void *handlerData
, void *docData
,
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
);
187 } XpdfSecurityHandler
;
190 /*------------------------------------------------------------------------*/
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
);
214 * Get the handle for the viewer window associated with the specified
215 * document. [Win32 only]
217 HWND (*_xpdfWin32GetWindow
)(XpdfDoc doc
);
222 * Get the Motif widget for the viewer window associated with the
223 * specified document. [X only]
225 Widget (*_xpdfXGetWindow
)(XpdfDoc doc
);
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
);
249 * (xObjects returned by xpdfArrayGet and xpdfDictGet must be freed
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
;
290 extern __declspec(dllexport
) XpdfPluginVecTable xpdfPluginVecTable
;
292 #define xpdfPluginSetup \
293 extern __declspec(dllexport) \
294 XpdfPluginVecTable xpdfPluginVecTable = {xpdfPluginAPIVersion};
298 extern XpdfPluginVecTable xpdfPluginVecTable
;
300 #define xpdfPluginSetup \
301 XpdfPluginVecTable xpdfPluginVecTable = {xpdfPluginAPIVersion};
305 #define xpdfGetInfoDict (*xpdfPluginVecTable._xpdfGetInfoDict)
306 #define xpdfGetCatalog (*xpdfPluginVecTable._xpdfGetCatalog)
308 #define xpdfWin32GetWindow (*xpdfPluginVecTable._xpdfWin32GetWindow)
310 #define xpdfXGetWindow (*xpdfPluginVecTable._xpdfXGetWindow)
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)