Ticket 3948: can't create network link from panel...
[midnight-commander.git] / lib / global.h
blob7f0b65c6caa19871b8f4136801970d31bf3144ed
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 /* struct stat members */
141 #ifdef __APPLE__
142 #define st_atim st_atimespec
143 #define st_ctim st_ctimespec
144 #define st_mtim st_mtimespec
145 #endif
147 /* Used to distinguish between a normal MC termination and */
148 /* one caused by typing 'exit' or 'logout' in the subshell */
149 #define SUBSHELL_EXIT 128
151 #define MC_ERROR g_quark_from_static_string (PACKAGE)
153 #define DEFAULT_CHARSET "ASCII"
155 #include "lib/timer.h" /* mc_timer_t */
157 /*** enums ***************************************************************************************/
159 /* run mode and params */
160 typedef enum
162 MC_RUN_FULL = 0,
163 MC_RUN_EDITOR,
164 MC_RUN_VIEWER,
165 MC_RUN_DIFFVIEWER
166 } mc_run_mode_t;
168 /*** structures declarations (and typedefs of structures)*****************************************/
170 typedef struct
172 mc_run_mode_t mc_run_mode;
173 /* global timer */
174 mc_timer_t *timer;
175 /* Used so that widgets know if they are being destroyed or shut down */
176 gboolean midnight_shutdown;
178 /* sysconfig_dir: Area for default settings from maintainers of distributuves
179 default is /etc/mc or may be defined by MC_DATADIR */
180 char *sysconfig_dir;
181 /* share_data_dir: Area for default settings from developers */
182 char *share_data_dir;
184 mc_config_t *main_config;
185 mc_config_t *panels_config;
187 #ifdef HAVE_CHARSET
188 /* Numbers of (file I/O) and (input/display) codepages. -1 if not selected */
189 int source_codepage;
190 int display_codepage;
191 #else
192 /* If true, allow characters in the range 160-255 */
193 gboolean eight_bit_clean;
195 * If true, also allow characters in the range 128-159.
196 * This is reported to break on many terminals (xterm, qansi-m).
198 gboolean full_eight_bits;
199 #endif /* !HAVE_CHARSET */
201 * If utf-8 terminal utf8_display = TRUE
202 * Display bits set UTF-8
204 gboolean utf8_display;
206 /* Set if the nice message (hint) bar is visible */
207 int message_visible;
208 /* Set if the nice and useful keybar is visible */
209 int keybar_visible;
211 #ifdef ENABLE_BACKGROUND
212 /* If true, this is a background process */
213 gboolean we_are_background;
214 #endif /* ENABLE_BACKGROUND */
216 struct
218 /* Asks for confirmation before clean up of history */
219 gboolean confirm_history_cleanup;
221 /* Set if you want the possible completions dialog for the first time */
222 gboolean show_all_if_ambiguous;
224 /* Ugly hack in order to distinguish between left and right panel in menubar */
225 /* Set if the command is being run from the "Right" menu */
226 gboolean is_right; /* If the selected menu was the right */
227 } widget;
229 /* The user's shell */
230 mc_shell_t *shell;
232 struct
234 /* Use the specified skin */
235 char *skin;
237 char *setup_color_string;
238 char *term_color_string;
239 char *color_terminal_string;
240 /* colors specified on the command line: they override any other setting */
241 char *command_line_colors;
243 #ifndef LINUX_CONS_SAVER_C
244 /* Used only in mc, not in cons.saver */
245 char console_flag;
246 #endif /* !LINUX_CONS_SAVER_C */
247 /* If using a subshell for evaluating commands this is true */
248 gboolean use_subshell;
250 #ifdef ENABLE_SUBSHELL
251 /* File descriptors of the pseudoterminal used by the subshell */
252 int subshell_pty;
253 #endif /* !ENABLE_SUBSHELL */
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