1 /* errors.h
2 
3    Copyright 2009 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 ERRORS_H
22 #  define ERRORS_H
23 
24 /*
25 The global variable |interaction| has four settings, representing increasing
26 amounts of user interaction:
27 */
28 
29 typedef enum {
30     batch_mode = 0,             /* omits all stops and omits terminal output */
31     nonstop_mode = 1,           /* omits all stops */
32     scroll_mode = 2,            /* omits error stops */
33     error_stop_mode = 3,        /* stops at every opportunity to interact */
34     unspecified_mode = 4,       /* extra value for command-line switch */
35 } interaction_settings;
36 
37 extern int interaction;         /* current level of interaction */
38 extern int interactionoption;   /* set from command line */
39 
40 extern void initialize_errors(void);
41 
42 extern char *last_error;
43 extern void print_err(const char *s);
44 
45 extern void fixup_selector(boolean log_opened);
46 
47 extern boolean deletions_allowed;
48 extern boolean set_box_allowed;
49 extern int history;
50 extern int error_count;
51 extern int interrupt;
52 extern boolean OK_to_interrupt;
53 
54 typedef enum {
55     spotless = 0,               /* |history| value when nothing has been amiss yet */
56     warning_issued = 1,         /* |history| value when |begin_diagnostic| has been called */
57     error_message_issued = 2,   /* |history| value when |error| has been called */
58     fatal_error_stop = 3,       /* |history| value when termination was premature */
59 } error_states;
60 
61 extern const char *help_line[7];        /* helps for the next |error| */
62 extern boolean use_err_help;    /* should the |err_help| list be shown? */
63 
64 /* these macros are just temporary, until everything is in C */
65 
66 #  define hlp1(A)           help_line[0]=A
67 #  define hlp2(A,B)         help_line[1]=A; hlp1(B)
68 #  define hlp3(A,B,C)       help_line[2]=A; hlp2(B,C)
69 #  define hlp4(A,B,C,D)     help_line[3]=A; hlp3(B,C,D)
70 #  define hlp5(A,B,C,D,E)   help_line[4]=A; hlp4(B,C,D,E)
71 #  define hlp6(A,B,C,D,E,F) help_line[5]=A; hlp5(B,C,D,E,F)
72 
73 #  define help0()                 help_line[0]=NULL     /* sometimes there might be no help */
74 #  define help1(A)           do { help_line[1]=NULL; hlp1(A);           } while (0)
75 #  define help2(A,B)         do { help_line[2]=NULL; hlp2(B,A);         } while (0)
76 #  define help3(A,B,C)       do { help_line[3]=NULL; hlp3(C,B,A);       } while (0)
77 #  define help4(A,B,C,D)     do { help_line[4]=NULL; hlp4(D,C,B,A);     } while (0)
78 #  define help5(A,B,C,D,E)   do { help_line[5]=NULL; hlp5(E,D,C,B,A);   } while (0)
79 #  define help6(A,B,C,D,E,F) do { help_line[6]=NULL; hlp6(F,E,D,C,B,A); } while (0)
80 
81 extern void do_final_end(void);
82 extern void jump_out(void);
83 extern void error(void);
84 extern void int_error(int n);
85 extern void normalize_selector(void);
86 extern void succumb(void);
87 extern void fatal_error(const char *s);
88 extern void lua_norm_error(const char *s);
89 extern void lua_fatal_error(const char *s);
90 extern void overflow(const char *s, unsigned int n);
91 extern void confusion(const char *s);
92 extern void check_interrupt(void);
93 extern void pause_for_instructions(void);
94 
95 extern void tex_error(const char *msg, const char **hlp);
96 
97 extern void back_error(void);
98 extern void ins_error(void);
99 extern void flush_err(void);
100 
101 extern void char_warning(internal_font_number f, int c);
102 
103 #endif
104