global.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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 O_* macros */
  21. #include <fcntl.h>
  22. /* for sig_atomic_t */
  23. #include <signal.h>
  24. #ifdef HAVE_FUNC_ATTRIBUTE_FALLTHROUGH
  25. #define MC_FALLTHROUGH __attribute__((fallthrough))
  26. #else
  27. #define MC_FALLTHROUGH
  28. #endif
  29. /*** typedefs(not structures) and defined constants **********************************************/
  30. /* The O_BINARY definition was taken from gettext */
  31. #if !defined O_BINARY && defined _O_BINARY
  32. /* For MSC-compatible compilers. */
  33. #define O_BINARY _O_BINARY
  34. #endif
  35. #ifdef __BEOS__
  36. /* BeOS 5 has O_BINARY, but is has no effect. */
  37. #undef O_BINARY
  38. #endif
  39. /* On reasonable systems, binary I/O is the default. */
  40. #ifndef O_BINARY
  41. #define O_BINARY 0
  42. #endif
  43. /* Replacement for O_NONBLOCK */
  44. #ifndef O_NONBLOCK
  45. #ifdef O_NDELAY /* SYSV */
  46. #define O_NONBLOCK O_NDELAY
  47. #else /* BSD */
  48. #define O_NONBLOCK FNDELAY
  49. #endif /* !O_NDELAY */
  50. #endif /* !O_NONBLOCK */
  51. #if defined(__QNX__) && !defined(__QNXNTO__)
  52. /* exec*() from <process.h> */
  53. #include <unix.h>
  54. #endif
  55. #include <glib.h>
  56. #include "glibcompat.h"
  57. /* For SMB VFS only */
  58. #ifndef __GNUC__
  59. #define __attribute__(x)
  60. #endif
  61. /* Solaris9 doesn't have PRIXMAX */
  62. #ifndef PRIXMAX
  63. #define PRIXMAX PRIxMAX
  64. #endif
  65. #ifdef ENABLE_NLS
  66. #include <libintl.h>
  67. #define _(String) gettext (String)
  68. #ifdef gettext_noop
  69. #define N_(String) gettext_noop (String)
  70. #else
  71. #define N_(String) (String)
  72. #endif
  73. #else /* Stubs that do something close enough. */
  74. #define textdomain(String) 1
  75. #define gettext(String) (String)
  76. #define ngettext(String1,String2,Num) (((Num) == 1) ? (String1) : (String2))
  77. #define dgettext(Domain,Message) (Message)
  78. #define dcgettext(Domain,Message,Type) (Message)
  79. #define bindtextdomain(Domain,Directory) 1
  80. #define _(String) (String)
  81. #define N_(String) (String)
  82. #endif /* !ENABLE_NLS */
  83. #include "fs.h"
  84. #include "shell.h"
  85. #include "mcconfig.h"
  86. #ifdef USE_MAINTAINER_MODE
  87. #include "lib/logging.h"
  88. #endif
  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. /* ESC_CHAR is defined in /usr/include/langinfo.h in some systems */
  99. #ifdef ESC_CHAR
  100. #undef ESC_CHAR
  101. #endif
  102. /* AIX compiler doesn't understand '\e' */
  103. #define ESC_CHAR '\033'
  104. #define ESC_STR "\033"
  105. /* OS specific defines */
  106. #define PATH_SEP '/'
  107. #define PATH_SEP_STR "/"
  108. #define IS_PATH_SEP(c) ((c) == PATH_SEP)
  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 TRUE
  114. #define UTF8_CHAR_LEN 6
  115. /* struct stat members */
  116. #ifdef __APPLE__
  117. #define st_atim st_atimespec
  118. #define st_ctim st_ctimespec
  119. #define st_mtim st_mtimespec
  120. #endif
  121. /* Used to distinguish between a normal MC termination and */
  122. /* one caused by typing 'exit' or 'logout' in the subshell */
  123. #define SUBSHELL_EXIT 128
  124. #define MC_ERROR g_quark_from_static_string (PACKAGE)
  125. #define DEFAULT_CHARSET "ASCII"
  126. /*** enums ***************************************************************************************/
  127. /* run mode and params */
  128. typedef enum
  129. {
  130. MC_RUN_FULL = 0,
  131. MC_RUN_EDITOR,
  132. MC_RUN_VIEWER,
  133. MC_RUN_DIFFVIEWER
  134. } mc_run_mode_t;
  135. /*** structures declarations (and typedefs of structures)*****************************************/
  136. typedef struct
  137. {
  138. const char *mc_version;
  139. mc_run_mode_t mc_run_mode;
  140. gboolean run_from_parent_mc;
  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. mc_config_t *main_config;
  149. mc_config_t *panels_config;
  150. #ifdef HAVE_CHARSET
  151. /* Numbers of (file I/O) and (input/display) codepages. -1 if not selected */
  152. int source_codepage;
  153. int display_codepage;
  154. #else
  155. /* If true, allow characters in the range 160-255 */
  156. gboolean eight_bit_clean;
  157. /*
  158. * If true, also allow characters in the range 128-159.
  159. * This is reported to break on many terminals (xterm, qansi-m).
  160. */
  161. gboolean full_eight_bits;
  162. #endif /* !HAVE_CHARSET */
  163. /*
  164. * If utf-8 terminal utf8_display = TRUE
  165. * Display bits set UTF-8
  166. */
  167. gboolean utf8_display;
  168. /* Set if the nice message (hint) bar is visible */
  169. gboolean message_visible;
  170. /* Set if the nice and useful keybar is visible */
  171. gboolean keybar_visible;
  172. #ifdef ENABLE_BACKGROUND
  173. /* If true, this is a background process */
  174. gboolean we_are_background;
  175. #endif /* ENABLE_BACKGROUND */
  176. struct
  177. {
  178. /* Asks for confirmation before clean up of history */
  179. gboolean confirm_history_cleanup;
  180. /* Set if you want the possible completions dialog for the first time */
  181. gboolean show_all_if_ambiguous;
  182. /* Ugly hack in order to distinguish between left and right panel in menubar */
  183. /* Set if the command is being run from the "Right" menu */
  184. gboolean is_right; /* If the selected menu was the right */
  185. } widget;
  186. /* The user's shell */
  187. mc_shell_t *shell;
  188. struct
  189. {
  190. /* Use the specified skin */
  191. char *skin;
  192. /* Dialog window and frop down menu have a shadow */
  193. gboolean shadows;
  194. char *setup_color_string;
  195. char *term_color_string;
  196. char *color_terminal_string;
  197. /* colors specified on the command line: they override any other setting */
  198. char *command_line_colors;
  199. #ifndef LINUX_CONS_SAVER_C
  200. /* Used only in mc, not in cons.saver */
  201. char console_flag;
  202. #endif /* !LINUX_CONS_SAVER_C */
  203. /* If using a subshell for evaluating commands this is true */
  204. gboolean use_subshell;
  205. #ifdef ENABLE_SUBSHELL
  206. /* File descriptors of the pseudoterminal used by the subshell */
  207. int subshell_pty;
  208. #endif /* !ENABLE_SUBSHELL */
  209. /* This flag is set by xterm detection routine in function main() */
  210. /* It is used by function toggle_subshell() */
  211. gboolean xterm_flag;
  212. /* disable x11 support */
  213. gboolean disable_x11;
  214. /* For slow terminals */
  215. /* If true lines are shown by spaces */
  216. gboolean slow_terminal;
  217. /* Set to force black and white display at program startup */
  218. gboolean disable_colors;
  219. /* If true use +, -, | for line drawing */
  220. gboolean ugly_line_drawing;
  221. /* Tries to use old highlight mouse tracking */
  222. gboolean old_mouse;
  223. /* If true, use + and \ keys normally and select/unselect do if M-+ / M-\.
  224. and M-- and keypad + / - */
  225. gboolean alternate_plus_minus;
  226. } tty;
  227. struct
  228. {
  229. /* Set when cd symlink following is desirable (bash mode) */
  230. gboolean cd_symlinks;
  231. /* Preallocate space before file copying */
  232. gboolean preallocate_space;
  233. } vfs;
  234. } mc_global_t;
  235. /*** global variables defined in .c file *********************************************************/
  236. extern mc_global_t mc_global;
  237. /*** declarations of public functions ************************************************************/
  238. /*** inline functions ****************************************************************************/
  239. #endif