1 /* luatexcallbackids.h 2 3 Copyright 2012 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 LUATEXCALLBACKIDS_H 22 #define LUATEXCALLBACKIDS_H 23 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 token_filter_callback, 48 pre_output_filter_callback, 49 buildpage_filter_callback, 50 hpack_filter_callback, vpack_filter_callback, 51 char_exists_callback, 52 hyphenate_callback, 53 ligaturing_callback, 54 kerning_callback, 55 pre_linebreak_filter_callback, 56 linebreak_filter_callback, 57 post_linebreak_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 pdf_stream_filter_callback, 65 total_callbacks 66 } callback_callback_types; 67 68 /* lcallbacklib.c */ 69 70 extern int callback_set[]; 71 72 # define callback_defined(a) callback_set[a] 73 /* # define callback_defined(a) debug_callback_defined(a) */ 74 75 extern int lua_active; 76 77 extern int debug_callback_defined(int i); 78 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); 83 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); 87 88 extern void get_lua_boolean(const char *table, const char *name, 89 boolean * target); 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); 92 93 extern char *get_lua_name(int i); 94 95 /* texfileio.c */ 96 extern char *luatex_find_file(const char *s, int callback_index); 97 extern int readbinfile(FILE * f, unsigned char **b, int *s); 98 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 105 106 static const char *const filetypes_left[] = { "?", "(", "{", "<", "<", "<<" } ; 107 static const char *const filetypes_right[] = { "?", ")", "}", ">", ">", ">>" } ; 108 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) { \ 113 if (left == 1) { \ 114 /* we only do this for traditional name reporting, normally name is iname */ \ 115 if (term_offset + strlen(name) > max_print_line - 2) \ 116 print_ln(); \ 117 else if ((term_offset > 0) || (file_offset > 0)) \ 118 print_char(' '); \ 119 tex_printf("%s", filetypes_left[left]); \ 120 tprint_file_name(NULL, (unsigned char *) name, NULL); \ 121 } else { \ 122 tex_printf("%s", filetypes_left[left]); \ 123 tex_printf("%s", (unsigned char *) name); \ 124 } \ 125 } else { \ 126 /* (void) run_callback(report_id, "dS->",left,(unsigned char *) fullnameoffile); */ \ 127 (void) run_callback(report_id, "dS->",left,name); \ 128 } \ 129 } \ 130 } while (0) 131 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]); \ 137 } else { \ 138 (void) run_callback(report_id, "d->",right); \ 139 } \ 140 } \ 141 } while (0) 142 143 #endif 144