global.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. /** \file global.h
  2. * \brief Header: %global definitions for compatibility
  3. *
  4. * This file should be included after all system includes and before all local includes.
  5. */
  6. #ifndef MC_GLOBAL_H
  7. #define MC_GLOBAL_H
  8. #if defined(HAVE_STRING_H)
  9. #include <string.h>
  10. /* An ANSI string.h and pre-ANSI memory.h might conflict */
  11. #elif defined(HAVE_MEMORY_H)
  12. #include <memory.h>
  13. #else
  14. #include <strings.h>
  15. /* memory and strings.h conflict on other systems */
  16. #endif /* !STDC_HEADERS & !HAVE_STRING_H */
  17. #ifdef HAVE_SYS_PARAM_H
  18. #include <sys/param.h>
  19. #endif
  20. /* for sig_atomic_t */
  21. #include <signal.h>
  22. /*** typedefs(not structures) and defined constants **********************************************/
  23. /* The O_BINARY definition was taken from gettext */
  24. #if !defined O_BINARY && defined _O_BINARY
  25. /* For MSC-compatible compilers. */
  26. #define O_BINARY _O_BINARY
  27. #endif
  28. #ifdef __BEOS__
  29. /* BeOS 5 has O_BINARY, but is has no effect. */
  30. #undef O_BINARY
  31. #endif
  32. /* On reasonable systems, binary I/O is the default. */
  33. #ifndef O_BINARY
  34. #define O_BINARY 0
  35. #endif
  36. /* Replacement for O_NONBLOCK */
  37. #ifndef O_NONBLOCK
  38. #ifdef O_NDELAY /* SYSV */
  39. #define O_NONBLOCK O_NDELAY
  40. #else /* BSD */
  41. #define O_NONBLOCK FNDELAY
  42. #endif /* !O_NDELAY */
  43. #endif /* !O_NONBLOCK */
  44. #ifdef HAVE_SYS_SELECT_H
  45. #include <sys/select.h>
  46. #endif
  47. #if defined(__QNX__) && !defined(__QNXNTO__)
  48. /* exec*() from <process.h> */
  49. #include <unix.h>
  50. #endif
  51. #include <glib.h>
  52. #include "glibcompat.h"
  53. #ifndef __GNUC__
  54. #define __attribute__(x)
  55. #endif
  56. /* Solaris9 doesn't have PRIXMAX */
  57. #ifndef PRIXMAX
  58. #define PRIXMAX PRIxMAX
  59. #endif
  60. #ifdef ENABLE_NLS
  61. #include <libintl.h>
  62. #define _(String) gettext (String)
  63. #ifdef gettext_noop
  64. #define N_(String) gettext_noop (String)
  65. #else
  66. #define N_(String) (String)
  67. #endif
  68. #else /* Stubs that do something close enough. */
  69. #define textdomain(String) 1
  70. #define gettext(String) (String)
  71. #define ngettext(String1,String2,Num) (((Num) == 1) ? (String1) : (String2))
  72. #define dgettext(Domain,Message) (Message)
  73. #define dcgettext(Domain,Message,Type) (Message)
  74. #define bindtextdomain(Domain,Directory) 1
  75. #define _(String) (String)
  76. #define N_(String) (String)
  77. #endif /* !ENABLE_NLS */
  78. #include "fs.h"
  79. #ifdef USE_MAINTAINER_MODE
  80. #include "lib/logging.h"
  81. #endif
  82. #ifdef min
  83. #undef min
  84. #endif
  85. #ifdef max
  86. #undef max
  87. #endif
  88. #define min(x, y) ((x) > (y) ? (y) : (x))
  89. #define max(x, y) ((x) > (y) ? (x) : (y))
  90. /* Just for keeping Your's brains from invention a proper size of the buffer :-) */
  91. #define BUF_10K 10240L
  92. #define BUF_8K 8192L
  93. #define BUF_4K 4096L
  94. #define BUF_1K 1024L
  95. #define BUF_LARGE BUF_1K
  96. #define BUF_MEDIUM 512
  97. #define BUF_SMALL 128
  98. #define BUF_TINY 64
  99. /* ESC_CHAR is defined in /usr/include/langinfo.h in some systems */
  100. #ifdef ESC_CHAR
  101. #undef ESC_CHAR
  102. #endif
  103. /* AIX compiler doesn't understand '\e' */
  104. #define ESC_CHAR '\033'
  105. #define ESC_STR "\033"
  106. /* OS specific defines */
  107. #define PATH_SEP '/'
  108. #define PATH_SEP_STR "/"
  109. #define PATH_ENV_SEP ':'
  110. #define TMPDIR_DEFAULT "/tmp"
  111. #define SCRIPT_SUFFIX ""
  112. #define get_default_editor() "vi"
  113. #define OS_SORT_CASE_SENSITIVE_DEFAULT 1
  114. #define UTF8_CHAR_LEN 6
  115. /* C++ style type casts */
  116. #define const_cast(m_type, m_expr) ((m_type) (m_expr))
  117. #if 0
  118. #ifdef MC_ENABLE_DEBUGGING_CODE
  119. #undef NDEBUG
  120. #else
  121. #define NDEBUG
  122. #endif
  123. #ifdef HAVE_ASSERT_H
  124. #include <assert.h>
  125. #endif
  126. #endif
  127. #define MC_ERROR g_quark_from_static_string (PACKAGE)
  128. /*** enums ***************************************************************************************/
  129. /* run mode and params */
  130. typedef enum
  131. {
  132. MC_RUN_FULL = 0,
  133. MC_RUN_EDITOR,
  134. MC_RUN_VIEWER,
  135. MC_RUN_DIFFVIEWER
  136. } mc_run_mode_t;
  137. /*** structures declarations (and typedefs of structures)*****************************************/
  138. typedef struct
  139. {
  140. mc_run_mode_t mc_run_mode;
  141. /* Used so that widgets know if they are being destroyed or shut down */
  142. gboolean midnight_shutdown;
  143. /* sysconfig_dir: Area for default settings from maintainers of distributuves
  144. default is /etc/mc or may be defined by MC_DATADIR */
  145. char *sysconfig_dir;
  146. /* share_data_dir: Area for default settings from developers */
  147. char *share_data_dir;
  148. #ifdef HAVE_CHARSET
  149. /* Numbers of (file I/O) and (input/display) codepages. -1 if not selected */
  150. int source_codepage;
  151. int display_codepage;
  152. #else
  153. /* If true, allow characters in the range 160-255 */
  154. int eight_bit_clean;
  155. /*
  156. * If true, also allow characters in the range 128-159.
  157. * This is reported to break on many terminals (xterm, qansi-m).
  158. */
  159. int full_eight_bits;
  160. #endif /* !HAVE_CHARSET */
  161. /*
  162. * If utf-8 terminal utf8_display = TRUE
  163. * Display bits set UTF-8
  164. */
  165. gboolean utf8_display;
  166. /* Set if the nice message (hint) bar is visible */
  167. int message_visible;
  168. /* Set if the nice and useful keybar is visible */
  169. int keybar_visible;
  170. #ifdef ENABLE_BACKGROUND
  171. /* If true, this is a background process */
  172. gboolean we_are_background;
  173. #endif /* ENABLE_BACKGROUND */
  174. struct
  175. {
  176. /* Asks for confirmation before clean up of history */
  177. gboolean confirm_history_cleanup;
  178. /* Set if you want the possible completions dialog for the first time */
  179. gboolean show_all_if_ambiguous;
  180. /* Ugly hack in order to distinguish between left and right panel in menubar */
  181. /* Set if the command is being run from the "Right" menu */
  182. gboolean is_right; /* If the selected menu was the right */
  183. } widget;
  184. struct
  185. {
  186. /* Use the specified skin */
  187. char *skin;
  188. char *setup_color_string;
  189. char *term_color_string;
  190. char *color_terminal_string;
  191. /* colors specified on the command line: they override any other setting */
  192. char *command_line_colors;
  193. #ifndef LINUX_CONS_SAVER_C
  194. /* Used only in mc, not in cons.saver */
  195. char console_flag;
  196. #endif /* !LINUX_CONS_SAVER_C */
  197. /* If using a subshell for evaluating commands this is true */
  198. gboolean use_subshell;
  199. #ifdef HAVE_SUBSHELL_SUPPORT
  200. /* File descriptors of the pseudoterminal used by the subshell */
  201. int subshell_pty;
  202. #endif /* !HAVE_SUBSHELL_SUPPORT */
  203. /* This flag is set by xterm detection routine in function main() */
  204. /* It is used by function view_other_cmd() */
  205. gboolean xterm_flag;
  206. /* disable x11 support */
  207. gboolean disable_x11;
  208. /* For slow terminals */
  209. /* If true lines are shown by spaces */
  210. gboolean slow_terminal;
  211. /* Set to force black and white display at program startup */
  212. gboolean disable_colors;
  213. /* If true use +, -, | for line drawing */
  214. gboolean ugly_line_drawing;
  215. /* Tries to use old highlight mouse tracking */
  216. gboolean old_mouse;
  217. /* If true, use + and \ keys normally and select/unselect do if M-+ / M-\.
  218. and M-- and keypad + / - */
  219. gboolean alternate_plus_minus;
  220. /* Set if the window has changed it's size */
  221. SIG_ATOMIC_VOLATILE_T winch_flag;
  222. } tty;
  223. struct
  224. {
  225. /* Set when cd symlink following is desirable (bash mode) */
  226. gboolean cd_symlinks;
  227. /* Preallocate space before file copying */
  228. gboolean preallocate_space;
  229. } vfs;
  230. } mc_global_t;
  231. /*** global variables defined in .c file *********************************************************/
  232. extern mc_global_t mc_global;
  233. /*** declarations of public functions ************************************************************/
  234. void refresh_screen (void *);
  235. /*** inline functions ****************************************************************************/
  236. #endif