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/>. */
22 #ifndef LUATEXCALLBACKIDS_H
23 #define LUATEXCALLBACKIDS_H
26 find_write_file_callback
= 1,
27 find_output_file_callback
,
28 find_image_file_callback
,
29 find_format_file_callback
,
30 find_read_file_callback
, open_read_file_callback
,
31 find_vf_file_callback
, read_vf_file_callback
,
32 find_data_file_callback
, read_data_file_callback
,
33 find_font_file_callback
, read_font_file_callback
,
34 find_map_file_callback
, read_map_file_callback
,
35 find_enc_file_callback
, read_enc_file_callback
,
36 find_type1_file_callback
, read_type1_file_callback
,
37 find_truetype_file_callback
, read_truetype_file_callback
,
38 find_opentype_file_callback
, read_opentype_file_callback
,
39 find_sfd_file_callback
, read_sfd_file_callback
,
40 find_cidmap_file_callback
, read_cidmap_file_callback
,
41 find_pk_file_callback
, read_pk_file_callback
,
42 show_error_hook_callback
,
43 process_input_buffer_callback
, process_output_buffer_callback
,
44 process_jobname_callback
,
45 start_page_number_callback
, stop_page_number_callback
,
46 start_run_callback
, stop_run_callback
,
48 token_filter_callback
,
49 pre_output_filter_callback
,
50 buildpage_filter_callback
,
51 hpack_filter_callback
, vpack_filter_callback
,
56 pre_linebreak_filter_callback
,
57 linebreak_filter_callback
,
58 post_linebreak_filter_callback
,
59 mlist_to_hlist_callback
,
60 finish_pdffile_callback
,
61 finish_pdfpage_callback
,
63 start_file_callback
, stop_file_callback
,
64 show_error_message_callback
,show_lua_error_hook_callback
,
66 } callback_callback_types
;
70 extern int callback_set
[];
72 # define callback_defined(a) callback_set[a]
73 /* # define callback_defined(a) debug_callback_defined(a) */
75 extern int lua_active
;
77 extern int debug_callback_defined(int i
);
79 extern int run_callback(int i
, const char *values
, ...);
80 extern int run_saved_callback(int i
, const char *name
, const char *values
, ...);
81 extern int run_and_save_callback(int i
, const char *values
, ...);
82 extern void destroy_saved_callback(int i
);
84 extern void get_saved_lua_boolean(int i
, const char *name
, boolean
* target
);
85 extern void get_saved_lua_number(int i
, const char *name
, int *target
);
86 extern void get_saved_lua_string(int i
, const char *name
, char **target
);
88 extern void get_lua_boolean(const char *table
, const char *name
,
90 extern void get_lua_number(const char *table
, const char *name
, int *target
);
91 extern void get_lua_string(const char *table
, const char *name
, char **target
);
93 extern char *get_lua_name(int i
);
96 extern char *luatex_find_file(const char *s
, int callback_index
);
97 extern int readbinfile(FILE * f
, unsigned char **b
, int *s
);
99 #define filetype_unknown 0
100 #define filetype_tex 1
101 #define filetype_map 2
102 #define filetype_image 3
103 #define filetype_subset 4
104 #define filetype_font 5
106 static const char *const filetypes_left
[] = { "?", "(", "{", "<", "<", "<<" } ;
107 static const char *const filetypes_right
[] = { "?", ")", "}", ">", ">", ">>" } ;
109 #define report_start_file(left,name) do { \
110 if (tracefilenames) { \
111 int report_id = callback_defined(start_file_callback); \
112 if (report_id == 0) { \
114 /* we only do this for traditional name reporting, normally name is iname */ \
115 if (term_offset + strlen(name) > max_print_line - 2) \
117 else if ((term_offset > 0) || (file_offset > 0)) \
119 tex_printf("%s", filetypes_left[left]); \
120 tprint_file_name(NULL, (unsigned char *) name, NULL); \
122 tex_printf("%s", filetypes_left[left]); \
123 tex_printf("%s", (unsigned char *) name); \
126 /* (void) run_callback(report_id, "dS->",left,(unsigned char *) fullnameoffile); */ \
127 (void) run_callback(report_id, "dS->",left,name); \
132 #define report_stop_file(right) do { \
133 if (tracefilenames) { \
134 int report_id = callback_defined(stop_file_callback); \
135 if (report_id == 0) { \
136 tex_printf("%s", filetypes_right[right]); \
138 (void) run_callback(report_id, "d->",right); \