]>
Commit | Line | Data |
---|---|---|
ef416fc2 | 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 | |
19 | extern "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 | */ | |
66 | typedef int XpdfBool; | |
67 | #define xpdfTrue 1 | |
68 | #define xpdfFalse 0 | |
69 | ||
70 | /* | |
71 | * PDF document handle. | |
72 | */ | |
73 | typedef struct _XpdfDoc *XpdfDoc; | |
74 | ||
75 | /* | |
76 | * PDF object handle. | |
77 | */ | |
78 | typedef 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 | */ | |
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) | |
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 | |
101 | struct XpdfSecurityHandler { | |
102 | #else | |
103 | typedef 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 | ||
192 | typedef 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 | */ | |
203 | XpdfObject (*_xpdfGetInfoDict)(XpdfDoc doc); | |
204 | ||
205 | /* | |
206 | * Get a document's catalog ("root") dictionary. (The returned object | |
207 | * must be freed with xpdfFreeObj.) | |
208 | */ | |
209 | XpdfObject (*_xpdfGetCatalog)(XpdfDoc doc); | |
210 | ||
211 | /*------------------------------------------------------------------------ | |
212 | * Object access functions | |
213 | *------------------------------------------------------------------------*/ | |
214 | ||
215 | /* | |
216 | * Check an object's type. | |
217 | */ | |
218 | XpdfBool (*_xpdfObjIsBool)(XpdfObject obj); | |
219 | XpdfBool (*_xpdfObjIsInt)(XpdfObject obj); | |
220 | XpdfBool (*_xpdfObjIsReal)(XpdfObject obj); | |
221 | XpdfBool (*_xpdfObjIsString)(XpdfObject obj); | |
222 | XpdfBool (*_xpdfObjIsName)(XpdfObject obj); | |
223 | XpdfBool (*_xpdfObjIsNull)(XpdfObject obj); | |
224 | XpdfBool (*_xpdfObjIsArray)(XpdfObject obj); | |
225 | XpdfBool (*_xpdfObjIsDict)(XpdfObject obj); | |
226 | XpdfBool (*_xpdfObjIsStream)(XpdfObject obj); | |
227 | XpdfBool (*_xpdfObjIsRef)(XpdfObject obj); | |
228 | ||
229 | /* | |
230 | * Value access. | |
231 | * (Objects returned by xpdfArrayGet and xpdfDictGet must be freed | |
232 | * with xpdfFreeObj.) | |
233 | */ | |
234 | XpdfBool (*_xpdfBoolValue)(XpdfObject obj); | |
235 | int (*_xpdfIntValue)(XpdfObject obj); | |
236 | double (*_xpdfRealValue)(XpdfObject obj); | |
237 | int (*_xpdfStringLength)(XpdfObject obj); | |
238 | char *(*_xpdfStringValue)(XpdfObject obj); | |
239 | char *(*_xpdfNameValue)(XpdfObject obj); | |
240 | int (*_xpdfArrayLength)(XpdfObject obj); | |
241 | XpdfObject (*_xpdfArrayGet)(XpdfObject obj, int idx); | |
242 | XpdfObject (*_xpdfDictGet)(XpdfObject obj, char *key); | |
243 | ||
244 | /* | |
245 | * Object destruction. NB: *all* objects must be freed after use. | |
246 | */ | |
247 | void (*_xpdfFreeObj)(XpdfObject obj); | |
248 | ||
249 | /*------------------------------------------------------------------------ | |
250 | * Memory allocation functions | |
251 | *------------------------------------------------------------------------*/ | |
252 | ||
253 | void *(*_xpdfMalloc)(int size); | |
254 | void *(*_xpdfRealloc)(void *p, int size); | |
255 | void (*_xpdfFree)(void *p); | |
256 | ||
257 | /*------------------------------------------------------------------------ | |
258 | * Security handler functions | |
259 | *------------------------------------------------------------------------*/ | |
260 | ||
261 | /* | |
262 | * Register a new security handler. | |
263 | */ | |
264 | void (*_xpdfRegisterSecurityHandler)(XpdfSecurityHandler *handler); | |
265 | ||
266 | /*------------------------------------------------------------------------*/ | |
267 | ||
268 | } XpdfPluginVecTable; | |
269 | ||
270 | #ifdef _WIN32 | |
271 | ||
272 | extern __declspec(dllexport) XpdfPluginVecTable xpdfPluginVecTable; | |
273 | ||
274 | #define xpdfPluginSetup \ | |
275 | extern __declspec(dllexport) \ | |
276 | XpdfPluginVecTable xpdfPluginVecTable = {xpdfPluginAPIVersion}; | |
277 | ||
278 | #else | |
279 | ||
280 | extern XpdfPluginVecTable xpdfPluginVecTable; | |
281 | ||
282 | #define xpdfPluginSetup \ | |
283 | XpdfPluginVecTable xpdfPluginVecTable = {xpdfPluginAPIVersion}; | |
284 | ||
285 | #endif | |
286 | ||
287 | #define xpdfGetInfoDict (*xpdfPluginVecTable._xpdfGetInfoDict) | |
288 | #define xpdfGetCatalog (*xpdfPluginVecTable._xpdfGetCatalog) | |
289 | #ifdef _WIN32 | |
290 | #define xpdfWin32GetWindow (*xpdfPluginVecTable._xpdfWin32GetWindow) | |
291 | #else | |
292 | #define xpdfXGetWindow (*xpdfPluginVecTable._xpdfXGetWindow) | |
293 | #endif | |
294 | #define xpdfObjIsBool (*xpdfPluginVecTable._xpdfObjIsBool) | |
295 | #define xpdfObjIsInt (*xpdfPluginVecTable._xpdfObjIsInt) | |
296 | #define xpdfObjIsReal (*xpdfPluginVecTable._xpdfObjIsReal) | |
297 | #define xpdfObjIsString (*xpdfPluginVecTable._xpdfObjIsString) | |
298 | #define xpdfObjIsName (*xpdfPluginVecTable._xpdfObjIsName) | |
299 | #define xpdfObjIsNull (*xpdfPluginVecTable._xpdfObjIsNull) | |
300 | #define xpdfObjIsArray (*xpdfPluginVecTable._xpdfObjIsArray) | |
301 | #define xpdfObjIsDict (*xpdfPluginVecTable._xpdfObjIsDict) | |
302 | #define xpdfObjIsStream (*xpdfPluginVecTable._xpdfObjIsStream) | |
303 | #define xpdfObjIsRef (*xpdfPluginVecTable._xpdfObjIsRef) | |
304 | #define xpdfBoolValue (*xpdfPluginVecTable._xpdfBoolValue) | |
305 | #define xpdfIntValue (*xpdfPluginVecTable._xpdfIntValue) | |
306 | #define xpdfRealValue (*xpdfPluginVecTable._xpdfRealValue) | |
307 | #define xpdfStringLength (*xpdfPluginVecTable._xpdfStringLength) | |
308 | #define xpdfStringValue (*xpdfPluginVecTable._xpdfStringValue) | |
309 | #define xpdfNameValue (*xpdfPluginVecTable._xpdfNameValue) | |
310 | #define xpdfArrayLength (*xpdfPluginVecTable._xpdfArrayLength) | |
311 | #define xpdfArrayGet (*xpdfPluginVecTable._xpdfArrayGet) | |
312 | #define xpdfDictGet (*xpdfPluginVecTable._xpdfDictGet) | |
313 | #define xpdfFreeObj (*xpdfPluginVecTable._xpdfFreeObj) | |
314 | #define xpdfMalloc (*xpdfPluginVecTable._xpdfMalloc) | |
315 | #define xpdfRealloc (*xpdfPluginVecTable._xpdfRealloc) | |
316 | #define xpdfFree (*xpdfPluginVecTable._xpdfFree) | |
317 | #define xpdfRegisterSecurityHandler (*xpdfPluginVecTable._xpdfRegisterSecurityHandler) | |
318 | ||
319 | #ifdef __cplusplus | |
320 | } | |
321 | #endif | |
322 | ||
323 | #endif |