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