2009-02-05 21:28:18 +03:00
|
|
|
/** \file global.h
|
2009-02-06 17:46:15 +03:00
|
|
|
* \brief Header: %global definitions for compatibility
|
2009-02-05 21:28:18 +03:00
|
|
|
*
|
|
|
|
* This file should be included after all system includes and before all local includes.
|
2001-09-07 20:46:31 +04:00
|
|
|
*/
|
|
|
|
|
2004-12-03 22:17:46 +03:00
|
|
|
#ifndef MC_GLOBAL_H
|
|
|
|
#define MC_GLOBAL_H
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2012-01-02 11:34:52 +04:00
|
|
|
#if defined(HAVE_STRING_H)
|
2010-11-08 13:21:45 +03:00
|
|
|
#include <string.h>
|
2002-07-14 23:34:17 +04:00
|
|
|
/* An ANSI string.h and pre-ANSI memory.h might conflict */
|
2012-01-02 11:34:52 +04:00
|
|
|
#elif defined(HAVE_MEMORY_H)
|
2010-11-08 13:21:45 +03:00
|
|
|
#include <memory.h>
|
2012-01-02 11:34:52 +04:00
|
|
|
#else
|
2010-11-08 13:21:45 +03:00
|
|
|
#include <strings.h>
|
2002-07-14 23:34:17 +04:00
|
|
|
/* memory and strings.h conflict on other systems */
|
|
|
|
#endif /* !STDC_HEADERS & !HAVE_STRING_H */
|
|
|
|
|
2001-08-19 20:23:24 +04:00
|
|
|
#ifdef HAVE_SYS_PARAM_H
|
2010-11-08 13:21:45 +03:00
|
|
|
#include <sys/param.h>
|
2001-09-07 20:46:31 +04:00
|
|
|
#endif
|
|
|
|
|
2010-11-08 13:21:45 +03:00
|
|
|
/*** typedefs(not structures) and defined constants **********************************************/
|
|
|
|
|
2002-09-23 10:43:22 +04:00
|
|
|
/* The O_BINARY definition was taken from gettext */
|
|
|
|
#if !defined O_BINARY && defined _O_BINARY
|
|
|
|
/* For MSC-compatible compilers. */
|
2010-11-08 13:21:45 +03:00
|
|
|
#define O_BINARY _O_BINARY
|
2002-09-23 10:43:22 +04:00
|
|
|
#endif
|
|
|
|
#ifdef __BEOS__
|
2002-09-23 11:00:30 +04:00
|
|
|
/* BeOS 5 has O_BINARY, but is has no effect. */
|
2010-11-08 13:21:45 +03:00
|
|
|
#undef O_BINARY
|
2002-09-23 10:43:22 +04:00
|
|
|
#endif
|
|
|
|
/* On reasonable systems, binary I/O is the default. */
|
|
|
|
#ifndef O_BINARY
|
2010-11-08 13:21:45 +03:00
|
|
|
#define O_BINARY 0
|
2002-09-23 10:43:22 +04:00
|
|
|
#endif
|
|
|
|
|
2002-12-16 03:41:06 +03:00
|
|
|
/* Replacement for O_NONBLOCK */
|
2004-12-03 22:17:46 +03:00
|
|
|
#ifndef O_NONBLOCK
|
2010-11-08 13:21:45 +03:00
|
|
|
#ifdef O_NDELAY /* SYSV */
|
2004-12-03 22:17:46 +03:00
|
|
|
#define O_NONBLOCK O_NDELAY
|
|
|
|
#else /* BSD */
|
|
|
|
#define O_NONBLOCK FNDELAY
|
|
|
|
#endif /* !O_NDELAY */
|
|
|
|
#endif /* !O_NONBLOCK */
|
2002-12-16 03:41:06 +03:00
|
|
|
|
2001-09-07 20:46:31 +04:00
|
|
|
#ifdef HAVE_SYS_SELECT_H
|
2010-11-08 13:21:45 +03:00
|
|
|
#include <sys/select.h>
|
2001-09-07 20:46:31 +04:00
|
|
|
#endif
|
|
|
|
|
2002-02-19 00:54:27 +03:00
|
|
|
#if defined(__QNX__) && !defined(__QNXNTO__)
|
|
|
|
/* exec*() from <process.h> */
|
2010-11-08 13:21:45 +03:00
|
|
|
#include <unix.h>
|
2002-02-19 00:54:27 +03:00
|
|
|
#endif
|
|
|
|
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 04:08:30 +03:00
|
|
|
#include <glib.h>
|
2003-09-23 00:21:48 +04:00
|
|
|
#include "glibcompat.h"
|
2001-08-19 20:23:24 +04:00
|
|
|
|
2001-10-20 07:38:41 +04:00
|
|
|
#ifndef __GNUC__
|
2010-11-08 13:21:45 +03:00
|
|
|
#define __attribute__(x)
|
2002-01-21 23:47:05 +03:00
|
|
|
#endif
|
|
|
|
|
2010-12-02 21:50:57 +03:00
|
|
|
/* Solaris9 doesn't have PRIXMAX */
|
|
|
|
#ifndef PRIXMAX
|
|
|
|
#define PRIXMAX PRIxMAX
|
|
|
|
#endif
|
|
|
|
|
2003-10-26 07:11:12 +03:00
|
|
|
#ifdef ENABLE_NLS
|
2010-11-08 13:21:45 +03:00
|
|
|
#include <libintl.h>
|
|
|
|
#define _(String) gettext (String)
|
|
|
|
#ifdef gettext_noop
|
|
|
|
#define N_(String) gettext_noop (String)
|
|
|
|
#else
|
|
|
|
#define N_(String) (String)
|
|
|
|
#endif
|
2003-10-26 07:11:12 +03:00
|
|
|
#else /* Stubs that do something close enough. */
|
2011-10-23 16:21:36 +04:00
|
|
|
#define textdomain(String) 1
|
2010-11-08 13:21:45 +03:00
|
|
|
#define gettext(String) (String)
|
|
|
|
#define ngettext(String1,String2,Num) (((Num) == 1) ? (String1) : (String2))
|
|
|
|
#define dgettext(Domain,Message) (Message)
|
|
|
|
#define dcgettext(Domain,Message,Type) (Message)
|
2011-10-23 16:21:36 +04:00
|
|
|
#define bindtextdomain(Domain,Directory) 1
|
2010-11-08 13:21:45 +03:00
|
|
|
#define _(String) (String)
|
|
|
|
#define N_(String) (String)
|
2003-10-26 07:11:12 +03:00
|
|
|
#endif /* !ENABLE_NLS */
|
|
|
|
|
2001-08-19 20:23:24 +04:00
|
|
|
#include "fs.h"
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 04:08:30 +03:00
|
|
|
|
2009-10-30 00:57:40 +03:00
|
|
|
#ifdef USE_MAINTAINER_MODE
|
2010-01-21 16:47:19 +03:00
|
|
|
#include "lib/logging.h"
|
2009-10-30 00:57:40 +03:00
|
|
|
#endif
|
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
#ifdef min
|
|
|
|
#undef min
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef max
|
|
|
|
#undef max
|
|
|
|
#endif
|
|
|
|
|
2010-11-08 13:21:45 +03:00
|
|
|
#define min(x, y) ((x) > (y) ? (y) : (x))
|
|
|
|
#define max(x, y) ((x) > (y) ? (x) : (y))
|
1998-02-27 07:54:42 +03:00
|
|
|
|
Glibing..... (2)
Wed Jan 27 03:17:44 1999 Timur Bakeyev <mc@bat.ru>
* Converted memory managment to Glib. Now we use g_new()/g_malloc()/
g_strdup()/g_free() routings. Also, copy_strings() replaced by
g_strconcat(), strcasecmp() -> g_strcasecmp(),and sprintf() by
g_snprintf().
* Some sequences of malloc()/sprintf() changed to g_strdup_printf().
* mad.[ch]: Modified, to work with new GLib's memory managment. Fixed
a missing #undef for tempnam, which caused dead loop. Add several new
functions to emulate GLib memory managment.
*main.c, mad.[ch]: Add a new switch "-M", which allows to redirect MAD
messages to the file.
* util.[ch], utilunix.c: Modified, deleted our variants of strcasecmp()
and strdup() - we have g_ equivalences. Remove get_full_name() - it is
similar to concat_dir_and_file(). Some other tricks with g_* functions.
* global.h: Modified, extended. Now it is main memory mangment include -
i.e. all inclusions of <stdlib.h>, <malloc.h>, <glib.h>, "fs.h", "mem.h",
"util.h" and "mad.h" done there. This elimanates problem with proper or-
der of #include's.
* All around the source - changed order of #include's, most of them gone
to global.h (see above), minor changes, like "0" -> NULL in string func-
tions.
1999-01-27 04:08:30 +03:00
|
|
|
/* Just for keeping Your's brains from invention a proper size of the buffer :-) */
|
2010-11-08 13:21:45 +03:00
|
|
|
#define BUF_10K 10240L
|
|
|
|
#define BUF_8K 8192L
|
|
|
|
#define BUF_4K 4096L
|
|
|
|
#define BUF_1K 1024L
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2010-11-08 13:21:45 +03:00
|
|
|
#define BUF_LARGE BUF_1K
|
|
|
|
#define BUF_MEDIUM 512
|
|
|
|
#define BUF_SMALL 128
|
|
|
|
#define BUF_TINY 64
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
/* AIX compiler doesn't understand '\e' */
|
|
|
|
#define ESC_CHAR '\033'
|
|
|
|
#define ESC_STR "\033"
|
|
|
|
|
2010-11-11 16:14:22 +03:00
|
|
|
/* OS specific defines */
|
|
|
|
#define PATH_SEP '/'
|
|
|
|
#define PATH_SEP_STR "/"
|
|
|
|
#define PATH_ENV_SEP ':'
|
|
|
|
#define TMPDIR_DEFAULT "/tmp"
|
|
|
|
#define SCRIPT_SUFFIX ""
|
|
|
|
#define get_default_editor() "vi"
|
|
|
|
#define OS_SORT_CASE_SENSITIVE_DEFAULT 1
|
2011-10-15 16:42:43 +04:00
|
|
|
#define UTF8_CHAR_LEN 6
|
2010-11-11 16:14:22 +03:00
|
|
|
|
2004-08-16 19:42:48 +04:00
|
|
|
/* C++ style type casts */
|
|
|
|
#define const_cast(m_type, m_expr) ((m_type) (m_expr))
|
|
|
|
|
2005-07-01 03:12:08 +04:00
|
|
|
#if 0
|
2005-04-26 23:42:37 +04:00
|
|
|
#ifdef MC_ENABLE_DEBUGGING_CODE
|
2010-11-08 13:21:45 +03:00
|
|
|
#undef NDEBUG
|
2005-04-26 23:42:37 +04:00
|
|
|
#else
|
2010-11-08 13:21:45 +03:00
|
|
|
#define NDEBUG
|
2005-04-26 23:42:37 +04:00
|
|
|
#endif
|
2012-01-04 15:36:53 +04:00
|
|
|
#ifdef HAVE_ASSERT_H
|
2005-04-26 23:42:37 +04:00
|
|
|
#include <assert.h>
|
2005-07-01 03:12:08 +04:00
|
|
|
#endif
|
2012-01-04 15:36:53 +04:00
|
|
|
#endif
|
2005-04-26 23:42:37 +04:00
|
|
|
|
2011-02-10 16:32:38 +03:00
|
|
|
#define MC_ERROR g_quark_from_static_string (PACKAGE)
|
2010-11-08 13:21:45 +03:00
|
|
|
|
|
|
|
/*** enums ***************************************************************************************/
|
|
|
|
|
2011-02-10 18:02:54 +03:00
|
|
|
/* run mode and params */
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
MC_RUN_FULL = 0,
|
|
|
|
MC_RUN_EDITOR,
|
|
|
|
MC_RUN_VIEWER,
|
|
|
|
MC_RUN_DIFFVIEWER
|
|
|
|
} mc_run_mode_t;
|
|
|
|
|
2010-11-08 13:21:45 +03:00
|
|
|
/*** structures declarations (and typedefs of structures)*****************************************/
|
|
|
|
|
2011-02-10 18:02:54 +03:00
|
|
|
typedef struct
|
|
|
|
{
|
2012-01-09 15:48:39 +04:00
|
|
|
#ifdef ENABLE_BACKGROUND
|
2011-02-10 18:02:54 +03:00
|
|
|
/* If true, this is a background process */
|
|
|
|
int we_are_background;
|
2012-01-09 15:48:39 +04:00
|
|
|
#endif /* ENABLE_BACKGROUND */
|
2011-02-10 18:02:54 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If utf-8 terminal utf8_display = 1
|
|
|
|
* Display bits set UTF-8
|
|
|
|
*/
|
|
|
|
int utf8_display;
|
|
|
|
|
|
|
|
/* Set if the nice message (hint) bar is visible */
|
|
|
|
int message_visible;
|
|
|
|
|
|
|
|
/* Set if the nice and useful keybar is visible */
|
|
|
|
int keybar_visible;
|
|
|
|
|
|
|
|
mc_run_mode_t mc_run_mode;
|
|
|
|
|
|
|
|
#ifdef HAVE_CHARSET
|
|
|
|
/* Numbers of (file I/O) and (input/display) codepages. -1 if not selected */
|
|
|
|
int source_codepage;
|
|
|
|
int display_codepage;
|
|
|
|
#else
|
|
|
|
/* If true, allow characters in the range 160-255 */
|
|
|
|
int eight_bit_clean;
|
|
|
|
/*
|
|
|
|
* If true, also allow characters in the range 128-159.
|
|
|
|
* This is reported to break on many terminals (xterm, qansi-m).
|
|
|
|
*/
|
|
|
|
int full_eight_bits;
|
|
|
|
#endif /* !HAVE_CHARSET */
|
|
|
|
|
|
|
|
/* sysconfig_dir: Area for default settings from maintainers of distributuves
|
|
|
|
default is /etc/mc or may be defined by MC_DATADIR
|
|
|
|
*/
|
|
|
|
char *sysconfig_dir;
|
|
|
|
|
|
|
|
/* share_data_dir: Area for default settings from developers */
|
|
|
|
char *share_data_dir;
|
|
|
|
|
2011-02-18 16:11:57 +03:00
|
|
|
/* Ugly hack in order to distinguish between left and right panel in menubar */
|
|
|
|
/* Set if the command is being run from the "Right" menu */
|
|
|
|
gboolean is_right; /* If the selected menu was the right */
|
|
|
|
|
2011-09-07 13:06:03 +04:00
|
|
|
/* Use the specified skin */
|
|
|
|
char *skin;
|
2011-02-10 18:02:54 +03:00
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
/* Used so that widgets know if they are being destroyed or shut down */
|
|
|
|
gboolean midnight_shutdown;
|
|
|
|
|
|
|
|
/* Asks for confirmation before clean up of history */
|
|
|
|
gboolean confirm_history_cleanup;
|
|
|
|
|
|
|
|
/* Set if you want the possible completions dialog for the first time */
|
|
|
|
gboolean show_all_if_ambiguous;
|
|
|
|
|
|
|
|
} widget;
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
char *setup_color_string;
|
|
|
|
char *term_color_string;
|
|
|
|
char *color_terminal_string;
|
|
|
|
|
|
|
|
/* Set if the window has changed it's size */
|
|
|
|
gboolean winch_flag;
|
|
|
|
|
|
|
|
#ifndef LINUX_CONS_SAVER_C
|
|
|
|
/* Used only in mc, not in cons.saver */
|
|
|
|
char console_flag;
|
|
|
|
#endif /* !LINUX_CONS_SAVER_C */
|
|
|
|
/* If using a subshell for evaluating commands this is true */
|
|
|
|
gboolean use_subshell;
|
|
|
|
#ifdef HAVE_SUBSHELL_SUPPORT
|
|
|
|
/* File descriptors of the pseudoterminal used by the subshell */
|
|
|
|
int subshell_pty;
|
|
|
|
#endif /* !HAVE_SUBSHELL_SUPPORT */
|
|
|
|
|
|
|
|
/* colors specified on the command line: they override any other setting */
|
|
|
|
char *command_line_colors;
|
|
|
|
|
2011-09-06 14:35:42 +04:00
|
|
|
/* This flag is set by xterm detection routine in function main() */
|
|
|
|
/* It is used by function view_other_cmd() */
|
|
|
|
gboolean xterm_flag;
|
2011-09-06 19:24:18 +04:00
|
|
|
|
2011-10-28 16:09:44 +04:00
|
|
|
/* disable x11 support */
|
|
|
|
gboolean disable_x11;
|
|
|
|
|
2011-09-06 19:24:18 +04:00
|
|
|
/* For slow terminals */
|
|
|
|
/* If true lines are shown by spaces */
|
|
|
|
gboolean slow_terminal;
|
|
|
|
|
2011-09-07 13:06:03 +04:00
|
|
|
/* Set to force black and white display at program startup */
|
|
|
|
gboolean disable_colors;
|
|
|
|
|
|
|
|
/* If true use +, -, | for line drawing */
|
|
|
|
gboolean ugly_line_drawing;
|
|
|
|
|
|
|
|
/* Tries to use old highlight mouse tracking */
|
|
|
|
gboolean old_mouse;
|
2011-09-14 02:07:31 +04:00
|
|
|
|
|
|
|
/* If true, use + and \ keys normally and select/unselect do if M-+ / M-\.
|
|
|
|
and M-- and keypad + / - */
|
|
|
|
gboolean alternate_plus_minus;
|
|
|
|
|
2011-02-10 18:02:54 +03:00
|
|
|
} tty;
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
/* Set when cd symlink following is desirable (bash mode) */
|
|
|
|
gboolean cd_symlinks;
|
2011-09-20 14:27:04 +04:00
|
|
|
|
|
|
|
/* Preallocate space before file copying */
|
|
|
|
gboolean preallocate_space;
|
|
|
|
|
2011-02-10 18:02:54 +03:00
|
|
|
} vfs;
|
|
|
|
|
|
|
|
} mc_global_t;
|
|
|
|
|
2010-11-08 13:21:45 +03:00
|
|
|
/*** global variables defined in .c file *********************************************************/
|
|
|
|
|
2011-02-10 18:02:54 +03:00
|
|
|
extern mc_global_t mc_global;
|
|
|
|
|
2010-11-08 13:21:45 +03:00
|
|
|
/*** declarations of public functions ************************************************************/
|
|
|
|
|
|
|
|
void refresh_screen (void *);
|
2009-09-28 18:04:25 +04:00
|
|
|
|
2010-11-08 13:21:45 +03:00
|
|
|
/*** inline functions ****************************************************************************/
|
2004-12-03 22:17:46 +03:00
|
|
|
#endif
|