Merge branch '3906_zstd'
[midnight-commander.git] / lib / global.h
blob96b20f2e37a0a8942fd68b8d31d0ecdd8089d986
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 #ifdef HAVE_FUNC_ATTRIBUTE_FALLTHROUGH
31 #define MC_FALLTHROUGH __attribute__((fallthrough))
32 #else
33 #define MC_FALLTHROUGH
34 #endif
36 /*** typedefs(not structures) and defined constants **********************************************/
38 /* The O_BINARY definition was taken from gettext */
39 #if !defined O_BINARY && defined _O_BINARY
40 /* For MSC-compatible compilers. */
41 #define O_BINARY _O_BINARY
42 #endif
43 #ifdef __BEOS__
44 /* BeOS 5 has O_BINARY, but is has no effect. */
45 #undef O_BINARY
46 #endif
47 /* On reasonable systems, binary I/O is the default. */
48 #ifndef O_BINARY
49 #define O_BINARY 0
50 #endif
52 /* Replacement for O_NONBLOCK */
53 #ifndef O_NONBLOCK
54 #ifdef O_NDELAY /* SYSV */
55 #define O_NONBLOCK O_NDELAY
56 #else /* BSD */
57 #define O_NONBLOCK FNDELAY
58 #endif /* !O_NDELAY */
59 #endif /* !O_NONBLOCK */
61 #ifdef HAVE_SYS_SELECT_H
62 #include <sys/select.h>
63 #endif
65 #if defined(__QNX__) && !defined(__QNXNTO__)
66 /* exec*() from <process.h> */
67 #include <unix.h>
68 #endif
70 #include <glib.h>
71 #include "glibcompat.h"
73 /* For SMB VFS only */
74 #ifndef __GNUC__
75 #define __attribute__(x)
76 #endif
78 /* Solaris9 doesn't have PRIXMAX */
79 #ifndef PRIXMAX
80 #define PRIXMAX PRIxMAX
81 #endif
83 #ifdef ENABLE_NLS
84 #include <libintl.h>
85 #define _(String) gettext (String)
86 #ifdef gettext_noop
87 #define N_(String) gettext_noop (String)
88 #else
89 #define N_(String) (String)
90 #endif
91 #else /* Stubs that do something close enough. */
92 #define textdomain(String) 1
93 #define gettext(String) (String)
94 #define ngettext(String1,String2,Num) (((Num) == 1) ? (String1) : (String2))
95 #define dgettext(Domain,Message) (Message)
96 #define dcgettext(Domain,Message,Type) (Message)
97 #define bindtextdomain(Domain,Directory) 1
98 #define _(String) (String)
99 #define N_(String) (String)
100 #endif /* !ENABLE_NLS */
102 #include "fs.h"
103 #include "shell.h"
104 #include "mcconfig.h"
106 #ifdef USE_MAINTAINER_MODE
107 #include "lib/logging.h"
108 #endif
110 /* Just for keeping Your's brains from invention a proper size of the buffer :-) */
111 #define BUF_10K 10240L
112 #define BUF_8K 8192L
113 #define BUF_4K 4096L
114 #define BUF_1K 1024L
116 #define BUF_LARGE BUF_1K
117 #define BUF_MEDIUM 512
118 #define BUF_SMALL 128
119 #define BUF_TINY 64
121 /* ESC_CHAR is defined in /usr/include/langinfo.h in some systems */
122 #ifdef ESC_CHAR
123 #undef ESC_CHAR
124 #endif
125 /* AIX compiler doesn't understand '\e' */
126 #define ESC_CHAR '\033'
127 #define ESC_STR "\033"
129 /* OS specific defines */
130 #define PATH_SEP '/'
131 #define PATH_SEP_STR "/"
132 #define IS_PATH_SEP(c) ((c) == PATH_SEP)
133 #define PATH_ENV_SEP ':'
134 #define TMPDIR_DEFAULT "/tmp"
135 #define SCRIPT_SUFFIX ""
136 #define get_default_editor() "vi"
137 #define OS_SORT_CASE_SENSITIVE_DEFAULT TRUE
138 #define UTF8_CHAR_LEN 6
140 /* Used to distinguish between a normal MC termination and */
141 /* one caused by typing 'exit' or 'logout' in the subshell */
142 #define SUBSHELL_EXIT 128
144 #define MC_ERROR g_quark_from_static_string (PACKAGE)
146 #define DEFAULT_CHARSET "ASCII"
148 #include "lib/timer.h" /* mc_timer_t */
150 /*** enums ***************************************************************************************/
152 /* run mode and params */
153 typedef enum
155 MC_RUN_FULL = 0,
156 MC_RUN_EDITOR,
157 MC_RUN_VIEWER,
158 MC_RUN_DIFFVIEWER
159 } mc_run_mode_t;
161 /*** structures declarations (and typedefs of structures)*****************************************/
163 typedef struct
165 mc_run_mode_t mc_run_mode;
166 /* global timer */
167 mc_timer_t *timer;
168 /* Used so that widgets know if they are being destroyed or shut down */
169 gboolean midnight_shutdown;
171 /* sysconfig_dir: Area for default settings from maintainers of distributuves
172 default is /etc/mc or may be defined by MC_DATADIR */
173 char *sysconfig_dir;
174 /* share_data_dir: Area for default settings from developers */
175 char *share_data_dir;
177 mc_config_t *main_config;
178 mc_config_t *panels_config;
180 #ifdef HAVE_CHARSET
181 /* Numbers of (file I/O) and (input/display) codepages. -1 if not selected */
182 int source_codepage;
183 int display_codepage;
184 #else
185 /* If true, allow characters in the range 160-255 */
186 gboolean eight_bit_clean;
188 * If true, also allow characters in the range 128-159.
189 * This is reported to break on many terminals (xterm, qansi-m).
191 gboolean full_eight_bits;
192 #endif /* !HAVE_CHARSET */
194 * If utf-8 terminal utf8_display = TRUE
195 * Display bits set UTF-8
197 gboolean utf8_display;
199 /* Set if the nice message (hint) bar is visible */
200 int message_visible;
201 /* Set if the nice and useful keybar is visible */
202 int keybar_visible;
204 #ifdef ENABLE_BACKGROUND
205 /* If true, this is a background process */
206 gboolean we_are_background;
207 #endif /* ENABLE_BACKGROUND */
209 struct
211 /* Asks for confirmation before clean up of history */
212 gboolean confirm_history_cleanup;
214 /* Set if you want the possible completions dialog for the first time */
215 gboolean show_all_if_ambiguous;
217 /* Ugly hack in order to distinguish between left and right panel in menubar */
218 /* Set if the command is being run from the "Right" menu */
219 gboolean is_right; /* If the selected menu was the right */
220 } widget;
222 /* The user's shell */
223 mc_shell_t *shell;
225 struct
227 /* Use the specified skin */
228 char *skin;
230 char *setup_color_string;
231 char *term_color_string;
232 char *color_terminal_string;
233 /* colors specified on the command line: they override any other setting */
234 char *command_line_colors;
236 #ifndef LINUX_CONS_SAVER_C
237 /* Used only in mc, not in cons.saver */
238 char console_flag;
239 #endif /* !LINUX_CONS_SAVER_C */
240 /* If using a subshell for evaluating commands this is true */
241 gboolean use_subshell;
243 #ifdef ENABLE_SUBSHELL
244 /* File descriptors of the pseudoterminal used by the subshell */
245 int subshell_pty;
246 #endif /* !ENABLE_SUBSHELL */
248 /* This flag is set by xterm detection routine in function main() */
249 /* It is used by function view_other_cmd() */
250 gboolean xterm_flag;
252 /* disable x11 support */
253 gboolean disable_x11;
255 /* For slow terminals */
256 /* If true lines are shown by spaces */
257 gboolean slow_terminal;
259 /* Set to force black and white display at program startup */
260 gboolean disable_colors;
262 /* If true use +, -, | for line drawing */
263 gboolean ugly_line_drawing;
265 /* Tries to use old highlight mouse tracking */
266 gboolean old_mouse;
268 /* If true, use + and \ keys normally and select/unselect do if M-+ / M-\.
269 and M-- and keypad + / - */
270 gboolean alternate_plus_minus;
272 /* Set if the window has changed it's size */
273 SIG_ATOMIC_VOLATILE_T winch_flag;
274 } tty;
276 struct
278 /* Set when cd symlink following is desirable (bash mode) */
279 gboolean cd_symlinks;
281 /* Preallocate space before file copying */
282 gboolean preallocate_space;
284 } vfs;
285 } mc_global_t;
287 /*** global variables defined in .c file *********************************************************/
289 extern mc_global_t mc_global;
291 /*** declarations of public functions ************************************************************/
293 /*** inline functions ****************************************************************************/
294 #endif