2001-09-07 20:46:31 +04:00
|
|
|
/*
|
|
|
|
* This file should be included after all system includes and before
|
|
|
|
* all local includes.
|
|
|
|
*/
|
|
|
|
|
2001-09-07 21:52:19 +04:00
|
|
|
#ifndef __MC_GLOBAL_H
|
|
|
|
#define __MC_GLOBAL_H
|
1998-02-27 07:54:42 +03:00
|
|
|
|
2003-06-02 23:26:55 +04:00
|
|
|
#include <stdlib.h> /* for free() and other useful routins */
|
2001-09-07 20:46:31 +04:00
|
|
|
|
2002-07-14 23:34:17 +04:00
|
|
|
#if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
|
|
|
|
# include <string.h>
|
|
|
|
/* An ANSI string.h and pre-ANSI memory.h might conflict */
|
|
|
|
# if !defined(STDC_HEADERS) && defined(HAVE_MEMORY_H)
|
|
|
|
# include <memory.h>
|
|
|
|
# endif /* !STDC_HEADERS & HAVE_MEMORY_H */
|
|
|
|
|
|
|
|
#else /* !STDC_HEADERS & !HAVE_STRING_H */
|
|
|
|
# include <strings.h>
|
|
|
|
/* 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
|
2001-09-07 20:46:31 +04:00
|
|
|
# include <sys/param.h>
|
|
|
|
#endif
|
|
|
|
|
2002-09-23 10:43:22 +04:00
|
|
|
#ifdef HAVE_FCNTL_H
|
|
|
|
# include <fcntl.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* The O_BINARY definition was taken from gettext */
|
|
|
|
#if !defined O_BINARY && defined _O_BINARY
|
|
|
|
/* For MSC-compatible compilers. */
|
|
|
|
# define O_BINARY _O_BINARY
|
|
|
|
#endif
|
|
|
|
#ifdef __BEOS__
|
2002-09-23 11:00:30 +04:00
|
|
|
/* BeOS 5 has O_BINARY, but is has no effect. */
|
2002-09-23 10:43:22 +04:00
|
|
|
# undef O_BINARY
|
|
|
|
#endif
|
|
|
|
/* On reasonable systems, binary I/O is the default. */
|
|
|
|
#ifndef O_BINARY
|
|
|
|
# define O_BINARY 0
|
|
|
|
#endif
|
|
|
|
|
2002-12-16 03:41:06 +03:00
|
|
|
|
|
|
|
/* Replacement for O_NONBLOCK */
|
|
|
|
#ifndef O_NONBLOCK
|
|
|
|
#ifdef O_NDELAY /* SYSV */
|
|
|
|
#define O_NONBLOCK O_NDELAY
|
|
|
|
#else /* BSD */
|
|
|
|
#define O_NONBLOCK FNDELAY
|
|
|
|
#endif /* !O_NDELAY */
|
|
|
|
#endif /* !O_NONBLOCK */
|
|
|
|
|
|
|
|
|
2001-09-07 20:46:31 +04:00
|
|
|
#ifdef HAVE_SYS_TIMEB_H
|
|
|
|
# include <sys/timeb.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef TIME_WITH_SYS_TIME
|
|
|
|
# include <sys/time.h>
|
|
|
|
# include <time.h>
|
|
|
|
#else
|
|
|
|
# ifdef HAVE_SYS_TIME_H
|
|
|
|
# include <sys/time.h>
|
|
|
|
# else
|
|
|
|
# include <time.h>
|
|
|
|
# endif
|
2001-08-19 20:23:24 +04:00
|
|
|
#endif
|
2001-09-07 20:46:31 +04:00
|
|
|
|
2003-07-23 07:22:32 +04:00
|
|
|
#if !defined(HAVE_SYS_TIME_H)
|
2002-01-22 01:46:22 +03:00
|
|
|
struct timeval {
|
|
|
|
long int tv_sec; /* seconds */
|
|
|
|
long int tv_usec; /* microseconds */
|
|
|
|
};
|
|
|
|
#endif /* !HAVE_SYS_TIME_H */
|
|
|
|
|
2001-09-07 21:52:19 +04:00
|
|
|
#ifdef HAVE_UTIME_H
|
|
|
|
# include <utime.h>
|
2002-01-22 00:29:55 +03:00
|
|
|
#elif defined(HAVE_SYS_UTIME_H)
|
2002-01-21 23:57:31 +03:00
|
|
|
# include <sys/utime.h>
|
2001-09-07 21:52:19 +04:00
|
|
|
#endif
|
|
|
|
|
2001-09-07 20:46:31 +04:00
|
|
|
#ifdef HAVE_SYS_WAIT_H
|
|
|
|
# include <sys/wait.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_SYS_SELECT_H
|
|
|
|
# include <sys/select.h>
|
|
|
|
#endif
|
|
|
|
|
2001-09-07 21:52:19 +04:00
|
|
|
#ifdef HAVE_GRP_H
|
|
|
|
# include <grp.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_PWD_H
|
|
|
|
# include <pwd.h>
|
|
|
|
#endif
|
|
|
|
|
2002-02-19 00:54:27 +03:00
|
|
|
#if defined(__QNX__) && !defined(__QNXNTO__)
|
|
|
|
/* exec*() from <process.h> */
|
|
|
|
# include <unix.h>
|
|
|
|
#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>
|
2001-08-19 20:23:24 +04:00
|
|
|
|
2002-08-21 11:20:39 +04:00
|
|
|
#if defined(HAVE_RX_H) && defined(HAVE_REGCOMP)
|
|
|
|
#include <rx.h>
|
|
|
|
#else
|
|
|
|
#include "eregex.h"
|
|
|
|
#endif
|
|
|
|
|
2001-10-20 07:38:41 +04:00
|
|
|
#ifndef __GNUC__
|
2002-01-21 23:47:05 +03:00
|
|
|
# define __attribute__(x)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef HAVE_GETUID
|
|
|
|
# define getuid() 0
|
|
|
|
#endif
|
|
|
|
#ifndef HAVE_GETGID
|
|
|
|
# define getgid() 0
|
|
|
|
#endif
|
|
|
|
#ifndef HAVE_GETEUID
|
|
|
|
# define geteuid() getuid()
|
|
|
|
#endif
|
|
|
|
#ifndef HAVE_GETEGID
|
|
|
|
# define getegid() getgid()
|
2001-10-20 07:38:41 +04:00
|
|
|
#endif
|
|
|
|
|
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
|
|
|
#include "util.h"
|
|
|
|
|
2001-09-03 07:07:46 +04:00
|
|
|
#include "textconf.h"
|
2002-07-11 01:20:49 +04:00
|
|
|
#include "../vfs/vfs.h"
|
2001-08-19 20:23:24 +04:00
|
|
|
|
1998-02-27 07:54:42 +03:00
|
|
|
extern char *home_dir;
|
|
|
|
|
|
|
|
#ifdef min
|
|
|
|
#undef min
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef max
|
|
|
|
#undef max
|
|
|
|
#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
|
|
|
#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 :-) */
|
|
|
|
#define BUF_10K 10240L
|
|
|
|
#define BUF_8K 8192L
|
|
|
|
#define BUF_4K 4096L
|
|
|
|
#define BUF_1K 1024L
|
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
|
|
|
#define BUF_LARGE BUF_1K
|
|
|
|
#define BUF_MEDIUM 512
|
|
|
|
#define BUF_SMALL 128
|
|
|
|
#define BUF_TINY 64
|
|
|
|
|
|
|
|
void refresh_screen (void *);
|
1998-02-27 07:54:42 +03:00
|
|
|
|
|
|
|
/* AIX compiler doesn't understand '\e' */
|
|
|
|
#define ESC_CHAR '\033'
|
|
|
|
#define ESC_STR "\033"
|
|
|
|
|
2001-09-07 21:52:19 +04:00
|
|
|
#endif /* !__MC_GLOBAL_H */
|