Merge branch '3607_cleanup'
[midnight-commander.git] / lib / global.h
blob34d46c8686a592b8c01ec21c7424a46b9f2475bb
1 /** \file global.h
2 * \brief Header: %global definitions for compatibility
4 * This file should be included after all system includes and before all local includes.
5 */
7 #ifndef MC_GLOBAL_H
8 #define MC_GLOBAL_H
10 #if defined(HAVE_STRING_H)
11 #include <string.h>
12 /* An ANSI string.h and pre-ANSI memory.h might conflict */
13 #elif defined(HAVE_MEMORY_H)
14 #include <memory.h>
15 #else
16 #include <strings.h>
17 /* memory and strings.h conflict on other systems */
18 #endif /* !STDC_HEADERS & !HAVE_STRING_H */
20 #ifdef HAVE_SYS_PARAM_H
21 #include <sys/param.h>
22 #endif
24 /* for O_* macros */
25 #include <fcntl.h>
27 /* for sig_atomic_t */
28 #include <signal.h>
30 /*** typedefs(not structures) and defined constants **********************************************/
32 /* The O_BINARY definition was taken from gettext */
33 #if !defined O_BINARY && defined _O_BINARY
34 /* For MSC-compatible compilers. */
35 #define O_BINARY _O_BINARY
36 #endif
37 #ifdef __BEOS__
38 /* BeOS 5 has O_BINARY, but is has no effect. */
39 #undef O_BINARY
40 #endif
41 /* On reasonable systems, binary I/O is the default. */
42 #ifndef O_BINARY
43 #define O_BINARY 0
44 #endif
46 /* Replacement for O_NONBLOCK */
47 #ifndef O_NONBLOCK
48 #ifdef O_NDELAY /* SYSV */
49 #define O_NONBLOCK O_NDELAY
50 #else /* BSD */
51 #define O_NONBLOCK FNDELAY
52 #endif /* !O_NDELAY */
53 #endif /* !O_NONBLOCK */
55 #ifdef HAVE_SYS_SELECT_H
56 #include <sys/select.h>
57 #endif
59 #if defined(__QNX__) && !defined(__QNXNTO__)
60 /* exec*() from <process.h> */
61 #include <unix.h>
62 #endif
64 #include <glib.h>
65 #include "glibcompat.h"
67 /* For SMB VFS only */
68 #ifndef __GNUC__
69 #define __attribute__(x)
70 #endif
72 /* Solaris9 doesn't have PRIXMAX */
73 #ifndef PRIXMAX
74 #define PRIXMAX PRIxMAX
75 #endif
77 #ifdef ENABLE_NLS
78 #include <libintl.h>
79 #define _(String) gettext (String)
80 #ifdef gettext_noop
81 #define N_(String) gettext_noop (String)
82 #else
83 #define N_(String) (String)
84 #endif
85 #else /* Stubs that do something close enough. */
86 #define textdomain(String) 1
87 #define gettext(String) (String)
88 #define ngettext(String1,String2,Num) (((Num) == 1) ? (String1) : (String2))
89 #define dgettext(Domain,Message) (Message)
90 #define dcgettext(Domain,Message,Type) (Message)
91 #define bindtextdomain(Domain,Directory) 1
92 #define _(String) (String)
93 #define N_(String) (String)
94 #endif /* !ENABLE_NLS */
96 #include "fs.h"
97 #include "shell.h"
98 #include "mcconfig.h"
100 #ifdef USE_MAINTAINER_MODE
101 #include "lib/logging.h"
102 #endif
104 /* Just for keeping Your's brains from invention a proper size of the buffer :-) */
105 #define BUF_10K 10240L
106 #define BUF_8K 8192L
107 #define BUF_4K 4096L
108 #define BUF_1K 1024L
110 #define BUF_LARGE BUF_1K
111 #define BUF_MEDIUM 512
112 #define BUF_SMALL 128
113 #define BUF_TINY 64
115 /* ESC_CHAR is defined in /usr/include/langinfo.h in some systems */
116 #ifdef ESC_CHAR
117 #undef ESC_CHAR
118 #endif
119 /* AIX compiler doesn't understand '\e' */
120 #define ESC_CHAR '\033'
121 #define ESC_STR "\033"
123 /* OS specific defines */
124 #define PATH_SEP '/'
125 #define PATH_SEP_STR "/"
126 #define IS_PATH_SEP(c) ((c) == PATH_SEP)
127 #define PATH_ENV_SEP ':'
128 #define TMPDIR_DEFAULT "/tmp"
129 #define SCRIPT_SUFFIX ""
130 #define get_default_editor() "vi"
131 #define OS_SORT_CASE_SENSITIVE_DEFAULT 1
132 #define UTF8_CHAR_LEN 6
134 /* Used to distinguish between a normal MC termination and */
135 /* one caused by typing 'exit' or 'logout' in the subshell */
136 #define SUBSHELL_EXIT 128
138 /* C++ style type casts */
139 #define const_cast(m_type, m_expr) ((m_type) (m_expr))
141 #if 0
142 #ifdef MC_ENABLE_DEBUGGING_CODE
143 #undef NDEBUG
144 #else
145 #define NDEBUG
146 #endif
147 #ifdef HAVE_ASSERT_H
148 #include <assert.h>
149 #endif
150 #endif
152 #define MC_ERROR g_quark_from_static_string (PACKAGE)
154 #define DEFAULT_CHARSET "ASCII"
156 #include "lib/timer.h" /* mc_timer_t */
158 /*** enums ***************************************************************************************/
160 /* run mode and params */
161 typedef enum
163 MC_RUN_FULL = 0,
164 MC_RUN_EDITOR,
165 MC_RUN_VIEWER,
166 MC_RUN_DIFFVIEWER
167 } mc_run_mode_t;
169 /*** structures declarations (and typedefs of structures)*****************************************/
171 typedef struct
173 mc_run_mode_t mc_run_mode;
174 /* global timer */
175 mc_timer_t *timer;
176 /* Used so that widgets know if they are being destroyed or shut down */
177 gboolean midnight_shutdown;
179 /* sysconfig_dir: Area for default settings from maintainers of distributuves
180 default is /etc/mc or may be defined by MC_DATADIR */
181 char *sysconfig_dir;
182 /* share_data_dir: Area for default settings from developers */
183 char *share_data_dir;
185 mc_config_t *main_config;
186 mc_config_t *panels_config;
188 #ifdef HAVE_CHARSET
189 /* Numbers of (file I/O) and (input/display) codepages. -1 if not selected */
190 int source_codepage;
191 int display_codepage;
192 #else
193 /* If true, allow characters in the range 160-255 */
194 int eight_bit_clean;
196 * If true, also allow characters in the range 128-159.
197 * This is reported to break on many terminals (xterm, qansi-m).
199 int full_eight_bits;
200 #endif /* !HAVE_CHARSET */
202 * If utf-8 terminal utf8_display = TRUE
203 * Display bits set UTF-8
205 gboolean utf8_display;
207 /* Set if the nice message (hint) bar is visible */
208 int message_visible;
209 /* Set if the nice and useful keybar is visible */
210 int keybar_visible;
212 #ifdef ENABLE_BACKGROUND
213 /* If true, this is a background process */
214 gboolean we_are_background;
215 #endif /* ENABLE_BACKGROUND */
217 struct
219 /* Asks for confirmation before clean up of history */
220 gboolean confirm_history_cleanup;
222 /* Set if you want the possible completions dialog for the first time */
223 gboolean show_all_if_ambiguous;
225 /* Ugly hack in order to distinguish between left and right panel in menubar */
226 /* Set if the command is being run from the "Right" menu */
227 gboolean is_right; /* If the selected menu was the right */
228 } widget;
230 /* The user's shell */
231 mc_shell_t *shell;
233 struct
235 /* Use the specified skin */
236 char *skin;
238 char *setup_color_string;
239 char *term_color_string;
240 char *color_terminal_string;
241 /* colors specified on the command line: they override any other setting */
242 char *command_line_colors;
244 #ifndef LINUX_CONS_SAVER_C
245 /* Used only in mc, not in cons.saver */
246 char console_flag;
247 #endif /* !LINUX_CONS_SAVER_C */
248 /* If using a subshell for evaluating commands this is true */
249 gboolean use_subshell;
251 #ifdef ENABLE_SUBSHELL
252 /* File descriptors of the pseudoterminal used by the subshell */
253 int subshell_pty;
254 #endif /* !ENABLE_SUBSHELL */
256 /* This flag is set by xterm detection routine in function main() */
257 /* It is used by function view_other_cmd() */
258 gboolean xterm_flag;
260 /* disable x11 support */
261 gboolean disable_x11;
263 /* For slow terminals */
264 /* If true lines are shown by spaces */
265 gboolean slow_terminal;
267 /* Set to force black and white display at program startup */
268 gboolean disable_colors;
270 /* If true use +, -, | for line drawing */
271 gboolean ugly_line_drawing;
273 /* Tries to use old highlight mouse tracking */
274 gboolean old_mouse;
276 /* If true, use + and \ keys normally and select/unselect do if M-+ / M-\.
277 and M-- and keypad + / - */
278 gboolean alternate_plus_minus;
280 /* Set if the window has changed it's size */
281 SIG_ATOMIC_VOLATILE_T winch_flag;
282 } tty;
284 struct
286 /* Set when cd symlink following is desirable (bash mode) */
287 gboolean cd_symlinks;
289 /* Preallocate space before file copying */
290 gboolean preallocate_space;
292 } vfs;
293 } mc_global_t;
295 /*** global variables defined in .c file *********************************************************/
297 extern mc_global_t mc_global;
299 /*** declarations of public functions ************************************************************/
301 /*** inline functions ****************************************************************************/
302 #endif