7 /* String managing functions */
9 int is_printable (int c
);
10 int msglen (char *text
, int *lines
);
11 char *trim (char *s
, char *d
, int len
);
12 char *name_quote (const char *c
, int quote_percent
);
13 char *fake_name_quote (const char *c
, int quote_percent
);
14 char *name_trunc (const char *txt
, int trunc_len
);
15 char *size_trunc (double size
);
16 char *size_trunc_sep (double size
);
17 void size_trunc_len (char *buffer
, int len
, off_t size
, int units
);
18 int is_exe (mode_t mode
);
19 char *string_perm (mode_t mode_bits
);
20 char *strip_password (char *path
, int has_prefix
);
21 char *strip_home_and_password (const char *dir
);
22 char *extension (char *);
23 char *concat_dir_and_file (const char *dir
, const char *file
);
24 char *unix_error_string (int error_num
);
25 char *skip_separators (char *s
);
26 char *skip_numbers (char *s
);
27 char *strip_ctrl_codes (char *s
);
28 char *convert_controls (char *s
);
29 void wipe_password (char *passwd
);
30 char *diff_two_paths (char *first
, char *second
);
32 char *x_basename (char *s
);
34 /* Profile managing functions */
35 int set_int (char *, char *, int);
36 int get_int (char *, char *, int);
38 char *load_file (char *filename
);
39 char *load_mc_home_file (const char *filename
, char ** allocated_filename
);
41 /* uid/gid managing */
42 void init_groups (void);
43 void destroy_groups (void);
44 int get_user_permissions (struct stat
*buf
);
46 void init_uid_gid_cache (void);
47 char *get_group (int);
48 char *get_owner (int);
50 #define MAX_I18NTIMELENGTH 14
51 #define MIN_I18NTIMELENGTH 10
52 #define STD_I18NTIMELENGTH 12
54 size_t i18n_checktimelength (void);
55 char *file_date (time_t);
57 int exist_file (char *name
);
59 /* Returns a copy of *s until a \n is found and is below top */
60 char *extract_line (char *s
, char *top
);
61 char *_icase_search (char *text
, char *data
, int *lng
);
62 #define icase_search(T,D) _icase_search((T), (D), NULL)
65 enum { match_file
, match_normal
};
66 extern int easy_patterns
;
67 char *convert_pattern (char *pattern
, int match_type
, int do_group
);
68 int regexp_match (char *pattern
, char *string
, int match_type
);
71 void open_error_pipe (void);
72 void check_error_pipe (void);
73 int close_error_pipe (int error
, char *text
);
75 /* Process spawning */
76 #define EXECUTE_INTERNAL 1
77 #define EXECUTE_AS_SHELL 4
78 int my_system (int flags
, const char *shell
, const char *command
);
79 void save_stop_handler (void);
80 extern struct sigaction startup_handler
;
83 char *tilde_expand (const char *);
85 /* Pathname canonicalization */
86 char *canonicalize_pathname (char *);
88 /* Misc Unix functions */
89 char *get_current_wd (char *buffer
, int size
);
90 const char *mc_tmpdir (void);
91 int my_mkdir (char *s
, mode_t mode
);
92 int my_rmdir (char *s
);
94 /* Rotating dash routines */
95 void use_dash (int flag
); /* Disable/Enable rotate_dash routines */
96 void rotate_dash (void);
97 void remove_dash (void);
99 extern const char app_text
[];
101 /* Creating temporary files safely */
102 void init_tmpdir(void);
103 int mc_mkstemps(char **pname
, const char *prefix
, const char *suffix
);
112 int get_compression_type (int fd
);
113 const char *decompress_extension (int type
);
115 int mc_doublepopen (int inhandle
, int inlen
, pid_t
*tp
, char *command
, ...);
116 int mc_doublepclose (int pipehandle
, pid_t pid
);
120 typedef struct hook
{
121 void (*hook_fn
)(void *);
126 void add_hook (Hook
**hook_list
, void (*hook_fn
)(void *), void *data
);
127 void execute_hooks (Hook
*hook_list
);
128 void delete_hook (Hook
**hook_list
, void (*hook_fn
)(void *));
129 int hook_present (Hook
*hook_list
, void (*hook_fn
)(void *));
132 /* Position saving and restoring */
134 /* file where positions are stored */
135 #define MC_FILEPOS ".mc/filepos"
137 #define MC_FILEPOS_TMP ".mc/filepos.tmp"
138 /* maximum entries in MC_FILEPOS */
139 #define MC_FILEPOS_ENTRIES 1024
140 /* Load position for the given filename */
141 void load_file_position (char *filename
, long *line
, long *column
);
142 /* Save position for the given filename */
143 void save_file_position (char *filename
, long line
, long column
);
146 /* OS specific defines */
149 # define PATH_SEP '\\'
150 # define PATH_SEP_STR "\\"
151 # define PATH_ENV_SEP ';'
152 # define TMPDIR_DEFAULT "c:\\temp"
153 # define SCRIPT_SUFFIX ".cmd"
154 # define OS_SORT_CASE_SENSITIVE_DEFAULT 0
155 # define STRCOMP stricmp
156 # define STRNCOMP strnicmp
157 # define MC_ARCH_FLAGS REG_ICASE
158 char *get_default_shell (void);
159 char *get_default_editor (void);
160 int lstat (const char* pathname
, struct stat
*buffer
);
162 # define PATH_SEP '/'
163 # define PATH_SEP_STR "/"
164 # define PATH_ENV_SEP ':'
165 # define TMPDIR_DEFAULT "/tmp"
166 # define SCRIPT_SUFFIX ""
167 # define get_default_editor() "vi"
168 # define OS_SORT_CASE_SENSITIVE_DEFAULT 1
169 # define STRCOMP strcmp
170 # define STRNCOMP strncmp
171 # define MC_ARCH_FLAGS 0
176 /* taken from regex.c: */
177 /* Jim Meyering writes:
179 "... Some ctype macros are valid only for character codes that
180 isascii says are ASCII (SGI's IRIX-4.0.5 is one such system --when
181 using /bin/cc or gcc but without giving an ansi option). So, all
182 ctype uses should be through macros like ISPRINT... If
183 STDC_HEADERS is defined, then autoconf has verified that the ctype
184 macros don't need to be guarded with references to isascii. ...
185 Defining isascii to 1 should let any compiler worth its salt
186 eliminate the && through constant folding." */
188 #if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
191 #define ISASCII(c) isascii(c)