1 /* pdfaction.h
2 
3    Copyright 2009 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 PDFACTION_H
22 #  define PDFACTION_H
23 
24 /* pdf action spec */
25 
26 #  define pdf_action_size 4
27 
28 typedef enum {
29     pdf_action_page = 0,
30     pdf_action_goto,
31     pdf_action_thread,
32     pdf_action_user
33 } pdf_action_type;
34 
35 typedef enum {
36     pdf_window_notset,
37     pdf_window_new,
38     pdf_window_nonew,
39 } pdf_window_type;
40 
41 
42 #  define pdf_action_type(a)        type((a) + 1)       /* enum pdf_action_type */
43 #  define pdf_action_named_id(a)    subtype((a) + 1)    /* boolean */
44 #  define pdf_action_id(a)          vlink((a) + 1)      /* number or toks */
45 #  define pdf_action_file(a)        vinfo((a) + 2)      /* toks */
46 #  define pdf_action_new_window(a)  vlink((a) + 2)      /* enum pdf_window_type */
47 #  define pdf_action_tokens(a)      vinfo((a) + 3)      /* toks */
48 #  define pdf_action_refcount(a)    vlink((a) + 3)      /* number */
49 
50 /* increase count of references to this action. this is used to speed up copy_node() */
51 
52 #  define add_action_ref(a) pdf_action_refcount((a))++
53 
54 /* decrease count of references to this
55    action; free it if there is no reference to this action*/
56 
57 #  define delete_action_ref(a) {                                        \
58         if (pdf_action_refcount(a) == null) {                           \
59             delete_action_node(a);                                      \
60         } else {                                                        \
61             pdf_action_refcount(a)--;                                   \
62         }                                                               \
63     }
64 
65 
66 #  define set_pdf_action_type(A,B) pdf_action_type(A)=B
67 #  define set_pdf_action_tokens(A,B) pdf_action_tokens(A)=B
68 #  define set_pdf_action_file(A,B) pdf_action_file(A)=B
69 #  define set_pdf_action_id(A,B) pdf_action_id(A)=B
70 #  define set_pdf_action_named_id(A,B) pdf_action_named_id(A)=B
71 #  define set_pdf_action_new_window(A,B) pdf_action_new_window(A)=B
72 
73 extern halfword scan_action(PDF pdf);
74 extern void write_action(PDF pdf, halfword p);
75 extern void delete_action_node(halfword a);
76 
77 #endif
78