| 1 |
/* texfileio.h |
| 2 |
|
| 3 |
Copyright 2009 Taco Hoekwater <[email protected]> |
| 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 TEXFILEIO_H |
| 22 |
# define TEXFILEIO_H |
| 23 |
|
| 24 |
extern int *input_file_callback_id; |
| 25 |
extern int read_file_callback_id[17]; |
| 26 |
|
| 27 |
extern char *luatex_find_read_file(const char *s, int n, int callback_index); |
| 28 |
extern boolean luatex_open_input(FILE ** f_ptr, const char *fn, int filefmt, |
| 29 |
const_string fopen_mode, boolean must_exist); |
| 30 |
extern boolean luatex_open_output(FILE ** f_ptr, const char *fn, |
| 31 |
const_string fopen_mode); |
| 32 |
|
| 33 |
extern boolean lua_a_open_in(alpha_file * f, char *fn, int n); |
| 34 |
extern boolean lua_a_open_out(alpha_file * f, char *fn, int n); |
| 35 |
extern boolean lua_b_open_out(alpha_file * f, char *fn); |
| 36 |
extern void lua_a_close_in(alpha_file f, int n); |
| 37 |
extern void lua_a_close_out(alpha_file f); |
| 38 |
|
| 39 |
extern packed_ASCII_code *buffer; |
| 40 |
extern int first; |
| 41 |
extern int last; |
| 42 |
extern int max_buf_stack; |
| 43 |
|
| 44 |
extern boolean lua_input_ln(alpha_file f, int n, boolean bypass_eoln); |
| 45 |
|
| 46 |
/* |
| 47 |
The user's terminal acts essentially like other files of text, except |
| 48 |
that it is used both for input and for output. When the terminal is |
| 49 |
considered an input file, the file variable is called |term_in|, and when it |
| 50 |
is considered an output file the file variable is |term_out|. |
| 51 |
@^system dependencies@> |
| 52 |
*/ |
| 53 |
|
| 54 |
# define term_in stdin /* the terminal as an input file */ |
| 55 |
# define term_out stdout /* the terminal as an output file */ |
| 56 |
|
| 57 |
|
| 58 |
/* |
| 59 |
Here is how to open the terminal files. |t_open_out| does nothing. |
| 60 |
|t_open_in|, on the other hand, does the work of ``rescanning,'' or getting |
| 61 |
any command line arguments the user has provided. It's defined in C. |
| 62 |
*/ |
| 63 |
|
| 64 |
# define t_open_out() /* output already open for text output */ |
| 65 |
|
| 66 |
/* |
| 67 |
Sometimes it is necessary to synchronize the input/output mixture that |
| 68 |
happens on the user's terminal, and three system-dependent |
| 69 |
procedures are used for this |
| 70 |
purpose. The first of these, |update_terminal|, is called when we want |
| 71 |
to make sure that everything we have output to the terminal so far has |
| 72 |
actually left the computer's internal buffers and been sent. |
| 73 |
The second, |clear_terminal|, is called when we wish to cancel any |
| 74 |
input that the user may have typed ahead (since we are about to |
| 75 |
issue an unexpected error message). The third, |wake_up_terminal|, |
| 76 |
is supposed to revive the terminal if the user has disabled it by |
| 77 |
some instruction to the operating system. The following macros show how |
| 78 |
these operations can be specified with {\mc UNIX}. |update_terminal| |
| 79 |
does an |fflush|. |clear_terminal| is redefined |
| 80 |
to do nothing, since the user should control the terminal. |
| 81 |
@^system dependencies@> |
| 82 |
*/ |
| 83 |
|
| 84 |
# define update_terminal() fflush (term_out) |
| 85 |
# define clear_terminal() do { ; } while (0) |
| 86 |
# define wake_up_terminal() do { ; } while (0) /* cancel the user's cancellation of output */ |
| 87 |
|
| 88 |
extern boolean init_terminal(void); |
| 89 |
extern void term_input(void); |
| 90 |
|
| 91 |
extern str_number cur_name; |
| 92 |
extern str_number cur_area; |
| 93 |
extern str_number cur_ext; |
| 94 |
extern pool_pointer area_delimiter; |
| 95 |
extern pool_pointer ext_delimiter; |
| 96 |
|
| 97 |
extern char *pack_file_name(str_number n, str_number a, str_number e); |
| 98 |
|
| 99 |
# define file_name_size 512 |
| 100 |
|
| 101 |
# define format_area_length 0 /* length of its area part */ |
| 102 |
# define format_ext_length 4 /* length of its `\.{.fmt}' part */ |
| 103 |
# define format_extension ".fmt" |
| 104 |
/* the extension, as a constant */ |
| 105 |
|
| 106 |
extern char *TEX_format_default; |
| 107 |
|
| 108 |
extern char *open_fmt_file(void); |
| 109 |
|
| 110 |
extern boolean name_in_progress; /* is a file name being scanned? */ |
| 111 |
extern str_number job_name; /* principal file name */ |
| 112 |
extern boolean log_opened_global; /* has the transcript file been opened? */ |
| 113 |
|
| 114 |
extern unsigned char *texmf_log_name; /* full name of the log file */ |
| 115 |
|
| 116 |
extern void open_log_file(void); |
| 117 |
extern char *get_full_log_name (void); |
| 118 |
extern void start_input(void); |
| 119 |
|
| 120 |
extern int open_outfile(FILE ** f, const char *name, const char *mode); |
| 121 |
|
| 122 |
extern boolean zopen_w_input(FILE **, const char *, int, |
| 123 |
const_string fopen_mode); |
| 124 |
extern boolean zopen_w_output(FILE **, const char *, const_string fopen_mode); |
| 125 |
extern void zwclose(FILE *); |
| 126 |
|
| 127 |
# define read_tfm_file readbinfile |
| 128 |
# define read_vf_file readbinfile |
| 129 |
# define read_data_file readbinfile |
| 130 |
|
| 131 |
extern boolean openinnameok(const_string); |
| 132 |
extern boolean openoutnameok(const_string); |
| 133 |
|
| 134 |
# ifdef WIN32 |
| 135 |
extern FILE *Poptr; |
| 136 |
# endif |
| 137 |
|
| 138 |
extern boolean open_in_or_pipe(FILE **, char *, int, const_string fopen_mode, |
| 139 |
boolean must_exist); |
| 140 |
extern boolean open_out_or_pipe(FILE **, char *, const_string fopen_mode); |
| 141 |
extern void close_file_or_pipe(FILE *); |
| 142 |
|
| 143 |
extern char *luatex_synctex_get_current_name(void); |
| 144 |
|
| 145 |
#endif |