1 /* pdftables.h
2 
3    Copyright 2009-2013 Taco Hoekwater <taco@luatex.org>
4 
5    This file is part of LuaTeX.
6 
7    LuaTeX is free software; you can redistribute it and/or modify it under
8    the terms of the GNU General Public License as published by the Free
9    Software Foundation; either version 2 of the License, or (at your
10    option) any later version.
11 
12    LuaTeX is distributed in the hope that it will be useful, but WITHOUT
13    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
15    License for more details.
16 
17    You should have received a copy of the GNU General Public License along
18    with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */
19 
20 
21 #ifndef PDFTABLES_H
22 #  define PDFTABLES_H
23 
24 extern const char *pdf_obj_typenames[PDF_OBJ_TYPE_MAX + 1];
25 
26 typedef enum {
27     union_type_int,
28     union_type_cstring,
29 } union_type;
30 
31 typedef struct {
32     union {
33         int int0;
34         char *str0;
35     } u;
36     union_type u_type;          /* integer or char * in union above */
37     int objptr;
38 } oentry;
39 
40 /*
41 The cross-reference table |obj_tab| is an array of |obj_tab_size| of
42 |obj_entry|. Each entry contains five integer fields and represents an object
43 in PDF file whose object number is the index of this entry in |obj_tab|.
44 Objects in |obj_tab| maybe linked into list; objects in such a linked list have
45 the same type.
46 */
47 
48 /*
49 The first field contains information representing identifier of this object.
50 It is usally a number for most of object types, but it may be a string number
51 for named destination or named thread.
52 
53 The second field of |obj_entry| contains link to the next
54 object in |obj_tab| if this object is linked in a list.
55 
56 The third field holds the byte offset of the object in the output PDF file,
57 or its byte offset within an object stream. As long as the object is not
58 written, this field is used for flags about the write status of the object;
59 then it has a negative value.
60 
61 The fourth field holds the object number of the object stream, into which
62 the object is included.
63 
64 The last field usually represents the pointer to some auxiliary data
65 structure depending on the object type; however it may be used as a counter as
66 well.
67 */
68 
69 #  define obj_info(pdf,A)      pdf->obj_tab[(A)].u.int0 /* information representing identifier of this object */
70 #  define obj_start(pdf,A)     pdf->obj_tab[(A)].u.str0
71 #  define obj_link(pdf,A)      pdf->obj_tab[(A)].int1   /* link to the next entry in linked list */
72 
73 #  define obj_offset(pdf,A)    pdf->obj_tab[(A)].int2   /* negative (flags), or byte offset for this object in PDF
74                                                            output file, or ... */
75 #  define obj_os_objnum(pdf,A) pdf->obj_tab[(A)].int2   /* ... object stream number for this object */
76 #  define obj_os_idx(pdf,A)    pdf->obj_tab[(A)].int3   /* index of this object in object stream */
77 #  define obj_aux(pdf,A)       pdf->obj_tab[(A)].v.int4 /* auxiliary pointer */
78 #  define obj_stop(pdf,A)      pdf->obj_tab[(A)].v.str4
79 #  define obj_type(pdf,A)      pdf->obj_tab[(A)].objtype
80 
81 #  define obj_data_ptr               obj_aux    /* pointer to |pdf->mem| */
82 
83 #  define set_obj_link(pdf,A,B)      obj_link(pdf,A)=(B)
84 #  define set_obj_start(pdf,A,B)     obj_start(pdf,A)=(B)
85 #  define set_obj_info(pdf,A,B)      obj_info(pdf,A)=(B)
86 #  define set_obj_offset(pdf,A,B)    obj_offset(pdf,A)=(B)
87 #  define set_obj_os_objnum(pdf,A,B) obj_offset(pdf,A)=(B)
88 #  define set_obj_aux(pdf,A,B)       obj_aux(pdf,A)=(B)
89 #  define set_obj_stop(pdf,A,B)      obj_stop(pdf,A)=(B)
90 #  define set_obj_data_ptr(pdf,A,B)  obj_data_ptr(pdf,A)=(B)
91 
92 #  define set_obj_fresh(pdf,A)       obj_offset(pdf,(A))=(off_t)-2
93 #  define set_obj_scheduled(pdf,A)   if (obj_offset(pdf,A)==(off_t)-2) obj_offset(pdf,A)=(off_t)-1
94 #  define is_obj_scheduled(pdf,A)    ((obj_offset(pdf,A))>(off_t)-2)
95 #  define is_obj_written(pdf,A)      ((obj_offset(pdf,A))>(off_t)-1)
96 
97 /*  NOTE: The data structure definitions for the nodes on the typesetting side are
98     inside |nodes.h| */
99 
100 /* Some constants */
101 #  define inf_pk_dpi 72         /* min PK pixel density value from \.{texmf.cnf} */
102 #  define sup_pk_dpi 8000       /* max PK pixel density value from \.{texmf.cnf} */
103 
104 extern int find_obj(PDF pdf, int t, int i, boolean byname);
105 extern void check_obj_exists(PDF pdf, int objnum);
106 extern void check_obj_type(PDF pdf, int t, int objnum);
107 extern int pdf_get_obj(PDF pdf, int t, int i, boolean byname);
108 extern int pdf_create_obj(PDF pdf, int t, int i);
109 
110 extern void set_rect_dimens(PDF pdf, halfword p, halfword parent_box,
111                             scaledpos cur, scaled_whd alt_rule, scaled margin);
112 
113 extern void libpdffinish(PDF);
114 
115 extern void dump_pdftex_data(PDF pdf);
116 extern void undump_pdftex_data(PDF pdf);
117 
118 #  define set_width(A, B) width(A) = (B)
119 #  define set_height(A, B) height(A) = (B)
120 #  define set_depth(A, B) depth(A) = (B)
121 
122 /* interface definitions for eqtb locations */
123 #  define pdf_compress_level       int_par(pdf_compress_level_code)
124 #  define pdf_decimal_digits       int_par(pdf_decimal_digits_code)
125 #  define pdf_draftmode            int_par(pdf_draftmode_code)
126 #  define pdf_gamma                int_par(pdf_gamma_code)
127 #  define pdf_gen_tounicode        int_par(pdf_gen_tounicode_code)
128 #  define pdf_image_apply_gamma    int_par(pdf_image_apply_gamma_code)
129 #  define pdf_image_gamma          int_par(pdf_image_gamma_code)
130 #  define pdf_image_hicolor        int_par(pdf_image_hicolor_code)
131 #  define pdf_inclusion_copy_font  int_par(pdf_inclusion_copy_font_code)
132 #  define pdf_inclusion_errorlevel int_par(pdf_inclusion_errorlevel_code)
133 #  define pdf_minor_version        int_par(pdf_minor_version_code)
134 #  define pdf_move_chars           int_par(pdf_move_chars_code)
135 #  define pdf_objcompresslevel     int_par(pdf_objcompresslevel_code)
136 #  define pdf_output               int_par(pdf_output_code)
137 #  define pdf_pk_mode              equiv(pdf_pk_mode_loc)
138 #  define pdf_pk_resolution        int_par(pdf_pk_resolution_code)
139 #  define pdf_replace_font         int_par(pdf_replace_font_code)
140 #  define pdf_unique_resname       int_par(pdf_unique_resname_code)
141 
142 #endif                          /* PDFTABLES_H */
143