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
|
|
|
|
2002-07-14 23:34:17 +04:00
|
|
|
#if defined(STDC_HEADERS) || 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 */
|
2010-11-08 13:21:45 +03:00
|
|
|
#if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H)
|
|
|
|
#include <memory.h>
|
|
|
|
#endif /* !STDC_HEADERS & HAVE_MEMORY_H */
|
2002-07-14 23:34:17 +04:00
|
|
|
|
|
|
|
#else /* !STDC_HEADERS & !HAVE_STRING_H */
|
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
|
|
|
|
|
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. */
|
2010-11-08 13:21:45 +03:00
|
|
|
#define textdomain(String)
|
|
|
|
#define gettext(String) (String)
|
|
|
|
#define ngettext(String1,String2,Num) (((Num) == 1) ? (String1) : (String2))
|
|
|
|
#define dgettext(Domain,Message) (Message)
|
|
|
|
#define dcgettext(Domain,Message,Type) (Message)
|
|
|
|
#define bindtextdomain(Domain,Directory)
|
|
|
|
#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
|
|
|
|
|
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
|
|
|
|
#include <assert.h>
|
2005-07-01 03:12:08 +04:00
|
|
|
#endif
|
2005-04-26 23:42:37 +04:00
|
|
|
|
2009-09-28 18:04:25 +04:00
|
|
|
#define MC_ERROR mc_main_error_quark ()
|
2010-11-08 13:21:45 +03:00
|
|
|
|
|
|
|
/*** enums ***************************************************************************************/
|
|
|
|
|
|
|
|
/*** structures declarations (and typedefs of structures)*****************************************/
|
|
|
|
|
|
|
|
/*** global variables defined in .c file *********************************************************/
|
|
|
|
|
|
|
|
extern const char *home_dir;
|
|
|
|
|
|
|
|
/*** declarations of public functions ************************************************************/
|
|
|
|
|
|
|
|
void refresh_screen (void *);
|
2009-09-28 18:04:25 +04:00
|
|
|
GQuark mc_main_error_quark (void);
|
|
|
|
|
2010-11-08 13:21:45 +03:00
|
|
|
/*** inline functions ****************************************************************************/
|
2004-12-03 22:17:46 +03:00
|
|
|
#endif
|