3 Copyright 2012 Taco Hoekwater <taco@luatex.org>
5 This file is part of LuaTeX.
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.
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.
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/>. */
21 #ifndef LUATEXCALLBACKIDS_H
22 #define LUATEXCALLBACKIDS_H
25 find_write_file_callback
= 1,
26 find_output_file_callback
,
27 find_image_file_callback
,
28 find_format_file_callback
,
29 find_read_file_callback
, open_read_file_callback
,
30 find_vf_file_callback
, read_vf_file_callback
,
31 find_data_file_callback
, read_data_file_callback
,
32 find_font_file_callback
, read_font_file_callback
,
33 find_map_file_callback
, read_map_file_callback
,
34 find_enc_file_callback
, read_enc_file_callback
,
35 find_type1_file_callback
, read_type1_file_callback
,
36 find_truetype_file_callback
, read_truetype_file_callback
,
37 find_opentype_file_callback
, read_opentype_file_callback
,
38 find_sfd_file_callback
, read_sfd_file_callback
,
39 find_cidmap_file_callback
, read_cidmap_file_callback
,
40 find_pk_file_callback
, read_pk_file_callback
,
41 show_error_hook_callback
,
42 process_input_buffer_callback
, process_output_buffer_callback
,
43 process_jobname_callback
,
44 start_page_number_callback
, stop_page_number_callback
,
45 start_run_callback
, stop_run_callback
,
47 pre_output_filter_callback
,
48 buildpage_filter_callback
,
49 hpack_filter_callback
, vpack_filter_callback
,
54 pre_linebreak_filter_callback
,
55 linebreak_filter_callback
,
56 post_linebreak_filter_callback
,
57 append_to_vlist_filter_callback
,
58 mlist_to_hlist_callback
,
59 finish_pdffile_callback
,
60 finish_pdfpage_callback
,
62 start_file_callback
, stop_file_callback
,
63 show_error_message_callback
, show_lua_error_hook_callback
,
64 show_warning_message_callback
,
65 hpack_quality_callback
, vpack_quality_callback
,
66 process_rule_callback
,
67 insert_local_par_callback
,
68 contribute_filter_callback
,
70 build_page_insert_callback
,
72 } callback_callback_types
;
76 extern int callback_set
[];
78 # define callback_defined(a) callback_set[a]
79 /* # define callback_defined(a) debug_callback_defined(a) */
81 extern int lua_active
;
83 extern int debug_callback_defined(int i
);
85 extern int run_callback(int i
, const char *values
, ...);
86 extern int run_saved_callback(int i
, const char *name
, const char *values
, ...);
87 extern int run_and_save_callback(int i
, const char *values
, ...);
88 extern void destroy_saved_callback(int i
);
90 extern void get_saved_lua_boolean(int i
, const char *name
, boolean
* target
);
91 extern void get_saved_lua_number(int i
, const char *name
, int *target
);
92 extern void get_saved_lua_string(int i
, const char *name
, char **target
);
94 extern void get_lua_boolean(const char *table
, const char *name
, boolean
* target
);
95 extern void get_lua_number(const char *table
, const char *name
, int *target
);
96 extern void get_lua_string(const char *table
, const char *name
, char **target
);
98 extern int lua_reader_callback(int callback_id
, pointer
*buffloc
);
100 extern char *get_lua_name(int i
);
103 extern char *luatex_find_file(const char *s
, int callback_index
);
104 extern int readbinfile(FILE * f
, unsigned char **b
, int *s
);
106 #define filetype_unknown 0
107 #define filetype_tex 1
108 #define filetype_map 2
109 #define filetype_image 3
110 #define filetype_subset 4
111 #define filetype_font 5
113 static const char *const filetypes_left
[] = { "?", "(", "{", "<", "<", "<<" } ;
114 static const char *const filetypes_right
[] = { "?", ")", "}", ">", ">", ">>" } ;
116 #define report_start_file(left,name) do { \
117 if (tracefilenames) { \
118 int report_id = callback_defined(start_file_callback); \
119 if (report_id == 0) { \
121 /* we only do this for traditional name reporting, normally name is iname */ \
122 if (term_offset + strlen(name) > max_print_line - 2) \
124 else if ((term_offset > 0) || (file_offset > 0)) \
126 tex_printf("%s", filetypes_left[left]); \
127 tprint_file_name(NULL, (unsigned char *) name, NULL); \
129 tex_printf("%s", filetypes_left[left]); \
130 tex_printf("%s", (unsigned char *) name); \
133 /* (void) run_callback(report_id, "dS->",left,(unsigned char *) fullnameoffile); */ \
134 (void) run_callback(report_id, "dS->",left,name); \
139 #define report_stop_file(right) do { \
140 if (tracefilenames) { \
141 int report_id = callback_defined(stop_file_callback); \
142 if (report_id == 0) { \
143 tex_printf("%s", filetypes_right[right]); \
145 (void) run_callback(report_id, "d->",right); \
152 #define normal_page_filter(A) lua_node_filter_s(buildpage_filter_callback,lua_key_index(A))
153 #define checked_page_filter(A) if (!output_active) lua_node_filter_s(buildpage_filter_callback,lua_key_index(A))
154 #define checked_break_filter(A) if (!output_active) lua_node_filter_s(contribute_filter_callback,lua_key_index(A))