global.h 7.5 KB

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