Upx_Doxygen
https://github.com/upx/upx
console.h
1 /* console.h --
2 
3  This file is part of the UPX executable compressor.
4 
5  Copyright (C) 1996-2016 Markus Franz Xaver Johannes Oberhumer
6  Copyright (C) 1996-2016 Laszlo Molnar
7  All Rights Reserved.
8 
9  UPX and the UCL library are free software; you can redistribute them
10  and/or modify them under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of
12  the License, or (at your option) any later version.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; see the file COPYING.
21  If not, write to the Free Software Foundation, Inc.,
22  59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 
24  Markus F.X.J. Oberhumer Laszlo Molnar
25  <markus@oberhumer.com> <ezerotven+github@gmail.com>
26  */
27 
28 
29 
30 /*************************************************************************
31 //
32 **************************************************************************/
33 
34 #undef USE_CONSOLE
35 #undef USE_ANSI
36 #undef USE_SCREEN
37 #undef USE_SCREEN_CURSES
38 #undef USE_SCREEN_VCSA
39 #undef USE_SCREEN_WIN32
40 #undef USE_FRAMES
41 
42 #if 1 && (WITH_GUI) && !defined(NO_CONSOLE)
43 # define NO_CONSOLE 1
44 #endif
45 
46 #if 1 && defined(__linux__)
47 # define USE_SCREEN 1
48 # define USE_SCREEN_VCSA 1
49 # if !(HAVE_LINUX_KD_H)
50 # undef USE_SCREEN
51 # undef USE_SCREEN_VCSA
52 # endif
53 # if !(HAVE_LINUX_KDEV_T_H) || !(HAVE_LINUX_MAJOR_H)
54 # undef USE_SCREEN
55 # undef USE_SCREEN_VCSA
56 # endif
57 #endif
58 
59 #if 1 && defined(__DJGPP__)
60 # define USE_SCREEN 1
61 #elif 1 && (ACC_OS_CYGWIN || ACC_OS_WIN32 || ACC_OS_WIN64)
62 # define USE_SCREEN 1
63 # define USE_SCREEN_WIN32 1
64 #elif 1 && (ACC_OS_EMX && defined(__RSXNT__))
65 # define USE_SCREEN 1
66 # define USE_SCREEN_WIN32 1
67 #endif
68 
69 
70 #if 0 || (NO_ANSI)
71 # undef USE_ANSI
72 #endif
73 #if 0 || (NO_SCREEN)
74 # undef USE_SCREEN
75 #endif
76 #if 0 || (NO_FRAMES) || !(USE_SCREEN)
77 # undef USE_FRAMES
78 #endif
79 #if 1
80 # undef USE_FRAMES
81 #endif
82 
83 
84 #if 0 || (USE_ANSI) || (USE_SCREEN)
85 # define USE_CONSOLE 1
86 #endif
87 
88 #if 0 || (NO_CONSOLE) || !(USE_CONSOLE)
89 # undef USE_CONSOLE
90 # undef USE_ANSI
91 # undef USE_SCREEN
92 # undef USE_SCREEN_VCSA
93 # undef USE_SCREEN_CURSES
94 # undef USE_FRAMES
95 #endif
96 
97 
98 /*************************************************************************
99 //
100 **************************************************************************/
101 
102 enum {
103  CON_INIT,
104  CON_NONE,
105  CON_FILE,
106  CON_ANSI_MONO,
107  CON_ANSI_COLOR,
108  CON_SCREEN,
109  CON_UNUSED
110 };
111 
112 
113 #if (USE_CONSOLE)
114 
115 typedef struct
116 {
117  int (*init)(FILE *f, int, int);
118  int (*set_fg)(FILE *f, int fg);
119  void (*print0)(FILE *f, const char *s);
120  bool (*intro)(FILE *f);
121 }
122 console_t;
123 
124 
125 #if defined(__GNUC__)
126 void __acc_cdecl_va con_fprintf(FILE *f, const char *format, ...)
127  __attribute__((__format__(printf,2,3)));
128 #else
129 void __acc_cdecl_va con_fprintf(FILE *f, const char *format, ...);
130 #endif
131 
132 
133 #define FG_BLACK 0x00
134 #define FG_BLUE 0x01
135 #define FG_GREEN 0x02
136 #define FG_CYAN 0x03
137 #define FG_RED 0x04
138 #define FG_VIOLET 0x05
139 #define FG_ORANGE 0x06
140 #define FG_LTGRAY 0x07
141 #define FG_DKGRAY 0x08
142 #define FG_BRTBLUE 0x09
143 #define FG_BRTGREEN 0x0a
144 #define FG_BRTCYAN 0x0b
145 #define FG_BRTRED 0x0c
146 #define FG_BRTVIOLET 0x0d
147 #define FG_YELLOW 0x0e
148 #define FG_WHITE 0x0f
149 
150 #define BG_BLACK 0x00
151 #define BG_BLUE 0x10
152 #define BG_GREEN 0x20
153 #define BG_CYAN 0x30
154 #define BG_RED 0x40
155 #define BG_VIOLET 0x50
156 #define BG_ORANGE 0x60
157 #define BG_WHITE 0x70
158 
159 #endif /* USE_CONSOLE */
160 
161 
162 /*************************************************************************
163 //
164 **************************************************************************/
165 
166 extern FILE *con_term;
167 
168 #if (USE_CONSOLE)
169 
170 extern int con_mode;
171 extern console_t *con;
172 
173 extern console_t console_init;
174 extern console_t console_none;
175 extern console_t console_file;
176 extern console_t console_ansi_mono;
177 extern console_t console_ansi_color;
178 extern console_t console_screen;
179 
180 
181 #define con_fg(f,x) con->set_fg(f,x)
182 
183 #else
184 
185 #define con_fg(f,x) 0
186 #define con_fprintf fprintf
187 
188 #endif /* USE_CONSOLE */
189 
190 /* vim:set ts=4 sw=4 et: */