root/lib/global.h

/* [previous][next][first][last][top][bottom][index][help]  */

INCLUDED FROM


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

/* [previous][next][first][last][top][bottom][index][help]  */