1 /*
2  * tumble: build a PDF file from image files
3  *
4  * PDF routines
5  * Copyright 2003, 2017 Eric Smith <spacewar@gmail.com>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License version 2 as
9  * published by the Free Software Foundation.  Note that permission is
10  * not granted to redistribute this program under the terms of any
11  * other version of the General Public License.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
21  */
22 
23 
24 struct pdf_name_tree
25 {
26   pdf_file_handle           pdf_file;
27   struct pdf_name_tree      *next;  /* chain all name trees in the PDF file */
28   bool                      number_tree;   /* false for name tree,
29 					      true for number tree */
30   struct pdf_name_tree_node *root;
31 };
32 
33 
34 #define MAX_NAME_TREE_NODE_ENTRIES 32
35 
36 
37 struct pdf_name_tree_node
38 {
39   struct pdf_obj *dict;    /* indirect reference */
40 
41   struct pdf_name_tree_node *parent;  /* NULL for root */
42   bool leaf;
43 
44   int count;               /* how many kids or names/numbers are
45 			      attached to this node */
46 
47   struct pdf_name_tree_node *kids [MAX_NAME_TREE_NODE_ENTRIES];  /* non-leaf only */
48 
49   struct pdf_obj *min_key;
50   struct pdf_obj *max_key;
51 
52   /* following fields valid in leaf nodes only: */
53 
54   struct pdf_obj *keys [MAX_NAME_TREE_NODE_ENTRIES];
55   struct pdf_obj *values [MAX_NAME_TREE_NODE_ENTRIES];
56 };
57 
58 
59 struct pdf_name_tree *pdf_new_name_tree (pdf_file_handle pdf_file,
60 					 bool number_tree);
61 
62 
63 void pdf_add_name_tree_element (struct pdf_name_tree *tree,
64 				char *key,
65 				struct pdf_obj *val);
66 
67 
68 void pdf_add_number_tree_element (struct pdf_name_tree *tree,
69 				  long key,
70 				  struct pdf_obj *val);
71 
72 
73 void pdf_finalize_name_trees (pdf_file_handle pdf_file);
74