beta-0.89.2
[luatex.git] / source / texk / web2c / luatexdir / luatexcallbackids.h
blobe201028207574170c0803da26226c410030d2d46
1 /* luatexcallbackids.h
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
24 typedef enum {
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,
46 define_font_callback,
47 pre_output_filter_callback,
48 buildpage_filter_callback,
49 hpack_filter_callback, vpack_filter_callback,
50 char_exists_callback,
51 hyphenate_callback,
52 ligaturing_callback,
53 kerning_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,
61 pre_dump_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 total_callbacks
68 } callback_callback_types;
70 /* lcallbacklib.c */
72 extern int callback_set[];
74 # define callback_defined(a) callback_set[a]
75 /* # define callback_defined(a) debug_callback_defined(a) */
77 extern int lua_active;
79 extern int debug_callback_defined(int i);
81 extern int run_callback(int i, const char *values, ...);
82 extern int run_saved_callback(int i, const char *name, const char *values, ...);
83 extern int run_and_save_callback(int i, const char *values, ...);
84 extern void destroy_saved_callback(int i);
86 extern void get_saved_lua_boolean(int i, const char *name, boolean * target);
87 extern void get_saved_lua_number(int i, const char *name, int *target);
88 extern void get_saved_lua_string(int i, const char *name, char **target);
90 extern void get_lua_boolean(const char *table, const char *name, boolean * target);
91 extern void get_lua_number(const char *table, const char *name, int *target);
92 extern void get_lua_string(const char *table, const char *name, char **target);
94 extern int lua_reader_callback(int callback_id, pointer *buffloc);
96 extern char *get_lua_name(int i);
98 /* texfileio.c */
99 extern char *luatex_find_file(const char *s, int callback_index);
100 extern int readbinfile(FILE * f, unsigned char **b, int *s);
102 #define filetype_unknown 0
103 #define filetype_tex 1
104 #define filetype_map 2
105 #define filetype_image 3
106 #define filetype_subset 4
107 #define filetype_font 5
109 static const char *const filetypes_left[] = { "?", "(", "{", "<", "<", "<<" } ;
110 static const char *const filetypes_right[] = { "?", ")", "}", ">", ">", ">>" } ;
112 #define report_start_file(left,name) do { \
113 if (tracefilenames) { \
114 int report_id = callback_defined(start_file_callback); \
115 if (report_id == 0) { \
116 if (left == 1) { \
117 /* we only do this for traditional name reporting, normally name is iname */ \
118 if (term_offset + strlen(name) > max_print_line - 2) \
119 print_ln(); \
120 else if ((term_offset > 0) || (file_offset > 0)) \
121 print_char(' '); \
122 tex_printf("%s", filetypes_left[left]); \
123 tprint_file_name(NULL, (unsigned char *) name, NULL); \
124 } else { \
125 tex_printf("%s", filetypes_left[left]); \
126 tex_printf("%s", (unsigned char *) name); \
128 } else { \
129 /* (void) run_callback(report_id, "dS->",left,(unsigned char *) fullnameoffile); */ \
130 (void) run_callback(report_id, "dS->",left,name); \
133 } while (0)
135 #define report_stop_file(right) do { \
136 if (tracefilenames) { \
137 int report_id = callback_defined(stop_file_callback); \
138 if (report_id == 0) { \
139 tex_printf("%s", filetypes_right[right]); \
140 } else { \
141 (void) run_callback(report_id, "d->",right); \
144 } while (0)
146 #endif