Update doc/NEWS file
[midnight-commander.git] / lib / global.h
blobbd77bbdf1a4548808df4b49e3365058ae3e0d2b3
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 #if defined(__QNX__) && !defined(__QNXNTO__)
62 /* exec*() from <process.h> */
63 #include <unix.h>
64 #endif
66 #include <glib.h>
67 #include "glibcompat.h"
69 /* Solaris9 doesn't have PRIXMAX */
70 #ifndef PRIXMAX
71 #define PRIXMAX PRIxMAX
72 #endif
74 #ifdef ENABLE_NLS
75 #include <libintl.h>
76 #define _(String) gettext (String)
77 #ifdef gettext_noop
78 #define N_(String) gettext_noop (String)
79 #else
80 #define N_(String) (String)
81 #endif
82 #else /* Stubs that do something close enough. */
83 #define textdomain(String) 1
84 #define gettext(String) (String)
85 #define ngettext(String1,String2,Num) (((Num) == 1) ? (String1) : (String2))
86 #define dgettext(Domain,Message) (Message)
87 #define dcgettext(Domain,Message,Type) (Message)
88 #define bindtextdomain(Domain,Directory) 1
89 #define _(String) (String)
90 #define N_(String) (String)
91 #endif /* !ENABLE_NLS */
93 #include "fs.h"
94 #include "shell.h"
95 #include "mcconfig.h"
97 #ifdef USE_MAINTAINER_MODE
98 #include "lib/logging.h"
99 #endif
101 /* Just for keeping Your's brains from invention a proper size of the buffer :-) */
102 #define BUF_10K 10240L
103 #define BUF_8K 8192L
104 #define BUF_4K 4096L
105 #define BUF_1K 1024L
107 #define BUF_LARGE BUF_1K
108 #define BUF_MEDIUM 512
109 #define BUF_SMALL 128
110 #define BUF_TINY 64
112 /* ESC_CHAR is defined in /usr/include/langinfo.h in some systems */
113 #ifdef ESC_CHAR
114 #undef ESC_CHAR
115 #endif
116 /* AIX compiler doesn't understand '\e' */
117 #define ESC_CHAR '\033'
118 #define ESC_STR "\033"
120 /* OS specific defines */
121 #define PATH_SEP '/'
122 #define PATH_SEP_STR "/"
123 #define IS_PATH_SEP(c) ((c) == PATH_SEP)
124 #define PATH_ENV_SEP ':'
125 #define TMPDIR_DEFAULT "/tmp"
126 #define SCRIPT_SUFFIX ""
127 #define get_default_editor() "vi"
128 #define OS_SORT_CASE_SENSITIVE_DEFAULT TRUE
129 #define UTF8_CHAR_LEN 6
131 /* struct stat members */
132 #ifdef __APPLE__
133 #define st_atim st_atimespec
134 #define st_ctim st_ctimespec
135 #define st_mtim st_mtimespec
136 #endif
138 /* Used to distinguish between a normal MC termination and */
139 /* one caused by typing 'exit' or 'logout' in the subshell */
140 #define SUBSHELL_EXIT 128
142 #define MC_ERROR g_quark_from_static_string (PACKAGE)
144 #define DEFAULT_CHARSET "ASCII"
146 /*** enums ***************************************************************************************/
148 /* run mode and params */
149 typedef enum
151 MC_RUN_FULL = 0,
152 MC_RUN_EDITOR,
153 MC_RUN_VIEWER,
154 MC_RUN_DIFFVIEWER
155 } mc_run_mode_t;
157 /*** structures declarations (and typedefs of structures)*****************************************/
159 typedef struct
161 const char *mc_version;
163 mc_run_mode_t mc_run_mode;
164 gboolean run_from_parent_mc;
165 /* Used so that widgets know if they are being destroyed or shut down */
166 gboolean midnight_shutdown;
168 /* sysconfig_dir: Area for default settings from maintainers of distributuves
169 default is /etc/mc or may be defined by MC_DATADIR */
170 char *sysconfig_dir;
171 /* share_data_dir: Area for default settings from developers */
172 char *share_data_dir;
174 mc_config_t *main_config;
175 mc_config_t *panels_config;
177 #ifdef HAVE_CHARSET
178 /* Numbers of (file I/O) and (input/display) codepages. -1 if not selected */
179 int source_codepage;
180 int display_codepage;
181 #else
182 /* If true, allow characters in the range 160-255 */
183 gboolean eight_bit_clean;
185 * If true, also allow characters in the range 128-159.
186 * This is reported to break on many terminals (xterm, qansi-m).
188 gboolean full_eight_bits;
189 #endif /* !HAVE_CHARSET */
191 * If utf-8 terminal utf8_display = TRUE
192 * Display bits set UTF-8
194 gboolean utf8_display;
196 /* Set if the nice message (hint) bar is visible */
197 gboolean message_visible;
198 /* Set if the nice and useful keybar is visible */
199 gboolean keybar_visible;
201 #ifdef ENABLE_BACKGROUND
202 /* If true, this is a background process */
203 gboolean we_are_background;
204 #endif /* ENABLE_BACKGROUND */
206 struct
208 /* Asks for confirmation before clean up of history */
209 gboolean confirm_history_cleanup;
211 /* Set if you want the possible completions dialog for the first time */
212 gboolean show_all_if_ambiguous;
214 /* Ugly hack in order to distinguish between left and right panel in menubar */
215 /* Set if the command is being run from the "Right" menu */
216 gboolean is_right; /* If the selected menu was the right */
217 } widget;
219 /* The user's shell */
220 mc_shell_t *shell;
222 struct
224 /* Use the specified skin */
225 char *skin;
226 /* Dialog window and frop down menu have a shadow */
227 gboolean shadows;
229 char *setup_color_string;
230 char *term_color_string;
231 char *color_terminal_string;
232 /* colors specified on the command line: they override any other setting */
233 char *command_line_colors;
235 #ifndef LINUX_CONS_SAVER_C
236 /* Used only in mc, not in cons.saver */
237 char console_flag;
238 #endif /* !LINUX_CONS_SAVER_C */
239 /* If using a subshell for evaluating commands this is true */
240 gboolean use_subshell;
242 #ifdef ENABLE_SUBSHELL
243 /* File descriptors of the pseudoterminal used by the subshell */
244 int subshell_pty;
245 #endif /* !ENABLE_SUBSHELL */
247 /* This flag is set by xterm detection routine in function main() */
248 /* It is used by function toggle_subshell() */
249 gboolean xterm_flag;
251 /* disable x11 support */
252 gboolean disable_x11;
254 /* For slow terminals */
255 /* If true lines are shown by spaces */
256 gboolean slow_terminal;
258 /* Set to force black and white display at program startup */
259 gboolean disable_colors;
261 /* If true use +, -, | for line drawing */
262 gboolean ugly_line_drawing;
264 /* Tries to use old highlight mouse tracking */
265 gboolean old_mouse;
267 /* If true, use + and \ keys normally and select/unselect do if M-+ / M-\.
268 and M-- and keypad + / - */
269 gboolean alternate_plus_minus;
270 } tty;
272 struct
274 /* Set when cd symlink following is desirable (bash mode) */
275 gboolean cd_symlinks;
277 /* Preallocate space before file copying */
278 gboolean preallocate_space;
280 } vfs;
281 } mc_global_t;
283 /*** global variables defined in .c file *********************************************************/
285 extern mc_global_t mc_global;
287 /*** declarations of public functions ************************************************************/
289 /*** inline functions ****************************************************************************/
290 #endif