global.h 7.5 KB

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