global.h 7.8 KB

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