Pajdeg  0.2.2
Pajdeg
PDDefines.h
Go to the documentation of this file.
1 //
2 // PDDefines.h
3 //
4 // Copyright (c) 2012 - 2015 Karl-Johan Alm (http://github.com/kallewoof)
5 //
6 // Permission is hereby granted, free of charge, to any person obtaining a copy
7 // of this software and associated documentation files (the "Software"), to deal
8 // in the Software without restriction, including without limitation the rights
9 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 // copies of the Software, and to permit persons to whom the Software is
11 // furnished to do so, subject to the following conditions:
12 //
13 // The above copyright notice and this permission notice shall be included in
14 // all copies or substantial portions of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 // THE SOFTWARE.
23 //
24 
30 #ifndef INCLUDED_PDDefines_h
31 #define INCLUDED_PDDefines_h
32 
33 #include <sys/types.h>
34 
38 #define PD_SUPPORT_ZLIB
39 
43 #define PD_SUPPORT_CRYPTO
44 
53 // #define DEBUG
54 
61 #define PD_WARNINGS
62 
69 //#define PD_NOTICES
70 
77 #define PD_ASSERTS
78 
85 //#define PD_DEBUG_TWINSTREAM_ASSERT_OBJECTS
86 
93 //#define DEBUG_PARSER_PRINT_XREFS
94 
101 //#define DEBUG_PARSER_CHECK_XREFS
102 
107 //#define DEBUG_SCANNER_SYMBOLS
108 
115 #define DEBUG_PDTYPES
116 
123 //#define DEBUG_PD_RELEASES
124 
131 //#define DEBUG_PD_STRINGS
132 
133 
142 //#define DEBUG_PD_LEAKS
143 
144 /*
145  This forces DEBUG_PD_RELEASES to be enabled if DEBUG_PD_LEAKS is set.
146  */
147 #if defined(DEBUG_PD_LEAKS) && !defined(DEBUG_PD_RELEASES)
148 # warning Forcing DEBUG_PD_RELEASES as DEBUG_PD_LEAKS is set.
149 # define DEBUG_PD_RELEASES
150 #endif
151 
155 #ifndef __deprecated
156 # warning __deprecated macro was not defined; consider including <sys/cdefs.h>
157 # define __deprecated
158 #endif
159 
170 #define PD_DEPRECATED(introduce_version, deprecate_version) __deprecated
171 
184 typedef long PDInteger;
185 
189 #define PDIntegerFromString atol
190 
194 typedef float PDReal;
195 
199 #define PDRealFromString atof
200 
204 #ifdef bool
205 typedef bool PDBool;
206 #else
207 typedef unsigned char PDBool;
208 #endif
209 
213 typedef size_t PDSize;
214 
218 #define PDSizeFromString atol
219 
223 typedef long long PDOffset;
224 
228 #define PDOffsetFromString atoll
229 
233 typedef struct PDPoint PDPoint;
234 struct PDPoint {
235  PDReal x, y;
236 };
237 
241 typedef struct PDRect PDRect;
242 struct PDRect {
243  PDPoint a, b;
244 };
245 
252 #define PDRectFromOSRect(osr) (PDRect) {{osr.origin.x, osr.origin.y}, {osr.origin.x+osr.size.width, osr.origin.y+osr.size.height}}
253 
260 #define PDRectToOSRect(rect) {{rect.a.x, rect.a.y}, {rect.b.x-rect.a.x, rect.b.y-rect.a.y}}
261 
265 //#define PDRectReadFromArrayString(rect, str) sscanf(str, "[%f %f %f %f]", &rect.a.x, &rect.a.y, &rect.b.x, &rect.b.y)
266 
270 //#define PDRectWriteToArrayString(rect, str) sprintf(str, "[%f %f %f %f]", rect.a.x, rect.a.y, rect.b.x, rect.b.y)
271 
284 typedef const char **PDID;
285 
299 typedef void (*PDDeallocator)(void *ob);
300 
304 extern void PDNOP(void*);
305 
311 typedef void (*PDSynchronizer)(void *parser, void *object, const void *syncInfo);
312 
318 typedef union PDType *PDTypeRef;
319 
335 typedef struct pd_stack *pd_stack;
336 
344 typedef struct PDArray *PDArrayRef;
345 
355 typedef void (*PDHashIterator)(char *key, void *value, void *userInfo, PDBool *shouldStop);
356 
365 
374 
384 
393 typedef struct PDFont *PDFontRef;
394 
403 typedef struct PDCMap *PDCMapRef;
404 
408 typedef enum {
409  pd_crypto_method_none = 0,
410  pd_crypto_method_rc4 = 1,
411  pd_crypto_method_aesv2 = 2,
413 
417 typedef enum {
418  pd_auth_event_none = 0,
419  pd_auth_event_docopen = 1,
420 } pd_auth_event;
421 
431 typedef struct pd_crypto *pd_crypto;
432 
441 
447 typedef struct PDSplayTree *PDSplayTreeRef;
448 
466 struct PDSelection {
467  PDInteger page;
468  PDRect position;
469  const char *text;
470 };
471 
477 typedef struct PDSelection *PDSelectionRef;
478 
486 typedef PDBool (*PDTextSearchOperatorFunc)(PDSelectionRef selection);
487 
493 typedef struct PDObject *PDObjectRef;
494 
500 typedef struct PDPage *PDPageRef;
501 
510 
517 
524 
532 typedef enum {
538 
550 typedef PDOperatorState (*PDContentOperatorFunc)(PDContentStreamRef cs, void *userInfo, PDArrayRef args, pd_stack inState, pd_stack *outState);
551 
557 typedef enum {
567  PDInstanceTypeParser = 7,
568  PDInstanceTypePipe = 8,
569  PDInstanceTypeScanner = 9,
572  PDInstanceTypeOperator = 12,
573  PDInstanceTypePage = 13,
574  PDInstanceTypeParserAtt = 14,
579  PDInstanceType2Stream = 19,
587  //
588  PDInstanceType__SIZE = 27,
590 
596 typedef PDInteger (*PDInstancePrinter)(void *inst, char **buf, PDInteger offs, PDInteger *cap);
597 
602 
611 typedef enum {
624 } PDObjectType;
625 
631 typedef enum {
635 } PDObjectClass;
636 
642 typedef struct PDReference *PDReferenceRef;
643 
649 typedef enum {
654 } PDStringType;
655 
656 typedef enum {
675 
679 
680 extern const char *PDStringEncodingToIconvName(PDStringEncoding enc);
681 
687 typedef struct PDNumber *PDNumberRef;
688 
694 typedef struct PDString *PDStringRef;
695 
707 typedef struct PDPipe *PDPipeRef;
708 
714 typedef struct PDTask *PDTaskRef;
715 
723 typedef enum {
731 
733 } PDFType;
734 
738 #define kPDFTypeStrings \
739  NULL, "/Page", "/Pages", "/Catalog", "/Annot", "/Font", "/FontDescriptor", "/Action"
740 
746 typedef enum {
753 
766 typedef enum {
771 } PDTaskResult;
772 
778 typedef PDTaskResult (*PDTaskFunc)(PDPipeRef pipe, PDTaskRef task, PDObjectRef object, void *info);
779 
785 typedef struct PDParser *PDParserRef;
786 
792 typedef struct PDCatalog *PDCatalogRef;
793 
802 
812 typedef enum {
817 
825 typedef enum {
835 
842 
858 typedef struct PDEnv *PDEnvRef;
859 
869 typedef struct PDState *PDStateRef;
870 
876 typedef struct PDOperator *PDOperatorRef;
877 
887 typedef enum {
895  //PDOperatorAppendResult, ///< Appends current symbol to last result on stack
896  //PDOperatorPushContent, ///< Pushes everything from the point where the state was entered to current offset to results
907  // debugging
910 
916 typedef struct PDScanner *PDScannerRef;
917 
925 typedef void(*PDScannerBufFunc)(void *info, PDScannerRef scanner, char **buf, PDInteger *size, PDInteger req);
926 
936 typedef void(*PDScannerPopFunc)(PDScannerRef scanner);
937 
940 #include "PDType.h"
941 
942 #endif
Definition: PDDefines.h:234
Definition: PDDefines.h:242
float PDReal
Definition: PDDefines.h:194
PDStreamFilter.
Definition: PDDefines.h:577
PDTaskResult(* PDTaskFunc)(PDPipeRef pipe, PDTaskRef task, PDObjectRef object, void *info)
Definition: PDDefines.h:778
font descriptor objects
Definition: PDDefines.h:729
struct PDDictionary * PDDictionaryRef
Definition: PDDefines.h:364
pd_auth_event
Definition: PDDefines.h:417
SHIFT-JIS.
Definition: PDDefines.h:665
Break (presuming breakpoint is properly placed)
Definition: PDDefines.h:908
Pushes the top value on the stack onto the symbols stack as if it were never read.
Definition: PDDefines.h:901
PDOperatorState
Definition: PDDefines.h:532
enum item count
Definition: PDDefines.h:732
PDXTable.
Definition: PDDefines.h:580
void(* PDScannerBufFunc)(void *info, PDScannerRef scanner, char **buf, PDInteger *size, PDInteger req)
Definition: PDDefines.h:925
value = page number
Definition: PDDefines.h:751
An object inside of an object stream.
Definition: PDDefines.h:633
Windows CP-1252.
Definition: PDDefines.h:669
Read to end of line.
Definition: PDDefines.h:902
long PDInteger
Definition: PDDefines.h:184
–marker–
Definition: PDDefines.h:674
ISO-2022-JP.
Definition: PDDefines.h:673
the entire pipe operation is terminated and the destination file is left unfinished ...
Definition: PDDefines.h:767
long long PDOffset
Definition: PDDefines.h:223
unsigned char PDBool
Definition: PDDefines.h:207
Pops entry off of results stack and stores as an attribute of a future complex result.
Definition: PDDefines.h:891
A string.
Definition: PDDefines.h:618
this operator does not push nor pop the stack
Definition: PDDefines.h:533
PDSplayTree.
Definition: PDDefines.h:575
Definition: PDStreamFilter.h:121
struct PDOperator * PDOperatorRef
Definition: PDDefines.h:876
struct PDTwinStream * PDTwinStreamRef
Definition: PDDefines.h:801
struct PDString * PDStringRef
Definition: PDDefines.h:694
this operator performs a seek operation on the stream; the latest argument in the arg stack is a PDNu...
Definition: PDDefines.h:536
Definition: PDParserAttachment.c:42
const char ** PDID
Definition: PDDefines.h:284
Windows CP-1254.
Definition: PDDefines.h:671
A boolean.
Definition: PDDefines.h:614
PDArrayRef args
pending operator arguments
Definition: pd_internal.h:308
An array.
Definition: PDDefines.h:619
union PDType * PDTypeRef
Definition: PDDefines.h:318
struct PDArray * PDArrayRef
Definition: PDDefines.h:344
value = object ID; only called for the live object, even if multiple copies exist ...
Definition: PDDefines.h:747
Pops entry off of results stack and stores in variable stack, without including a variable name...
Definition: PDDefines.h:892
struct PDReference * PDReferenceRef
Definition: PDDefines.h:642
struct PDSplayTree * PDSplayTreeRef
Definition: PDDefines.h:447
random access, jumping to positions in the input, not writing anything to output
Definition: PDDefines.h:814
A reference to another object.
Definition: PDDefines.h:622
Windows CP-1250.
Definition: PDDefines.h:672
struct pd_stack * pd_stack
Definition: PDDefines.h:335
PDBool(* PDTextSearchOperatorFunc)(PDSelectionRef selection)
Definition: PDDefines.h:486
triggered for each object of the given PDFType value
Definition: PDDefines.h:750
void * info
The (user) info object.
Definition: pd_internal.h:797
A size (not in CGPDFObject type)
Definition: PDDefines.h:623
void(* PDScannerPopFunc)(PDScannerRef scanner)
Definition: PDDefines.h:936
this operator pops the stack
Definition: PDDefines.h:535
Pushes an empty string onto the results stack.
Definition: PDDefines.h:893
PDInstanceType
Definition: PDDefines.h:557
Read over symbols and whitespace until a delimiter is encountered.
Definition: PDDefines.h:903
action objects; usually associated with a link annotation
Definition: PDDefines.h:730
PDState.
Definition: PDDefines.h:576
An integer.
Definition: PDDefines.h:615
Takes build stack as is, and stores it as if it was a popped variable.
Definition: PDDefines.h:899
EUC-JP.
Definition: PDDefines.h:664
triggered when info object is encountered
Definition: PDDefines.h:749
Mark current position in buffer for popping as is into results later.
Definition: PDDefines.h:904
Windows CP-1251.
Definition: PDDefines.h:668
struct PDContentStream * PDContentStreamRef
Definition: PDDefines.h:523
this operator pushes onto the stack
Definition: PDDefines.h:534
PostScript executable code.
Definition: PDDefines.h:585
PDDictionaryStack.
Definition: PDDefines.h:586
PDString.
Definition: PDDefines.h:562
Identical to above, but does not 'retain' the target state, to prevent retain cycles (e...
Definition: PDDefines.h:889
PDObjectClass
Definition: PDDefines.h:631
Content stream operator.
Definition: PDDefines.h:581
struct PDObject * PDObjectRef
Definition: PDDefines.h:493
PDOperatorType
Definition: PDDefines.h:887
the task ended, and requires that remaining tasks in its pipeline are skipped
Definition: PDDefines.h:769
all catalog objects; normally, the Root object is the only catalog in a PDF
Definition: PDDefines.h:726
PDPredictorType
Definition: PDDefines.h:825
The type of the object has not (yet) been determined.
Definition: PDDefines.h:613
Definition: pd_internal.h:190
struct PDEnv * PDEnvRef
Definition: PDDefines.h:858
pd_crypto_method
Definition: PDDefines.h:408
The encoding used was not determined correctly. The string may be a binary value or similar...
Definition: PDDefines.h:677
A trailer.
Definition: PDDefines.h:634
PDPropertyType
Definition: PDDefines.h:746
A HEX string, NUL-terminated.
Definition: PDDefines.h:651
PDObject.
Definition: PDDefines.h:566
void PDNOP(void *)
Definition: PDType.c:454
Pushes object of type description "key" with variables (if any) as attributes onto results stack...
Definition: PDDefines.h:897
struct PDTask * PDTaskRef
Definition: PDDefines.h:714
font objects
Definition: PDDefines.h:728
all annotation objects, such as links
Definition: PDDefines.h:727
PDTaskResult
Definition: PDDefines.h:766
Definition: pd_internal.h:306
A real (internally represented as a float).
Definition: PDDefines.h:616
PDCMap.
Definition: PDDefines.h:584
size_t PDSize
Definition: PDDefines.h:213
struct PDState * PDStateRef
Definition: PDDefines.h:869
PDStringEncoding
Definition: PDDefines.h:656
Definition: PDDefines.h:466
PDInstancePrinter PDInstancePrinters[]
Definition: pd_pdf_implementation.c:943
struct PDParser * PDParserRef
Definition: PDDefines.h:785
no prediction (default)
Definition: PDDefines.h:826
PDFontDictionary.
Definition: PDDefines.h:582
ISO-8859-2 (latin2)
Definition: PDDefines.h:667
A binary string, which may or may not be NUL-terminated, and may contain any character.
Definition: PDDefines.h:652
struct PDPipe * PDPipeRef
Definition: PDDefines.h:707
PDInteger(* PDInstancePrinter)(void *inst, char **buf, PDInteger offs, PDInteger *cap)
Definition: PDDefines.h:596
reads and writes from start to end of input into output, skipping/replacing/inserting as appropriate ...
Definition: PDDefines.h:813
PDTask.
Definition: PDDefines.h:578
triggered when root object is encountered
Definition: PDDefines.h:748
A dictionary. Most objects are considered dictionaries.
Definition: PDDefines.h:620
Pushes current symbol onto results stack.
Definition: PDDefines.h:894
all page objects
Definition: PDDefines.h:724
struct pd_crypto * pd_crypto
Definition: PDDefines.h:431
PNG prediction (on encoding, PNG Up on all rows)
Definition: PDDefines.h:830
struct PDStreamFilter * PDStreamFilterRef
Definition: PDDefines.h:841
PDObjectType
Definition: PDDefines.h:611
struct PDPage * PDPageRef
Definition: PDDefines.h:500
struct PDCatalog * PDCatalogRef
Definition: PDDefines.h:792
PDFont.
Definition: PDDefines.h:583
A regular object in a PDF.
Definition: PDDefines.h:632
UTF-32 encoding.
Definition: PDDefines.h:662
PNG prediction (on encoding, PNG Sub on all rows)
Definition: PDDefines.h:829
PDNumber.
Definition: PDDefines.h:561
Definition: PDSplayTree.c:20
void(* PDSynchronizer)(void *parser, void *object, const void *syncInfo)
Definition: PDDefines.h:311
PNG prediction (on encoding, PNG Paeth on all rows)
Definition: PDDefines.h:832
reads from the end of the input file, filling the heap from the end up towards the beginning ...
Definition: PDDefines.h:815
Definition: pd_internal.h:718
Definition: pd_internal.h:544
Definition: pd_internal.h:611
Definition: pd_internal.h:468
Definition: pd_internal.h:688
Definition: pd_internal.h:639
Definition: pd_internal.h:656
Definition: pd_internal.h:343
struct PDCMap * PDCMapRef
Definition: PDDefines.h:403
Definition: pd_internal.h:672
Definition: pd_internal.h:663
Definition: pd_internal.h:869
Definition: pd_internal.h:249
Definition: pd_internal.h:374
Definition: pd_internal.h:408
Definition: pd_internal.h:829
Definition: pd_internal.h:857
Definition: pd_internal.h:507
Definition: pd_internal.h:753
Definition: pd_internal.h:773
Definition: pd_internal.h:887
Definition: pd_internal.h:789
Definition: pd_internal.h:805
Pops back to previous state.
Definition: PDDefines.h:890
UTF-16 encoding (little endian)
Definition: PDDefines.h:661
Definition: pd_internal.h:326
PDStringType
Definition: PDDefines.h:649
struct PDSelection * PDSelectionRef
Definition: PDDefines.h:477
PNG prediction (on encoding, PNG None on all rows)
Definition: PDDefines.h:828
This is most likely ASCII or UTF-8, but implicit checks are made where necessary. ...
Definition: PDDefines.h:657
the task ended as normal; additionally, it should never be called again
Definition: PDDefines.h:770
struct PDDictionaryStack * PDDictionaryStackRef
Definition: PDDefines.h:373
struct PDParserAttachment * PDParserAttachmentRef
Definition: PDDefines.h:509
Pushes the scanned symbol back onto the symbols stack, so that it is re-read the next time a symbol i...
Definition: PDDefines.h:900
A name. Names in PDFs are things that begin with a slash, e.g. /Info.
Definition: PDDefines.h:617
NULL.
Definition: PDDefines.h:560
UTF-16 encoding (big endian)
Definition: PDDefines.h:660
PDFType
Definition: PDDefines.h:723
Windows CP-1253.
Definition: PDDefines.h:670
8-bit regular ascii encoding (this is probably 7-bit, actually)
Definition: PDDefines.h:658
The encoding has a custom mapping in an associated font object.
Definition: PDDefines.h:676
UTF-8 encoding.
Definition: PDDefines.h:659
PDOperatorState(* PDContentOperatorFunc)(PDContentStreamRef cs, void *userInfo, PDArrayRef args, pd_stack inState, pd_stack *outState)
Definition: PDDefines.h:550
PDReference.
Definition: PDDefines.h:565
Pushes another state; e.g. "<" pushes dict_hex, which on seeing "<" pushes "dict".
Definition: PDDefines.h:888
struct PDNumber * PDNumberRef
Definition: PDDefines.h:687
A stream.
Definition: PDDefines.h:621
PNG prediction (on encoding, PNG Paeth on all rows)
Definition: PDDefines.h:833
struct PDObjectStream * PDObjectStreamRef
Definition: PDDefines.h:516
struct PDFont * PDFontRef
Definition: PDDefines.h:393
void(* PDHashIterator)(char *key, void *value, void *userInfo, PDBool *shouldStop)
Definition: PDDefines.h:355
PDObjectStream.
Definition: PDDefines.h:571
Null object, often used to indicate the type of a dictionary entry for a key that it doesn't contain...
Definition: PDDefines.h:612
The associated instance value has not been set yet.
Definition: PDDefines.h:558
TIFF predictor 2.
Definition: PDDefines.h:827
Push everything from mark to current position in buffer as results.
Definition: PDDefines.h:905
the task ended as normal
Definition: PDDefines.h:768
struct PDScanner * PDScannerRef
Definition: PDDefines.h:916
Undefined / non-allocated instance.
Definition: PDDefines.h:559
A regular string, escaped and NUL-terminated.
Definition: PDDefines.h:650
PDArray.
Definition: PDDefines.h:563
ISO-8859-1 (latin1)
Definition: PDDefines.h:666
struct PDFontDictionary * PDFontDictionaryRef
Definition: PDDefines.h:383
A regular string prefixed with a forward slash.
Definition: PDDefines.h:653
PDTwinStreamMethod
Definition: PDDefines.h:812
all pages objects; pages objects are dictionaries with arrays of page objects (the "Kids") ...
Definition: PDDefines.h:725
PDContentStream.
Definition: PDDefines.h:570
Pushes a complex onto build stack rather than results stack (for popping as a chunk of objects later)...
Definition: PDDefines.h:898
Mac Roman encoding.
Definition: PDDefines.h:663
char * buf
buffer
Definition: pd_internal.h:520
PDDictionary.
Definition: PDDefines.h:564
Do nothing.
Definition: PDDefines.h:906
struct PDStaticHash * PDStaticHashRef
Definition: PDDefines.h:440
void(* PDDeallocator)(void *ob)
Definition: PDDefines.h:299
PNG prediction (on encoding, PNG Average on all rows)
Definition: PDDefines.h:831