File: console.h

package info (click to toggle)
upx-ucl 3.91-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 9,448 kB
  • ctags: 12,267
  • sloc: ansic: 70,113; cpp: 40,297; asm: 22,239; python: 1,119; makefile: 1,041; sh: 16
file content (194 lines) | stat: -rw-r--r-- 4,396 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/* console.h --

   This file is part of the UPX executable compressor.

   Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
   Copyright (C) 1996-2013 Laszlo Molnar
   All Rights Reserved.

   UPX and the UCL library are free software; you can redistribute them
   and/or modify them under the terms of the GNU General Public License as
   published by the Free Software Foundation; either version 2 of
   the License, or (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; see the file COPYING.
   If not, write to the Free Software Foundation, Inc.,
   59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

   Markus F.X.J. Oberhumer              Laszlo Molnar
   <markus@oberhumer.com>               <ml1050@users.sourceforge.net>
 */



/*************************************************************************
//
**************************************************************************/

#undef USE_CONSOLE
#undef USE_ANSI
#undef USE_SCREEN
#undef USE_SCREEN_CURSES
#undef USE_SCREEN_VCSA
#undef USE_SCREEN_WIN32
#undef USE_FRAMES

#if 1 && (WITH_GUI) && !defined(NO_CONSOLE)
#  define NO_CONSOLE 1
#endif

#if 1 && defined(__linux__)
#  define USE_SCREEN 1
#  define USE_SCREEN_VCSA 1
#  if !(HAVE_LINUX_KD_H)
#    undef USE_SCREEN
#    undef USE_SCREEN_VCSA
#  endif
#  if !(HAVE_LINUX_KDEV_T_H) || !(HAVE_LINUX_MAJOR_H)
#    undef USE_SCREEN
#    undef USE_SCREEN_VCSA
#  endif
#endif

#if 1 && defined(__DJGPP__)
#  define USE_SCREEN 1
#elif 1 && (ACC_OS_CYGWIN || ACC_OS_WIN32 || ACC_OS_WIN64)
#  define USE_SCREEN 1
#  define USE_SCREEN_WIN32 1
#elif 1 && (ACC_OS_EMX && defined(__RSXNT__))
#  define USE_SCREEN 1
#  define USE_SCREEN_WIN32 1
#endif


#if 0 || (NO_ANSI)
#  undef USE_ANSI
#endif
#if 0 || (NO_SCREEN)
#  undef USE_SCREEN
#endif
#if 0 || (NO_FRAMES) || !(USE_SCREEN)
#  undef USE_FRAMES
#endif
#if 1
#  undef USE_FRAMES
#endif


#if 0 || (USE_ANSI) || (USE_SCREEN)
#  define USE_CONSOLE 1
#endif

#if 0 || (NO_CONSOLE) || !(USE_CONSOLE)
#  undef USE_CONSOLE
#  undef USE_ANSI
#  undef USE_SCREEN
#  undef USE_SCREEN_VCSA
#  undef USE_SCREEN_CURSES
#  undef USE_FRAMES
#endif


/*************************************************************************
//
**************************************************************************/

enum {
    CON_INIT,
    CON_NONE,
    CON_FILE,
    CON_ANSI_MONO,
    CON_ANSI_COLOR,
    CON_SCREEN,
    CON_UNUSED
};


#if (USE_CONSOLE)

typedef struct
{
    int (*init)(FILE *f, int, int);
    int (*set_fg)(FILE *f, int fg);
    void (*print0)(FILE *f, const char *s);
    bool (*intro)(FILE *f);
}
console_t;


#if defined(__GNUC__)
void __acc_cdecl_va con_fprintf(FILE *f, const char *format, ...)
        __attribute__((__format__(printf,2,3)));
#else
void __acc_cdecl_va con_fprintf(FILE *f, const char *format, ...);
#endif


#define FG_BLACK     0x00
#define FG_BLUE      0x01
#define FG_GREEN     0x02
#define FG_CYAN      0x03
#define FG_RED       0x04
#define FG_VIOLET    0x05
#define FG_ORANGE    0x06
#define FG_LTGRAY    0x07
#define FG_DKGRAY    0x08
#define FG_BRTBLUE   0x09
#define FG_BRTGREEN  0x0a
#define FG_BRTCYAN   0x0b
#define FG_BRTRED    0x0c
#define FG_BRTVIOLET 0x0d
#define FG_YELLOW    0x0e
#define FG_WHITE     0x0f

#define BG_BLACK     0x00
#define BG_BLUE      0x10
#define BG_GREEN     0x20
#define BG_CYAN      0x30
#define BG_RED       0x40
#define BG_VIOLET    0x50
#define BG_ORANGE    0x60
#define BG_WHITE     0x70

#endif /* USE_CONSOLE */


/*************************************************************************
//
**************************************************************************/

extern FILE *con_term;

#if (USE_CONSOLE)

extern int con_mode;
extern console_t *con;

extern console_t console_init;
extern console_t console_none;
extern console_t console_file;
extern console_t console_ansi_mono;
extern console_t console_ansi_color;
extern console_t console_screen;


#define con_fg(f,x)     con->set_fg(f,x)

#else

#define con_fg(f,x)     0
#define con_fprintf     fprintf

#endif /* USE_CONSOLE */


/*
vi:ts=4:et
*/