Use #ifdef for autoconf provided marcos...
[midnight-commander.git] / lib / global.h
blob0e7b8b64a22ed2184231ca441bb236fbd808fb2d
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 sig_atomic_t */
25 #include <signal.h>
27 /*** typedefs(not structures) and defined constants **********************************************/
29 /* The O_BINARY definition was taken from gettext */
30 #if !defined O_BINARY && defined _O_BINARY
31 /* For MSC-compatible compilers. */
32 #define O_BINARY _O_BINARY
33 #endif
34 #ifdef __BEOS__
35 /* BeOS 5 has O_BINARY, but is has no effect. */
36 #undef O_BINARY
37 #endif
38 /* On reasonable systems, binary I/O is the default. */
39 #ifndef O_BINARY
40 #define O_BINARY 0
41 #endif
43 /* Replacement for O_NONBLOCK */
44 #ifndef O_NONBLOCK
45 #ifdef O_NDELAY /* SYSV */
46 #define O_NONBLOCK O_NDELAY
47 #else /* BSD */
48 #define O_NONBLOCK FNDELAY
49 #endif /* !O_NDELAY */
50 #endif /* !O_NONBLOCK */
52 #ifdef HAVE_SYS_SELECT_H
53 #include <sys/select.h>
54 #endif
56 #if defined(__QNX__) && !defined(__QNXNTO__)
57 /* exec*() from <process.h> */
58 #include <unix.h>
59 #endif
61 #include <glib.h>
62 #include "glibcompat.h"
64 #ifndef __GNUC__
65 #define __attribute__(x)
66 #endif
68 /* Solaris9 doesn't have PRIXMAX */
69 #ifndef PRIXMAX
70 #define PRIXMAX PRIxMAX
71 #endif
73 #ifdef ENABLE_NLS
74 #include <libintl.h>
75 #define _(String) gettext (String)
76 #ifdef gettext_noop
77 #define N_(String) gettext_noop (String)
78 #else
79 #define N_(String) (String)
80 #endif
81 #else /* Stubs that do something close enough. */
82 #define textdomain(String) 1
83 #define gettext(String) (String)
84 #define ngettext(String1,String2,Num) (((Num) == 1) ? (String1) : (String2))
85 #define dgettext(Domain,Message) (Message)
86 #define dcgettext(Domain,Message,Type) (Message)
87 #define bindtextdomain(Domain,Directory) 1
88 #define _(String) (String)
89 #define N_(String) (String)
90 #endif /* !ENABLE_NLS */
92 #include "fs.h"
94 #ifdef USE_MAINTAINER_MODE
95 #include "lib/logging.h"
96 #endif
98 #ifdef min
99 #undef min
100 #endif
102 #ifdef max
103 #undef max
104 #endif
106 #define min(x, y) ((x) > (y) ? (y) : (x))
107 #define max(x, y) ((x) > (y) ? (x) : (y))
109 /* Just for keeping Your's brains from invention a proper size of the buffer :-) */
110 #define BUF_10K 10240L
111 #define BUF_8K 8192L
112 #define BUF_4K 4096L
113 #define BUF_1K 1024L
115 #define BUF_LARGE BUF_1K
116 #define BUF_MEDIUM 512
117 #define BUF_SMALL 128
118 #define BUF_TINY 64
120 /* ESC_CHAR is defined in /usr/include/langinfo.h in some systems */
121 #ifdef ESC_CHAR
122 #undef ESC_CHAR
123 #endif
124 /* AIX compiler doesn't understand '\e' */
125 #define ESC_CHAR '\033'
126 #define ESC_STR "\033"
128 /* OS specific defines */
129 #define PATH_SEP '/'
130 #define PATH_SEP_STR "/"
131 #define IS_PATH_SEP(c) ((c) == PATH_SEP)
132 #define PATH_ENV_SEP ':'
133 #define TMPDIR_DEFAULT "/tmp"
134 #define SCRIPT_SUFFIX ""
135 #define get_default_editor() "vi"
136 #define OS_SORT_CASE_SENSITIVE_DEFAULT 1
137 #define UTF8_CHAR_LEN 6
139 /* Used to distinguish between a normal MC termination and */
140 /* one caused by typing 'exit' or 'logout' in the subshell */
141 #define SUBSHELL_EXIT 128
143 /* C++ style type casts */
144 #define const_cast(m_type, m_expr) ((m_type) (m_expr))
146 #if 0
147 #ifdef MC_ENABLE_DEBUGGING_CODE
148 #undef NDEBUG
149 #else
150 #define NDEBUG
151 #endif
152 #ifdef HAVE_ASSERT_H
153 #include <assert.h>
154 #endif
155 #endif
157 #define MC_ERROR g_quark_from_static_string (PACKAGE)
159 #define DEFAULT_CHARSET "ASCII"
161 /*** enums ***************************************************************************************/
163 /* run mode and params */
164 typedef enum
166 MC_RUN_FULL = 0,
167 MC_RUN_EDITOR,
168 MC_RUN_VIEWER,
169 MC_RUN_DIFFVIEWER
170 } mc_run_mode_t;
172 /*** structures declarations (and typedefs of structures)*****************************************/
174 typedef struct
176 mc_run_mode_t mc_run_mode;
177 /* global timer */
178 struct mc_timer_t *timer;
179 /* Used so that widgets know if they are being destroyed or shut down */
180 gboolean midnight_shutdown;
182 /* sysconfig_dir: Area for default settings from maintainers of distributuves
183 default is /etc/mc or may be defined by MC_DATADIR */
184 char *sysconfig_dir;
185 /* share_data_dir: Area for default settings from developers */
186 char *share_data_dir;
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 struct
232 /* Use the specified skin */
233 char *skin;
235 char *setup_color_string;
236 char *term_color_string;
237 char *color_terminal_string;
238 /* colors specified on the command line: they override any other setting */
239 char *command_line_colors;
241 #ifndef LINUX_CONS_SAVER_C
242 /* Used only in mc, not in cons.saver */
243 char console_flag;
244 #endif /* !LINUX_CONS_SAVER_C */
245 /* If using a subshell for evaluating commands this is true */
246 gboolean use_subshell;
247 #ifdef ENABLE_SUBSHELL
248 /* File descriptors of the pseudoterminal used by the subshell */
249 int subshell_pty;
250 #endif /* !ENABLE_SUBSHELL */
252 /* The user's shell */
253 char *shell;
255 /* This flag is set by xterm detection routine in function main() */
256 /* It is used by function view_other_cmd() */
257 gboolean xterm_flag;
259 /* disable x11 support */
260 gboolean disable_x11;
262 /* For slow terminals */
263 /* If true lines are shown by spaces */
264 gboolean slow_terminal;
266 /* Set to force black and white display at program startup */
267 gboolean disable_colors;
269 /* If true use +, -, | for line drawing */
270 gboolean ugly_line_drawing;
272 /* Tries to use old highlight mouse tracking */
273 gboolean old_mouse;
275 /* If true, use + and \ keys normally and select/unselect do if M-+ / M-\.
276 and M-- and keypad + / - */
277 gboolean alternate_plus_minus;
279 /* Set if the window has changed it's size */
280 SIG_ATOMIC_VOLATILE_T winch_flag;
281 } tty;
283 struct
285 /* Set when cd symlink following is desirable (bash mode) */
286 gboolean cd_symlinks;
288 /* Preallocate space before file copying */
289 gboolean preallocate_space;
291 } vfs;
292 } mc_global_t;
294 /*** global variables defined in .c file *********************************************************/
296 extern mc_global_t mc_global;
298 /*** declarations of public functions ************************************************************/
300 /*** inline functions ****************************************************************************/
301 #endif