Pajdeg  0.2.2
Pajdeg
pd_internal.h
Go to the documentation of this file.
1 //
2 // pd_internal.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 
36 #ifndef INCLUDED_pd_internal_h
37 #define INCLUDED_pd_internal_h
38 
39 #include <stdio.h>
40 #include <stdlib.h>
41 #include <string.h>
42 
43 #include "PDDefines.h"
44 #include "PDOperator.h"
45 
53 #ifndef true
54 #define true 1
55 #endif
56 #ifndef false
57 #define false 0
58 #endif
59 
61 
71 extern PDObjectRef PDObjectCreate(PDInteger obid, PDInteger genid);
72 
74 
78 #ifdef DEBUG_PDTYPES
79 #define PDTYPE_PTR_LEN 4
80 #else
81 #define PDTYPE_PTR_LEN 3
82 #endif
83 
95 union PDType {
96  struct {
97 #ifdef DEBUG_PDTYPES
98  char *pdc; // Pajdeg signature
99 #endif
100  PDInstanceType it; // Instance type, if any.
101  PDInteger retainCount; // Retain count. If the retain count of an object hits zero, the object is disposed of.
102  PDDeallocator dealloc; // Deallocation method.
103  };
104  void *align[PDTYPE_PTR_LEN]; // Force-align.
105 };
106 
116 #define PDAlloc(s,d,z) PDAllocTyped(PDInstanceTypeUnset,s,d,z)
117 
118 #ifdef DEBUG_PD_RELEASES
119 #define PDAllocTyped(it,s,d,z) _PDAllocTypedDebug(__FILE__,__LINE__,it,s,d,z)
120 extern void *_PDFocusObject;
121 extern void *_PDAllocTypedDebug(const char *file, int lineNumber, PDInstanceType it, PDSize size, void *dealloc, PDBool zeroed);
122 #else
123 
131 extern void *PDAllocTyped(PDInstanceType it, PDSize size, void *dealloc, PDBool zeroed);
132 #endif
133 
137 extern void PDFlush(void);
138 
145 extern void PDFlushUntil(void *ob);
146 
150 extern char *PDC;
151 
155 #ifdef DEBUG_PDTYPES
156 # define PDTYPE_ASSERT(ob) PDAssert(((PDTypeRef)ob - 1)->pdc == PDC)
157 #else
158 # define PDTYPE_ASSERT(ob)
159 #endif
160 
161 #ifdef PD_SUPPORT_CRYPTO
162 
167 
168 extern PDCryptoInstanceRef PDCryptoInstanceCreate(pd_crypto crypto, PDInteger obid, PDInteger gennum);
169 
175 typedef void (*PDInstanceCryptoExchange)(void *inst, PDCryptoInstanceRef ci, PDBool encrypted);
176 
181 
182 #endif
183 
190 struct PDObject {
196  void *inst;
200  char *streamBuf;
204  char *ovrStream;
207  char *ovrDef;
210  char *refString;
212  const void *syncInfo;
213 #ifdef PD_SUPPORT_CRYPTO
215  PDCryptoInstanceRef cryptoInstance;
216 #endif
217 };
218 
219 //
220 // object stream
221 //
222 
224 
241  void *def;
242 };
243 
254  PDObjectStreamElementRef elements;
256 };
257 
264 
275 
284 extern void PDObjectStreamParseExtractedObjectStream(PDObjectStreamRef obstm, char *buf);
285 
291 extern void PDObjectStreamCommit(PDObjectStreamRef obstm);
292 
312  const char *lastOperator;
313 };
314 
326 struct PDPage {
333 };
334 
338 
343 struct PDEnv {
347  //PDInteger entryOffset;
348 };
349 
355 extern void PDEnvDestroy(PDEnvRef env);
356 
358 
362 struct pd_btree {
364  void *value;
365  //PDInteger balance;
367 };
368 
370 
374 struct PDOperator {
376 
377  union {
379  char *key;
381  };
382 
384 };
385 
387 
393 typedef struct PDXTable *PDXTableRef;
394 
398 typedef enum {
403 } PDParserState;
404 
408 struct PDParser {
412 
413  // xref related
415  PDXTableRef mxt;
416  PDXTableRef cxt;
419 
420  // object related
429 
430  // document-wide stuff
440 
441  // miscellaneous
445 };
446 
453  union {
454  struct {
457  };
458  struct {
461  };
462  };
463 };
464 
468 struct PDCatalog {
476 };
477 
479 
480 typedef struct PDScannerSymbol *PDScannerSymbolRef;
481 
485 typedef enum {
493 
498  char *sstart;
499  short shash;
502 };
503 
507 struct PDScanner {
510  void *bufFuncInfo;
512 
517 
519 
520  char *buf;
525  PDScannerSymbolRef sym;
531 };
532 
534 
535 #define PD_STACK_STRING 0
536 #define PD_STACK_ID 1
537 #define PD_STACK_STACK 2
538 #define PD_STACK_PDOB 3
539 #define PD_STACK_FREEABLE 4
540 
541 
544 struct pd_stack {
546  char type;
547  void *info;
548 };
549 
550 
552 // "Get string object for key" signature for arrays/dictionaries. (Arrays pass integers as keys.)
553 // */
554 //typedef const char *(*_list_getter)(void *ref, const void *key);
555 //
557 // "Get raw object for key" signature for arrays/dictionaries. (Arrays pass integers as keys.)
558 // */
559 //typedef const pd_stack (*_list_getter_raw)(void *ref, const void *key);
560 //
562 // "Remove object for key" signature for arrays/dictionaries. (Arrays pass integers as keys.)
563 // */
564 //typedef void (*_list_remover)(void *ref, const void *key);
565 //
567 // "Set object for key to value" signature for arrays/dictionaries.
568 // */
569 //typedef PDInteger (*_list_setter)(void *ref, const void *key, const char *value);
570 //
572 // "Make room at index" signature for arrays.
573 // */
574 //typedef void (*_list_push_index)(void *ref, PDInteger index);
575 //
577 // The internal array structure.
578 // */
579 //struct pd_array {
580 // PDInteger count; ///< Number of elements
581 // PDInteger capacity; ///< Capacity of array
582 // char **values; ///< Content
583 // pd_stack *vstacks; ///< Values in pd_stack form
584 // _list_getter g; ///< Getter
585 // _list_getter_raw rg; ///< Raw getter
586 // _list_setter s; ///< Setter
587 // _list_remover r; ///< Remover
588 // _list_push_index pi; ///< Push-indexer
589 // void *info; ///< Info object (used for encrypted arrays)
590 //};
591 //
593 // The internal dictionary structure.
594 // */
595 //struct pd_dict {
596 // PDInteger count; ///< Number of entries
597 // PDInteger capacity; ///< Capacity of dictionary
598 // char **keys; ///< Keys
599 // char **values; ///< Values
600 // pd_stack *vstacks; ///< Values in pd_stack form
601 // _list_getter g; ///< Getter
602 // _list_getter_raw rg; ///< Raw getter
603 // _list_setter s; ///< Setter
604 // _list_remover r; ///< Remover
605 // void *info; ///< Info object (used for encrypted arrays)
606 //};
607 
611 struct PDArray {
614  void **values;
616 #ifdef PD_SUPPORT_CRYPTO
617  PDCryptoInstanceRef ci;
618 #endif
619 };
620 
621 typedef struct PDDictionaryNode *PDDictionaryNodeRef;
623  char *key;
624  void *data;
625 #ifdef PD_SUPPORT_CRYPTO
626  void *decrypted;
627 #endif
629 };
630 
634 //#define PDHM_PROF
635 
639 struct PDDictionary {
641 #ifdef PDHM_PROF
642  PDInteger maxCount;
643 #endif
648 #ifdef PD_SUPPORT_CRYPTO
649  PDCryptoInstanceRef ci;
650 #endif
651 };
652 
658 };
659 
667 };
668 
672 struct PDFont {
678  unsigned char *encMap;
679 };
680 
681 typedef struct PDCMapRange PDCMapRange;
684 
688 struct PDCMap {
702 };
703 
704 #ifdef PD_SUPPORT_CRYPTO
705 
713 };
714 
718 struct pd_crypto {
719  // common values
725 
726  // standard security handler
730  int32_t privs;
733 
734  // standard crypt filter
738 };
739 
740 #else
741 
742 struct pd_crypto {
743 
744 };
745 
746 #endif
747 
749 
753 struct PDState {
755  char *name;
756  char **symbol;
758 
760  short symindices;
761 
766 };
767 
769 
773 struct PDStaticHash {
779  void **keys;
780  void **values;
781  void **table;
782 };
783 
785 
789 struct PDTask {
797  void *info;
798 };
799 
801 
805 struct PDTwinStream {
808 
809  FILE *fi;
810  FILE *fo;
811  fpos_t offsi;
812  fpos_t offso;
813 
814  char *heap;
818 
819  char *sidebuf;
820 
822 };
823 
829 struct PDPipe {
833  char *pi;
834  char *po;
835  FILE *fi;
836  FILE *fo;
841  pd_stack
844 };
845 
846 extern void PDPipeCloseFileStream(FILE *stream);
847 extern FILE *PDPipeOpenInputStream(const char *path);
848 extern FILE *PDPipeOpenOutputStream(const char *path);
849 
851 
857 struct PDReference {
860 };
861 
863 
869 struct PDNumber {
871  union {
872  PDInteger i;
873  PDReal r;
874  PDBool b;
875  PDSize s;
876  void *p;
877  };
878 };
879 
881 
887 struct PDString {
893  char *data;
895 #ifdef PD_SUPPORT_CRYPTO
896  PDCryptoInstanceRef ci;
898 #endif
899 };
900 
901 extern void PDStringAttachCryptoInstance(PDStringRef string, PDCryptoInstanceRef ci, PDBool encrypted);
902 extern void PDArrayAttachCryptoInstance(PDArrayRef array, PDCryptoInstanceRef ci, PDBool encrypted);
903 extern void PDDictionaryAttachCryptoInstance(PDDictionaryRef dictionary, PDCryptoInstanceRef ci, PDBool encrypted);
904 extern void PDDictionaryAttachCryptoInstance(PDDictionaryRef hm, PDCryptoInstanceRef ci, PDBool encrypted);
905 
907 
908 typedef struct PDStringConv *PDStringConvRef;
909 
913 struct PDStringConv {
914  char *allocBuf;
917 };
918 
920 
924 #define PDDEF const void*[]
925 
929 #define PDDef(defs...) (PDDEF){(void*)defs, NULL}
930 
931 
938 #ifndef PDError
939 # if defined(DEBUG) || defined(PD_WARNINGS)
940 # define PD_WARNINGS
941 extern void _PDBreak();
942 # define PDError(args...) do {\
943  fprintf(stderr, "[pajdeg::error] %s:%d - ", __FILE__,__LINE__); \
944  fprintf(stderr, args); \
945  fprintf(stderr, "\n"); \
946  _PDBreak();\
947  } while (0)
948 # else
949 # define PDError(args...)
950 # endif
951 #endif
952 
959 #ifndef PDWarn
960 # if defined(DEBUG) || defined(PD_WARNINGS)
961 # define PD_WARNINGS
962 # define PDWarn(args...) do { \
963  fprintf(stderr, "[pajdeg::warning] %s:%d - ", __FILE__,__LINE__); \
964  fprintf(stderr, args); \
965  fprintf(stderr, "\n"); \
966  } while (0)
967 # else
968 # define PDWarn(args...)
969 # endif
970 #endif
971 
978 #ifndef PDNotice
979 # if defined(PD_NOTICES)
980 # define PDNotice(args...) do { \
981  fprintf(stderr, "[pajdeg::notice] %s:%d - ", __FILE__,__LINE__); \
982  fprintf(stderr, args); \
983  fprintf(stderr, "\n"); \
984  } while (0)
985 # else
986 # define PDNotice(args...)
987 # endif
988 #endif
989 
1000 #ifndef PDAssert
1001 # if defined(DEBUG) || defined(PD_ASSERTS)
1002 # include <assert.h>
1003 # if defined(PD_WARNINGS)
1004 # define PDAssert(args...) \
1005  if (!(args)) { \
1006  PDWarn("assertion failure : %s", #args); \
1007  assert(args); \
1008  }
1009 # else
1010 # define PDAssert(args...) assert(args)
1011 # endif
1012 # else
1013 # define PDAssert(args...)
1014 # endif
1015 #endif
1016 
1024 #define PDRequire(state, retval, msg...) \
1025  if (!(state)) { \
1026  PDWarn("requirement failure : " msg); \
1027  PDAssert(state); \
1028  return retval; \
1029  }
1030 
1039 #define as(type, expr...) ((type)(expr))
1040 
1046 extern void PDTwinStreamAsserts(PDTwinStreamRef ts);
1047 
1048 #define PDInstancePrinterRequire(b, r) \
1049  if (*cap - offs < b) { \
1050  *cap += r; \
1051  *buf = realloc(*buf, *cap); \
1052  }
1053 
1054 #define PDInstancePrinterInit(itype, b, r) \
1055  itype i = (itype) inst;\
1056  PDInstancePrinterRequire(b, r)
1057 
1066 #define fmatox(x, ato) \
1067 static inline x fast_mutative_##ato(char *str, PDInteger len) \
1068 { \
1069  char t = str[len]; \
1070  str[len] = 0; \
1071  x l = ato(str); \
1072  str[len] = t; \
1073  return l; \
1074 }
1075 
1076 fmatox(long long, atoll)
1077 fmatox(long, atol)
1078 
1079 #endif
Definition: PDDefines.h:242
PDTwinStreamMethod method
The current method.
Definition: pd_internal.h:806
PDOperatorRef next
the next operator, if any
Definition: pd_internal.h:383
PDSize size
size of heap
Definition: pd_internal.h:815
float PDReal
Definition: PDDefines.h:194
PDStringRef identifier
PDF /ID found in the trailer dictionary.
Definition: pd_internal.h:720
char * streamBuf
the stream, if fetched via parser, otherwise an undefined value
Definition: pd_internal.h:200
void * bufFuncInfo
buffer function info object
Definition: pd_internal.h:510
PDCMapRangeMapping * bfrs
BF ranges.
Definition: pd_internal.h:700
PDStateRef state
The wrapped state.
Definition: pd_internal.h:344
PDBool encryptedDoc
if set, the object is contained in an encrypted PDF; if false, PDObjectSetStreamEncrypted is NOP ...
Definition: pd_internal.h:209
void ** values
Resolved values.
Definition: pd_internal.h:614
pd_stack dicts
Stack of PDDictionaries.
Definition: pd_internal.h:657
#define fmatox(x, ato)
Definition: pd_internal.h:1066
PDTaskResult(* PDTaskFunc)(PDPipeRef pipe, PDTaskRef task, PDObjectRef object, void *info)
Definition: PDDefines.h:778
pd_stack xstack
A stack of partial xref tables based on offset; see [1] below.
Definition: pd_internal.h:414
PDBool typedTasks
Whether type tasks (excluding unfiltered tasks) are activated; activation results in a slight decreas...
Definition: pd_internal.h:832
PDInteger value
The filter value, if any.
Definition: pd_internal.h:793
pd_auth_event
Definition: PDDefines.h:417
PDInteger first
first object's offset
Definition: pd_internal.h:252
pd_crypto_method cfMethod
crypt filter method
Definition: pd_internal.h:736
const char * lastOperator
the last operator that was encountered
Definition: pd_internal.h:312
Definition: PDCMap.c:25
enum item count
Definition: PDDefines.h:732
fpos_t offso
absolute offset in output for file pointer
Definition: pd_internal.h:812
PDInteger version
algorithm version (V key in PDFs)
Definition: pd_internal.h:723
PDCryptoInstanceRef ci
Crypto instance, if array is encrypted.
Definition: pd_internal.h:617
PDInteger length
length of the encryption key, in bits; must be a multiple of 8 in the range 40 - 128; default = 40 ...
Definition: pd_internal.h:724
PDSize genid
generation number of the current object
Definition: pd_internal.h:427
void(* PDScannerBufFunc)(void *info, PDScannerRef scanner, char **buf, PDInteger *size, PDInteger req)
Definition: PDDefines.h:925
PDInteger capacity
Size of kids array.
Definition: pd_internal.h:474
PDBool leaveKeys
if set, the keys are not deallocated on destruction; default = false (i.e. dealloc keys) ...
Definition: pd_internal.h:777
void ** table
The static hash table.
Definition: pd_internal.h:781
PDInteger count
Number of entries.
Definition: pd_internal.h:640
PDSize xrefnewiter
iterator for locating unused id's for usage in master xref table
Definition: pd_internal.h:418
PDSize csrCount
Number of codespace ranges.
Definition: pd_internal.h:695
PDPropertyType propertyType
The filter property type.
Definition: pd_internal.h:792
PDStringRef enckey
encryption key
Definition: pd_internal.h:732
long PDInteger
Definition: PDDefines.h:184
PDBool dynamicFiltering
Whether dynamic filtering is necessary; if set, the static hash filtering of filters is skipped and f...
Definition: pd_internal.h:831
PDInteger bucketm
Bucket mask.
Definition: pd_internal.h:645
PDBool strict
if true, the scanner will complain loudly when erroring out, otherwise it will silently fail ...
Definition: pd_internal.h:530
PDArrayRef contentRefs
array of content references for the page
Definition: pd_internal.h:330
PDNumberRef type
CMapType.
Definition: pd_internal.h:691
char * PDC
Definition: PDType.c:281
PDOperatorRef numberOp
number operator
Definition: pd_internal.h:763
PDBool isActive
Whether task is still active; sometimes tasks cannot be unloaded properly even though the task return...
Definition: pd_internal.h:790
pd_stack envStack
environment stack; e.g. root -> arb -> array -> arb -> ...
Definition: pd_internal.h:513
PDInteger offs
The current offset inside the buffer.
Definition: pd_internal.h:915
FILE * fi
Reader.
Definition: pd_internal.h:835
char * name
name of the state
Definition: pd_internal.h:755
PDStateRef pushedState
for "PushNewEnv", this is the environment being pushed
Definition: pd_internal.h:378
unsigned char PDBool
Definition: PDDefines.h:207
PDF delimiter character.
Definition: pd_internal.h:488
PDObjectRef root
the root object, if instantiated
Definition: pd_internal.h:435
char * heap
heap in which buffer is located
Definition: pd_internal.h:814
PDParserRef parser
Parser reference.
Definition: pd_internal.h:673
PDBool PDObjectStreamParseRawObjectStream(PDObjectStreamRef obstm, char *rawBuf)
Definition: PDObjectStream.c:96
Definition: PDStreamFilter.h:121
PDStringRef user
user string ("U"), 32-byte string based on user password, used in determining whether to prompt the u...
Definition: pd_internal.h:729
PDInteger * symindex
symbol indices (for hash)
Definition: pd_internal.h:759
pd_stack appends
stack of objects that are meant to be appended at the end of the PDF
Definition: pd_internal.h:421
PDBool failed
if set, the scanner aborted due to a failure
Definition: pd_internal.h:528
PDParserRef parser
The owning parser.
Definition: pd_internal.h:664
PDBool outgrown
if true, a scanner with fixedBuf set needed more data
Definition: pd_internal.h:529
PDObjectStreamElementRef elements
n sized array of elements (non-pointered!)
Definition: pd_internal.h:254
pd_stack def
the object content
Definition: pd_internal.h:195
#define PDOperatorSymbolGlobWhitespace
PDF whitespace character.
Definition: PDOperator.h:49
PDStringRef filter
filter name
Definition: pd_internal.h:721
void ** values
Values array.
Definition: pd_internal.h:780
PDInteger shift
The shift.
Definition: pd_internal.h:776
const char ** PDID
Definition: PDDefines.h:284
PDInteger bsize
buffer capacity
Definition: pd_internal.h:522
a numeric symbol
Definition: pd_internal.h:489
PDScannerRef scanner
the master scanner
Definition: pd_internal.h:807
PDStringRef alt
Alternative representation.
Definition: pd_internal.h:894
PDFontDictionaryRef fontDict
The font dictionary for the page; lazily constructed on first call to PDPageGetFont().
Definition: pd_internal.h:332
PDObjectClass obclass
object class (regular, compressed, or trailer)
Definition: pd_internal.h:193
PDArrayRef args
pending operator arguments
Definition: pd_internal.h:308
PDInteger obid
object id of element
Definition: pd_internal.h:237
PDF whitespace character.
Definition: pd_internal.h:487
PDObjectRef obj
Font object reference.
Definition: pd_internal.h:675
PDInteger symbols
number of symbols in total
Definition: pd_internal.h:757
PDArrayRef populated
Array of buckets which were created (as opposed to remaining NULL due to index never being touched) ...
Definition: pd_internal.h:647
PDInteger obid
object id
Definition: pd_internal.h:191
PDInteger offset
offset inside object stream
Definition: pd_internal.h:238
PDInteger revision
revision ("R") of algorithm: 2 if version < 2 and perms have no 3 or greater values, 3 if version is 2 or 3, or P has rev 3 stuff, 4 if version = 4
Definition: pd_internal.h:727
void * value
The value.
Definition: pd_internal.h:364
#define PDOperatorSymbolExtNumeric
Numeric value.
Definition: PDOperator.h:51
PDInteger key
The (primitive) key.
Definition: pd_internal.h:363
#define PDOperatorSymbolExtFake
"Fake" symbol
Definition: PDOperator.h:52
PDBool ovrStreamAlloc
if set, ovrStream will be free()d by the object after use
Definition: pd_internal.h:206
void ** keys
Keys array.
Definition: pd_internal.h:779
PDObjectRef ob
the /Page object
Definition: pd_internal.h:327
char * data
Buffer containing string data.
Definition: pd_internal.h:893
PDBool done
parser has passed the last object in the input PDF
Definition: pd_internal.h:417
void * info
The (user) info object.
Definition: pd_internal.h:797
PDFontDictionaryRef mfd
Master font dictionary, containing all fonts processed so far.
Definition: pd_internal.h:444
parser is right after the endstream keyword, at the endobj keyword
Definition: pd_internal.h:402
PDParserRef parser
The parser.
Definition: pd_internal.h:839
PDSize bfcLength
Length (in bytes) of input characters in BF ranges.
Definition: pd_internal.h:698
void(* PDScannerPopFunc)(PDScannerRef scanner)
Definition: PDDefines.h:936
PDSize hash
the hash code
Definition: pd_internal.h:628
PDInteger boffset
buffer offset (we are at position &buf[boffset]
Definition: pd_internal.h:523
PDStreamFilterRef filter
filter used to extract the initial raw content
Definition: pd_internal.h:253
PDSize streamLen
stream length of the current object
Definition: pd_internal.h:425
char * ovrDef
definition override
Definition: pd_internal.h:207
PDInstanceType
Definition: PDDefines.h:557
PDSplayTreeRef constructs
instances of objects (i.e. constructs)
Definition: pd_internal.h:255
PDScannerSymbolType stype
symbol type
Definition: pd_internal.h:501
pd_stack typeTasks[_PDFTypeCount]
Tasks which run depending on all objects of the given type; the 0'th element (type NULL) is triggered...
Definition: pd_internal.h:842
PDInteger ovrStreamLen
length of ^
Definition: pd_internal.h:205
pd_stack buildStack
Build stack (for sub-components)
Definition: pd_internal.h:345
char ** symbol
symbol strings
Definition: pd_internal.h:756
PDInteger streamLen
length of stream (if one exists)
Definition: pd_internal.h:198
PDSynchronizer synchronizer
synchronizer callback, called right before the object is serialized and written to the output stream ...
Definition: pd_internal.h:211
PDInteger extractedLen
length of extracted stream; -1 until stream has been fetched via the parser
Definition: pd_internal.h:199
char type
Stack type.
Definition: pd_internal.h:546
void * info
The stack content, based on its type.
Definition: pd_internal.h:547
int32_t privs
privileges (see Table 3.20 in PDF spec v 1.7, p. 123-124)
Definition: pd_internal.h:730
PDOperatorRef delimiterOp
delimiter operator
Definition: pd_internal.h:764
char * key
the argument to the operator, for PopVariable, Push/StoveComplex, PullBuildVariable ...
Definition: pd_internal.h:379
pd_stack resultStack
results stack
Definition: pd_internal.h:514
pd_auth_event cfAuthEvent
when authentication occurs; currently only supports '/DocOpen'
Definition: pd_internal.h:737
PDSplayTreeRef opertree
operator tree
Definition: pd_internal.h:307
PDInteger capacity
Capacity of array.
Definition: pd_internal.h:613
pd_stack resetters
resetter (func, userInfo) pairs – called at the end of every execution call; these adhere to the PDD...
Definition: pd_internal.h:311
void PDFlush(void)
Definition: PDType.c:419
PDInteger genid
generation id
Definition: pd_internal.h:192
PDSize csrCap
Codespace range capacity.
Definition: pd_internal.h:692
PDInteger entries
Number of entries in static hash.
Definition: pd_internal.h:774
PDInteger slen
symbol length
Definition: pd_internal.h:500
PDObjectClass
Definition: PDDefines.h:631
PDBool skipStream
if set, even if an object has a stream, the stream (including keywords) is skipped when written to ou...
Definition: pd_internal.h:201
PDInteger genid
The generation ID.
Definition: pd_internal.h:460
char * pi
The path of the input file.
Definition: pd_internal.h:833
PDOperatorType
Definition: PDDefines.h:887
PDParserState state
The parser state.
Definition: pd_internal.h:411
PDSplayTreeRef filter
The filters, in a tree with the object ID as key.
Definition: pd_internal.h:840
PDSize bfrCap
BF range capacity.
Definition: pd_internal.h:693
void PDObjectStreamCommit(PDObjectStreamRef obstm)
Definition: PDObjectStream.c:221
PDSplayTreeRef aiTree
bin-tree identifying the (in-memory) PDObjectRefs in appends and inserts by their object ID's ...
Definition: pd_internal.h:423
PDSize length
Length of the string.
Definition: pd_internal.h:891
Definition: pd_internal.h:190
PDBool fixedBuf
if set, the buffer is fixed (i.e. buffering function should not be called)
Definition: pd_internal.h:527
PDInteger genid
Associated generation number.
Definition: pd_internal.h:712
PDStringRef subfilter
sub-filter name
Definition: pd_internal.h:722
PDArrayRef * buckets
Buckets containing content.
Definition: pd_internal.h:646
PDStringRef name
CMapName.
Definition: pd_internal.h:690
pd_crypto_method
Definition: PDDefines.h:408
Definition: PDXTable.h:93
PDPropertyType
Definition: PDDefines.h:746
PDSize holds
bytes in heap
Definition: pd_internal.h:816
PDBool skipObject
if set, entire object is discarded
Definition: pd_internal.h:202
PDSplayTreeRef attachments
PDParserAttachment entries.
Definition: pd_internal.h:843
PDOperatorRef fallbackOp
fallback operator
Definition: pd_internal.h:765
PDFontRef font
The font associated with the string.
Definition: pd_internal.h:889
void * def
definition; NULL if a construct has been made for this element
Definition: pd_internal.h:241
PDObjectType type
Type of the number; as a special case, PDObjectTypeReference is used for pointers.
Definition: pd_internal.h:870
PDObjectRef trailer
the trailer object
Definition: pd_internal.h:434
PDSize cursor
position in heap (bytes 0..cursor have been written (unless discarded) to output) ...
Definition: pd_internal.h:817
Definition: PDCMap.c:19
Definition: pd_internal.h:306
PDBool leaveValues
if set, the values are not deallocated on destruction; default = false (i.e. dealloc values) ...
Definition: pd_internal.h:778
PDID identifier
identifier (constant string pointer pointer)
Definition: pd_internal.h:380
PDObjectRef construct
cannot be relied on to contain anything; is used to hold constructed objects until iteration (at whic...
Definition: pd_internal.h:424
struct PDXTable * PDXTableRef
Definition: pd_internal.h:393
pd_crypto crypto
Crypto object.
Definition: pd_internal.h:710
size_t PDSize
Definition: PDDefines.h:213
PDSplayTreeRef skipT
whenever an object is ignored due to offset discrepancy, its ID is put on the skip tree; when the las...
Definition: pd_internal.h:443
char * refString
reference string, cached from calls to
Definition: pd_internal.h:210
PDOperatorRef * symbolOp
symbol operators
Definition: pd_internal.h:762
FILE * fo
writer
Definition: pd_internal.h:810
PDStringEncoding
Definition: PDDefines.h:656
#define PDOperatorSymbolGlobRegular
PDF regular character.
Definition: PDOperator.h:48
PDTaskFunc func
The function callback, if the task is not a filter.
Definition: pd_internal.h:794
PDBool collection
If set, this is a /Type /Pages object, which is a group of page and pages references.
Definition: pd_internal.h:452
PDCryptoInstanceRef ci
Crypto instance, if dictionary is encrypted.
Definition: pd_internal.h:649
pd_stack deallocators
deallocator (func, userInfo) pairs – called when content stream object is about to be destroyed ...
Definition: pd_internal.h:310
PDReferenceRef encryptRef
reference to the encrypt object
Definition: pd_internal.h:433
PDTwinStreamRef stream
The I/O stream from the pipe.
Definition: pd_internal.h:409
PDScannerBufFunc bufFunc
buffer function
Definition: pd_internal.h:509
PDObjectRef PDObjectCreate(PDInteger obid, PDInteger genid)
Definition: PDObject.c:57
PDStringType type
Type of the string.
Definition: pd_internal.h:888
PDInteger filterCount
Number of filters in the pipe.
Definition: pd_internal.h:837
PDFontDictionaryRef fontDict
The owning font dictionary.
Definition: pd_internal.h:674
PDStringEncoding enc
String encoding, or NULL if not a string encoding.
Definition: pd_internal.h:677
PDCryptoInstanceRef cryptoInstance
crypto instance, if set up
Definition: pd_internal.h:215
end of buffer marked
Definition: pd_internal.h:490
PDBool opened
Whether pipe has been opened or not.
Definition: pd_internal.h:830
PDObjectStreamRef PDObjectStreamCreateWithObject(PDObjectRef object)
Definition: PDObjectStream.c:68
PDScannerSymbolRef sym
the latest symbol
Definition: pd_internal.h:525
PDInteger obid
Associated object ID.
Definition: pd_internal.h:711
pd_stack prev
Previous object in stack.
Definition: pd_internal.h:545
PDInteger bmark
buffer mark
Definition: pd_internal.h:524
PDPageReference * kids
Kids.
Definition: pd_internal.h:456
void * inst
instance of def, or NULL if not yet instantiated
Definition: pd_internal.h:196
PDTwinStreamRef stream
The pipe stream.
Definition: pd_internal.h:838
PDCMapRef toUnicode
CMap, or NULL if not yet compiled or if non-existent.
Definition: pd_internal.h:676
fake symbol, which is when sstart is actually a real string, rather than a pointer into the stream bu...
Definition: pd_internal.h:491
parser is in between objects
Definition: pd_internal.h:399
PDEnvRef env
the current environment
Definition: pd_internal.h:508
void(* PDInstanceCryptoExchange)(void *inst, PDCryptoInstanceRef ci, PDBool encrypted)
Definition: pd_internal.h:175
PDObjectRef ob
obstream object
Definition: pd_internal.h:250
PDXTableRef cxt
current input xref table
Definition: pd_internal.h:416
PDObjectType
Definition: PDDefines.h:611
PDInteger cfLength
crypt filter length, e.g. 16 for AESV2
Definition: pd_internal.h:735
#define PDOperatorSymbolExtEOB
End of buffer (usually synonymous with end of file) symbol.
Definition: PDOperator.h:53
PDCatalogRef catalog
the root catalog, if instantiated
Definition: pd_internal.h:438
char * sidebuf
temporary buffer (e.g. for Fetch)
Definition: pd_internal.h:819
PDBool deleteObject
if set, the object's XREF table slot is marked as free
Definition: pd_internal.h:203
short symindices
number of index slots in total (not = symbols, often bigger)
Definition: pd_internal.h:760
PDXTableRef mxt
master xref table, used for output
Definition: pd_internal.h:415
PDBool wrapped
Whether the string is wrapped.
Definition: pd_internal.h:892
PDObjectRef * contentObs
array of content objects for the page, or NULL if unfetched
Definition: pd_internal.h:331
char * po
The path of the output file.
Definition: pd_internal.h:834
char * allocBuf
The allocated buffer.
Definition: pd_internal.h:914
unsigned char * encMap
Encoding map, a 256 byte array mapping bytes to bytes.
Definition: pd_internal.h:678
Definition: PDSplayTree.c:20
void(* PDSynchronizer)(void *parser, void *object, const void *syncInfo)
Definition: PDDefines.h:311
pd_stack opers
current operators stack
Definition: pd_internal.h:309
PDDictionaryRef fonts
Dictionary mapping font names to their values.
Definition: pd_internal.h:665
PDOperatorType type
The operator type.
Definition: pd_internal.h:375
PDCryptoInstanceRef ci
Crypto instance.
Definition: pd_internal.h:896
PDInteger bucketc
Number of buckets.
Definition: pd_internal.h:644
Definition: pd_internal.h:362
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:709
Definition: pd_internal.h:639
Definition: pd_internal.h:622
Definition: pd_internal.h:656
Definition: pd_internal.h:343
Definition: pd_internal.h:672
Definition: pd_internal.h:663
Definition: pd_internal.h:869
Definition: pd_internal.h:249
Definition: pd_internal.h:236
Definition: pd_internal.h:374
Definition: pd_internal.h:451
Definition: pd_internal.h:408
Definition: pd_internal.h:829
Definition: pd_internal.h:857
Definition: pd_internal.h:507
Definition: pd_internal.h:497
PDInteger n
number of objects
Definition: pd_internal.h:251
Definition: pd_internal.h:753
Definition: pd_internal.h:773
Definition: pd_internal.h:887
Definition: pd_internal.h:913
Definition: pd_internal.h:789
Definition: pd_internal.h:805
pd_stack symbolStack
symbols stack; used to "rewind" when misinterpretations occur (e.g. for "number_or_obref" when one or...
Definition: pd_internal.h:515
parser is right after the object's content, and expects to see endobj or stream next ...
Definition: pd_internal.h:401
Definition: pd_internal.h:326
PDStringType
Definition: PDDefines.h:649
PDStreamFilterRef filter
filter, if any
Definition: pd_internal.h:518
PDBool encrypted
Flag indicating whether the string is encrypted or not; the value of this flag is UNDEFINED if ci == ...
Definition: pd_internal.h:897
Definitions for the Pajdeg interface.
PDParserState
Definition: pd_internal.h:398
PDSplayTreeRef branch[2]
The left and right branches of the tree.
Definition: pd_internal.h:366
FILE * fi
Reader.
Definition: pd_internal.h:809
PDScannerRef scanner
The main scanner.
Definition: pd_internal.h:410
void PDTwinStreamAsserts(PDTwinStreamRef ts)
Definition: PDTwinStream.c:409
pd_crypto crypto
crypto instance, if the document is encrypted
Definition: pd_internal.h:439
PDTaskRef child
The task's child task; child tasks are called in order.
Definition: pd_internal.h:795
standard symbol
Definition: pd_internal.h:486
PDCMapRange * csrs
Array of codespace ranges.
Definition: pd_internal.h:699
PDSize oboffset
offset of the current object
Definition: pd_internal.h:428
PDInteger * kids
Array of object IDs for all pages.
Definition: pd_internal.h:475
pd_stack garbageStack
temporary allocations; only used in operator function when a symbol is regenerated from a malloc()'d ...
Definition: pd_internal.h:516
PDReferenceRef rootRef
reference to the root object
Definition: pd_internal.h:431
PDSize bfcCap
BF char capacity.
Definition: pd_internal.h:694
#define PDTYPE_PTR_LEN
Definition: pd_internal.h:79
PDInteger bresoffset
previously popped result's offset relative to buf
Definition: pd_internal.h:521
PDBool encryptMetadata
whether metadata should be encrypted or not ("/EncryptMetadata true")
Definition: pd_internal.h:731
PDInteger mask
The mask.
Definition: pd_internal.h:775
PDBool isFilter
Whether task is a filter or not. Internally, a task is only a filter if it is assigned to a specific ...
Definition: pd_internal.h:791
PDScannerSymbolType
Definition: pd_internal.h:485
const void * syncInfo
user info object for synchronizer callback (usually a class instance, for wrappers) ...
Definition: pd_internal.h:212
#define PDOperatorSymbolGlobDelimiter
PDF delimiter character.
Definition: PDOperator.h:50
PDStringRef owner
owner string ("O"), 32-byte string based on owner and user passwords, used to compute encryption key ...
Definition: pd_internal.h:728
PDInteger contentCount
of content objects in the page
Definition: pd_internal.h:329
struct PDCryptoInstance * PDCryptoInstanceRef
Definition: pd_internal.h:166
FILE * fo
Writer.
Definition: pd_internal.h:836
PDInteger count
Number of entries.
Definition: pd_internal.h:455
PDInteger obid
The object ID.
Definition: pd_internal.h:858
PDBool hasStream
if set, object has a stream
Definition: pd_internal.h:197
Definition: PDCMap.c:14
void * decrypted
the data, in decrypted form
Definition: pd_internal.h:626
PDReferenceRef infoRef
reference to the info object
Definition: pd_internal.h:432
PDObjectType type
element object type
Definition: pd_internal.h:240
void * data
the data
Definition: pd_internal.h:624
short shash
symbol hash (not normalized)
Definition: pd_internal.h:499
void * PDAllocTyped(PDInstanceType it, PDSize size, void *dealloc, PDBool zeroed)
Definition: PDType.c:312
PDPageReference pages
The root pages.
Definition: pd_internal.h:472
PDInstanceCryptoExchange PDInstanceCryptoExchanges[]
Definition: pd_pdf_implementation.c:947
PDCMapCharMapping * bfcs
BF chars.
Definition: pd_internal.h:701
char * ovrStream
stream override
Definition: pd_internal.h:204
void PDObjectStreamParseExtractedObjectStream(PDObjectStreamRef obstm, char *buf)
Definition: PDObjectStream.c:122
PDSize obid
object ID of the current object
Definition: pd_internal.h:426
PDRect mediaBox
The media box of the catalog object.
Definition: pd_internal.h:471
PDBool outgrown
if true, a buffer with growth disallowed attempted to grow and failed
Definition: pd_internal.h:821
PDScannerPopFunc popFunc
the symbol pop function
Definition: pd_internal.h:526
PDParserRef parser
the parser associated with the owning PDF document
Definition: pd_internal.h:328
PDInteger ovrDefLen
take a wild guess
Definition: pd_internal.h:208
PDDictionaryRef systemInfo
The CIDSystemInfo dictionary, which has /Registry, /Ordering, and /Supplement.
Definition: pd_internal.h:689
PDStringEncoding enc
Encoding of the string.
Definition: pd_internal.h:890
PDInteger left
The current bytes left (remaining) in the buffer.
Definition: pd_internal.h:916
PDTwinStreamMethod
Definition: PDDefines.h:812
PDObjectRef encrypt
the encrypt object, if instantiated
Definition: pd_internal.h:437
pd_stack contextStack
context stack for buffer function/info
Definition: pd_internal.h:511
char * sstart
symbol start
Definition: pd_internal.h:498
PDObjectType type
data structure of def below
Definition: pd_internal.h:194
fpos_t offsi
absolute offset in input for heap
Definition: pd_internal.h:811
pd_stack * vstacks
Unresolved values in pd_stack form.
Definition: pd_internal.h:615
PDDeallocator deallocator
The deallocator for the task.
Definition: pd_internal.h:796
pd_stack varStack
Variable stack (for incomplete components)
Definition: pd_internal.h:346
PDObjectRef object
The object representation of the catalog.
Definition: pd_internal.h:470
PDInteger length
length of the (stringified) definition; only valid during a commit
Definition: pd_internal.h:239
PDDictionaryRef encodings
Encoding dictionary.
Definition: pd_internal.h:666
char * buf
buffer
Definition: pd_internal.h:520
PDSize bfcCount
Number of BF chars.
Definition: pd_internal.h:697
PDParserRef parser
The parser owning the catalog.
Definition: pd_internal.h:469
char * key
the key for this node
Definition: pd_internal.h:623
PDInteger count
Number of elements.
Definition: pd_internal.h:612
void PDEnvDestroy(PDEnvRef env)
Definition: PDEnv.c:31
PDInteger count
Number of pages (in total)
Definition: pd_internal.h:473
PDBool iterates
if true, scanner will stop while in this state, after reading one entry
Definition: pd_internal.h:754
pd_stack inserts
stack of objects that are meant to be inserted as soon as the current object is dealt with ...
Definition: pd_internal.h:422
parser is right after 1 2 obj and right before whatever the object consists of
Definition: pd_internal.h:400
void PDFlushUntil(void *ob)
Definition: PDType.c:427
PDInteger genid
The generation number.
Definition: pd_internal.h:859
PDSize bfrCount
Number of BF ranges.
Definition: pd_internal.h:696
PDObjectRef info
the info object, if instantiated
Definition: pd_internal.h:436
pd_crypto crypto
crypto object, if available
Definition: pd_internal.h:214
void(* PDDeallocator)(void *ob)
Definition: PDDefines.h:299
PDBool success
if true, the parser has so far succeeded at parsing the input file
Definition: pd_internal.h:442
PDInteger obid
The object ID.
Definition: pd_internal.h:459