Just a little correction at the it.po file.
[midnight-commander.git] / src / util.h
blobf22947ab545b21ac9a4a62ecc6f62e415736bf13
1 #ifndef __UTIL_H
2 #define __UTIL_H
5 #include <sys/types.h>
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)
64 /* Matching */
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);
70 /* Error pipes */
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;
82 /* Tilde expansion */
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 int my_mkdir (char *s, mode_t mode);
91 int my_rmdir (char *s);
93 /* Rotating dash routines */
94 void use_dash (int flag); /* Disable/Enable rotate_dash routines */
95 void rotate_dash (void);
96 void remove_dash (void);
98 /* Creating temporary files safely */
99 const char *mc_tmpdir (void);
100 int mc_mkstemps(char **pname, const char *prefix, const char *suffix);
102 enum {
103 COMPRESSION_NONE,
104 COMPRESSION_GZIP,
105 COMPRESSION_BZIP,
106 COMPRESSION_BZIP2
109 int get_compression_type (int fd);
110 const char *decompress_extension (int type);
112 int mc_doublepopen (int inhandle, int inlen, pid_t *tp, char *command, ...);
113 int mc_doublepclose (int pipehandle, pid_t pid);
115 /* Hook functions */
117 typedef struct hook {
118 void (*hook_fn)(void *);
119 void *hook_data;
120 struct hook *next;
121 } Hook;
123 void add_hook (Hook **hook_list, void (*hook_fn)(void *), void *data);
124 void execute_hooks (Hook *hook_list);
125 void delete_hook (Hook **hook_list, void (*hook_fn)(void *));
126 int hook_present (Hook *hook_list, void (*hook_fn)(void *));
128 GList *list_append_unique (GList *list, char *text);
130 /* Position saving and restoring */
132 /* file where positions are stored */
133 #define MC_FILEPOS ".mc/filepos"
134 /* temporary file */
135 #define MC_FILEPOS_TMP ".mc/filepos.tmp"
136 /* maximum entries in MC_FILEPOS */
137 #define MC_FILEPOS_ENTRIES 1024
138 /* Load position for the given filename */
139 void load_file_position (char *filename, long *line, long *column);
140 /* Save position for the given filename */
141 void save_file_position (char *filename, long line, long column);
144 /* OS specific defines */
146 #ifdef NATIVE_WIN32
147 # define PATH_SEP '\\'
148 # define PATH_SEP_STR "\\"
149 # define PATH_ENV_SEP ';'
150 # define TMPDIR_DEFAULT "c:\\temp"
151 # define SCRIPT_SUFFIX ".cmd"
152 # define OS_SORT_CASE_SENSITIVE_DEFAULT 0
153 # define STRCOMP stricmp
154 # define STRNCOMP strnicmp
155 # define MC_ARCH_FLAGS REG_ICASE
156 char *get_default_shell (void);
157 char *get_default_editor (void);
158 int lstat (const char* pathname, struct stat *buffer);
159 #else
160 # define PATH_SEP '/'
161 # define PATH_SEP_STR "/"
162 # define PATH_ENV_SEP ':'
163 # define TMPDIR_DEFAULT "/tmp"
164 # define SCRIPT_SUFFIX ""
165 # define get_default_editor() "vi"
166 # define OS_SORT_CASE_SENSITIVE_DEFAULT 1
167 # define STRCOMP strcmp
168 # define STRNCOMP strncmp
169 # define MC_ARCH_FLAGS 0
170 #endif
172 #include "i18n.h"
174 /* taken from regex.c: */
175 /* Jim Meyering writes:
177 "... Some ctype macros are valid only for character codes that
178 isascii says are ASCII (SGI's IRIX-4.0.5 is one such system --when
179 using /bin/cc or gcc but without giving an ansi option). So, all
180 ctype uses should be through macros like ISPRINT... If
181 STDC_HEADERS is defined, then autoconf has verified that the ctype
182 macros don't need to be guarded with references to isascii. ...
183 Defining isascii to 1 should let any compiler worth its salt
184 eliminate the && through constant folding." */
186 #if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
187 #define ISASCII(c) 1
188 #else
189 #define ISASCII(c) isascii(c)
190 #endif
192 #endif