blob: 00ae239ea20d35a9363b26ca92759af963487981 [file] [log] [blame]
Bram Moolenaaredf3f972016-08-29 22:49:24 +02001/* vi:set ts=8 sts=4 sw=4 noet:
Bram Moolenaar071d4272004-06-13 20:20:40 +00002 *
3 * VIM - Vi IMproved by Bram Moolenaar
4 *
5 * Do ":help uganda" in Vim to read copying and usage conditions.
6 * Do ":help credits" in Vim to see a list of people who contributed.
7 */
8
9/*
10 * NextStep has a problem with configure, undefine a few things:
11 */
12#ifdef NeXT
13# ifdef HAVE_UTIME
14# undef HAVE_UTIME
15# endif
16# ifdef HAVE_SYS_UTSNAME_H
17# undef HAVE_SYS_UTSNAME_H
18# endif
19#endif
20
21#include <stdio.h>
22#include <ctype.h>
23
24#ifdef VAXC
25# include <types.h>
26# include <stat.h>
27#else
28# include <sys/types.h>
29# include <sys/stat.h>
30#endif
31
32#ifdef HAVE_STDLIB_H
33# include <stdlib.h>
34#endif
35
Bram Moolenaar6ef8f9e2019-03-02 07:15:28 +010036#ifdef __CYGWIN__
Bram Moolenaar9bf703d2019-11-30 19:44:38 +010037# define WIN32UNIX // Compiling for Win32 using Unix files.
Bram Moolenaar071d4272004-06-13 20:20:40 +000038# define BINARY_FILE_IO
Bram Moolenaar24552be2005-12-10 20:17:30 +000039
40# define CASE_INSENSITIVE_FILENAME
Bram Moolenaar9bf703d2019-11-30 19:44:38 +010041# define USE_FNAME_CASE // Fix filename case differences.
Bram Moolenaar071d4272004-06-13 20:20:40 +000042#endif
43
Bram Moolenaar9bf703d2019-11-30 19:44:38 +010044// On AIX 4.2 there is a conflicting prototype for ioctl() in stropts.h and
45// unistd.h. This hack should fix that (suggested by Jeff George).
46// But on AIX 4.3 it's alright (suggested by Jake Hamby).
Bram Moolenaar071d4272004-06-13 20:20:40 +000047#if defined(FEAT_GUI) && defined(_AIX) && !defined(_AIX43) && !defined(_NO_PROTO)
48# define _NO_PROTO
49#endif
50
51#ifdef HAVE_UNISTD_H
Bram Moolenaar8f0b2d42009-05-16 14:41:10 +000052# include <unistd.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +000053#endif
54
55#ifdef HAVE_LIBC_H
Bram Moolenaar9bf703d2019-11-30 19:44:38 +010056# include <libc.h> // for NeXT
Bram Moolenaar071d4272004-06-13 20:20:40 +000057#endif
58
59#ifdef HAVE_SYS_PARAM_H
Bram Moolenaar9bf703d2019-11-30 19:44:38 +010060# include <sys/param.h> // defines BSD, if it's a BSD system
Bram Moolenaar071d4272004-06-13 20:20:40 +000061#endif
62
63/*
Bram Moolenaar071d4272004-06-13 20:20:40 +000064 * Using getcwd() is preferred, because it checks for a buffer overflow.
65 * Don't use getcwd() on systems do use system("sh -c pwd"). There is an
66 * autoconf check for this.
67 * Use getcwd() anyway if getwd() isn't present.
68 */
69#if defined(HAVE_GETCWD) && !(defined(BAD_GETCWD) && defined(HAVE_GETWD))
70# define USE_GETCWD
71#endif
72
Bram Moolenaar9bf703d2019-11-30 19:44:38 +010073// always use unlink() to remove files
Bram Moolenaar071d4272004-06-13 20:20:40 +000074#ifndef PROTO
75# ifdef VMS
Bram Moolenaar82c38fe2021-01-04 10:47:26 +010076# define vim_mkdir(x, y) mkdir((char *)vms_fixfilename(x), y)
77# define mch_rmdir(x) delete((char *)vms_fixfilename(x))
78# define mch_remove(x) delete((char *)vms_fixfilename(x))
Bram Moolenaar071d4272004-06-13 20:20:40 +000079# else
80# define vim_mkdir(x, y) mkdir((char *)(x), y)
81# define mch_rmdir(x) rmdir((char *)(x))
82# define mch_remove(x) unlink((char *)(x))
83# endif
84#endif
85
Bram Moolenaar9bf703d2019-11-30 19:44:38 +010086// The number of arguments to a signal handler is configured here.
87// It used to be a long list of almost all systems. Any system that doesn't
88// have an argument???
Bram Moolenaar071d4272004-06-13 20:20:40 +000089#define SIGHASARG
90
Bram Moolenaar9bf703d2019-11-30 19:44:38 +010091// List 3 arg systems here. I guess __sgi, please test and correct me. jw.
Bram Moolenaar071d4272004-06-13 20:20:40 +000092#if defined(__sgi) && defined(HAVE_SIGCONTEXT)
93# define SIGHAS3ARGS
94#endif
95
96#ifdef SIGHASARG
97# ifdef SIGHAS3ARGS
98# define SIGPROTOARG (int, int, struct sigcontext *)
Yegappan Lakshmanand2b98ab2021-09-18 12:15:08 +020099# define SIGDEFARG(s) (int s, int sig2, struct sigcontext *scont)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000100# define SIGDUMMYARG 0, 0, (struct sigcontext *)0
101# else
102# define SIGPROTOARG (int)
Yegappan Lakshmanand2b98ab2021-09-18 12:15:08 +0200103# define SIGDEFARG(s) (int s UNUSED)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000104# define SIGDUMMYARG 0
105# endif
106#else
107# define SIGPROTOARG (void)
108# define SIGDEFARG(s) ()
109# define SIGDUMMYARG
110#endif
111
112#ifdef HAVE_DIRENT_H
113# include <dirent.h>
114# ifndef NAMLEN
115# define NAMLEN(dirent) strlen((dirent)->d_name)
116# endif
117#else
118# define dirent direct
119# define NAMLEN(dirent) (dirent)->d_namlen
120# if HAVE_SYS_NDIR_H
121# include <sys/ndir.h>
122# endif
123# if HAVE_SYS_DIR_H
124# include <sys/dir.h>
125# endif
126# if HAVE_NDIR_H
127# include <ndir.h>
128# endif
129#endif
130
Bram Moolenaar300d7182022-06-20 12:01:10 +0100131#include <time.h>
Bram Moolenaar071d4272004-06-13 20:20:40 +0000132#ifdef HAVE_SYS_TIME_H
133# include <sys/time.h>
134#endif
135
136#include <signal.h>
137
138#if defined(DIRSIZ) && !defined(MAXNAMLEN)
139# define MAXNAMLEN DIRSIZ
140#endif
141
142#if defined(UFS_MAXNAMLEN) && !defined(MAXNAMLEN)
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100143# define MAXNAMLEN UFS_MAXNAMLEN // for dynix/ptx
Bram Moolenaar071d4272004-06-13 20:20:40 +0000144#endif
145
146#if defined(NAME_MAX) && !defined(MAXNAMLEN)
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100147# define MAXNAMLEN NAME_MAX // for Linux before .99p3
Bram Moolenaar071d4272004-06-13 20:20:40 +0000148#endif
149
150/*
151 * Note: if MAXNAMLEN has the wrong value, you will get error messages
152 * for not being able to open the swap file.
153 */
154#if !defined(MAXNAMLEN)
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100155# define MAXNAMLEN 512 // for all other Unix
Bram Moolenaar071d4272004-06-13 20:20:40 +0000156#endif
157
158#define BASENAMELEN (MAXNAMLEN - 5)
159
Bram Moolenaar071d4272004-06-13 20:20:40 +0000160#ifdef HAVE_PWD_H
161# include <pwd.h>
162#endif
163
Bram Moolenaar071d4272004-06-13 20:20:40 +0000164#if (defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_GETRLIMIT)) \
165 || (defined(HAVE_SYS_SYSINFO_H) && defined(HAVE_SYSINFO)) \
166 || defined(HAVE_SYSCTL) || defined(HAVE_SYSCONF)
167# define HAVE_TOTAL_MEM
168#endif
169
Bram Moolenaar82881492012-11-20 16:53:39 +0100170
171#ifndef PROTO
172
Bram Moolenaar071d4272004-06-13 20:20:40 +0000173#ifdef VMS
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000174# include <unixio.h>
175# include <unixlib.h>
176# include <signal.h>
177# include <file.h>
178# include <ssdef.h>
179# include <descrip.h>
180# include <libclidef.h>
181# include <lnmdef.h>
182# include <psldef.h>
183# include <prvdef.h>
184# include <dvidef.h>
185# include <dcdef.h>
186# include <stsdef.h>
187# include <iodef.h>
188# include <ttdef.h>
189# include <tt2def.h>
190# include <jpidef.h>
191# include <rms.h>
192# include <trmdef.h>
193# include <string.h>
194# include <starlet.h>
195# include <socket.h>
196# include <lib$routines.h>
Bram Moolenaar4ffa0702013-12-11 17:12:37 +0100197# include <libdef.h>
198# include <libdtdef.h>
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000199
Bram Moolenaar467676d2020-12-30 13:14:45 +0100200# if defined(FEAT_GUI_MOTIF)
201# define XFree XFREE
202# define XmRepTypeInstallTearOffModelCon XMREPTYPEINSTALLTEAROFFMODELCON
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000203# endif
Bram Moolenaar467676d2020-12-30 13:14:45 +0100204#endif // VMS
Bram Moolenaar071d4272004-06-13 20:20:40 +0000205
Bram Moolenaarb2d0e512020-05-07 18:37:03 +0200206#ifdef HAVE_FLOCK
207# include <sys/file.h>
208#endif
209
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100210#endif // PROTO
Bram Moolenaar82881492012-11-20 16:53:39 +0100211
212#ifdef VMS
Bram Moolenaar071d4272004-06-13 20:20:40 +0000213typedef struct dsc$descriptor DESC;
214#endif
215
216/*
217 * Unix system-dependent file names
218 */
219#ifndef SYS_VIMRC_FILE
220# define SYS_VIMRC_FILE "$VIM/vimrc"
221#endif
222#ifndef SYS_GVIMRC_FILE
223# define SYS_GVIMRC_FILE "$VIM/gvimrc"
224#endif
225#ifndef DFLT_HELPFILE
226# define DFLT_HELPFILE "$VIMRUNTIME/doc/help.txt"
227#endif
228#ifndef FILETYPE_FILE
229# define FILETYPE_FILE "filetype.vim"
230#endif
231#ifndef FTPLUGIN_FILE
232# define FTPLUGIN_FILE "ftplugin.vim"
233#endif
234#ifndef INDENT_FILE
235# define INDENT_FILE "indent.vim"
236#endif
237#ifndef FTOFF_FILE
238# define FTOFF_FILE "ftoff.vim"
239#endif
240#ifndef FTPLUGOF_FILE
241# define FTPLUGOF_FILE "ftplugof.vim"
242#endif
243#ifndef INDOFF_FILE
244# define INDOFF_FILE "indoff.vim"
245#endif
246#ifndef SYS_MENU_FILE
247# define SYS_MENU_FILE "$VIMRUNTIME/menu.vim"
248#endif
249
250#ifndef USR_EXRC_FILE
251# ifdef VMS
252# define USR_EXRC_FILE "sys$login:.exrc"
253# else
254# define USR_EXRC_FILE "$HOME/.exrc"
255# endif
256#endif
257
Bram Moolenaar071d4272004-06-13 20:20:40 +0000258#if !defined(USR_EXRC_FILE2) && defined(VMS)
259# define USR_EXRC_FILE2 "sys$login:_exrc"
260#endif
261
262#ifndef USR_VIMRC_FILE
263# ifdef VMS
264# define USR_VIMRC_FILE "sys$login:.vimrc"
265# else
266# define USR_VIMRC_FILE "$HOME/.vimrc"
267# endif
268#endif
269
Bram Moolenaar22971aa2013-06-12 20:35:58 +0200270
Bram Moolenaarea98f8b2015-05-04 09:31:11 +0200271#if !defined(USR_VIMRC_FILE2)
Bram Moolenaare7fedb62015-12-31 19:07:19 +0100272# ifdef VMS
273# define USR_VIMRC_FILE2 "sys$login:vimfiles/vimrc"
Bram Moolenaar22971aa2013-06-12 20:35:58 +0200274# else
Bram Moolenaare7fedb62015-12-31 19:07:19 +0100275# define USR_VIMRC_FILE2 "~/.vim/vimrc"
Bram Moolenaar22971aa2013-06-12 20:35:58 +0200276# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000277#endif
Bram Moolenaar22971aa2013-06-12 20:35:58 +0200278
Bram Moolenaar22971aa2013-06-12 20:35:58 +0200279#if !defined(USR_VIMRC_FILE3) && defined(VMS)
280# define USR_VIMRC_FILE3 "sys$login:_vimrc"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000281#endif
282
283#ifndef USR_GVIMRC_FILE
284# ifdef VMS
285# define USR_GVIMRC_FILE "sys$login:.gvimrc"
286# else
287# define USR_GVIMRC_FILE "$HOME/.gvimrc"
288# endif
289#endif
290
Bram Moolenaar22971aa2013-06-12 20:35:58 +0200291#ifndef USR_GVIMRC_FILE2
Bram Moolenaare7fedb62015-12-31 19:07:19 +0100292# ifdef VMS
293# define USR_GVIMRC_FILE2 "sys$login:vimfiles/gvimrc"
Bram Moolenaar22971aa2013-06-12 20:35:58 +0200294# else
Bram Moolenaare7fedb62015-12-31 19:07:19 +0100295# define USR_GVIMRC_FILE2 "~/.vim/gvimrc"
Bram Moolenaar22971aa2013-06-12 20:35:58 +0200296# endif
297#endif
298
Bram Moolenaar071d4272004-06-13 20:20:40 +0000299#ifdef VMS
Bram Moolenaar22971aa2013-06-12 20:35:58 +0200300# ifndef USR_GVIMRC_FILE3
301# define USR_GVIMRC_FILE3 "sys$login:_gvimrc"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000302# endif
303#endif
304
Bram Moolenaar8c08b5b2016-07-28 22:24:15 +0200305#ifndef VIM_DEFAULTS_FILE
306# define VIM_DEFAULTS_FILE "$VIMRUNTIME/defaults.vim"
307#endif
308
Bram Moolenaar071d4272004-06-13 20:20:40 +0000309#ifndef EVIM_FILE
310# define EVIM_FILE "$VIMRUNTIME/evim.vim"
311#endif
312
313#ifdef FEAT_VIMINFO
314# ifndef VIMINFO_FILE
315# ifdef VMS
316# define VIMINFO_FILE "sys$login:.viminfo"
317# else
318# define VIMINFO_FILE "$HOME/.viminfo"
319# endif
320# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000321# if !defined(VIMINFO_FILE2) && defined(VMS)
322# define VIMINFO_FILE2 "sys$login:_viminfo"
323# endif
324#endif
325
326#ifndef EXRC_FILE
327# define EXRC_FILE ".exrc"
328#endif
329
330#ifndef VIMRC_FILE
331# define VIMRC_FILE ".vimrc"
332#endif
333
334#ifdef FEAT_GUI
335# ifndef GVIMRC_FILE
336# define GVIMRC_FILE ".gvimrc"
337# endif
338#endif
339
340#ifndef SYNTAX_FNAME
341# define SYNTAX_FNAME "$VIMRUNTIME/syntax/%s.vim"
342#endif
343
344#ifndef DFLT_BDIR
Bram Moolenaare7fedb62015-12-31 19:07:19 +0100345# ifdef VMS
346# define DFLT_BDIR "./,sys$login:,tmp:"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000347# else
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100348# define DFLT_BDIR ".,~/tmp,~/" // default for 'backupdir'
Bram Moolenaar071d4272004-06-13 20:20:40 +0000349# endif
350#endif
351
352#ifndef DFLT_DIR
Bram Moolenaare7fedb62015-12-31 19:07:19 +0100353# ifdef VMS
354# define DFLT_DIR "./,sys$login:,tmp:"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000355# else
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100356# define DFLT_DIR ".,~/tmp,/var/tmp,/tmp" // default for 'directory'
Bram Moolenaar071d4272004-06-13 20:20:40 +0000357# endif
358#endif
359
360#ifndef DFLT_VDIR
Bram Moolenaare7fedb62015-12-31 19:07:19 +0100361# ifdef VMS
362# define DFLT_VDIR "sys$login:vimfiles/view"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000363# else
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100364# define DFLT_VDIR "$HOME/.vim/view" // default for 'viewdir'
Bram Moolenaar071d4272004-06-13 20:20:40 +0000365# endif
366#endif
367
368#define DFLT_ERRORFILE "errors.err"
369
Bram Moolenaarb3f74062020-02-26 16:16:53 +0100370#ifndef DFLT_RUNTIMEPATH
371
372# ifdef VMS
373# define DFLT_RUNTIMEPATH "sys$login:vimfiles,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,sys$login:vimfiles/after"
374# define CLEAN_RUNTIMEPATH "$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000375# else
Bram Moolenaarb3f74062020-02-26 16:16:53 +0100376# ifdef RUNTIME_GLOBAL
377# ifdef RUNTIME_GLOBAL_AFTER
378# define DFLT_RUNTIMEPATH "~/.vim," RUNTIME_GLOBAL ",$VIMRUNTIME," RUNTIME_GLOBAL_AFTER ",~/.vim/after"
379# define CLEAN_RUNTIMEPATH RUNTIME_GLOBAL ",$VIMRUNTIME," RUNTIME_GLOBAL_AFTER
380# else
381# define DFLT_RUNTIMEPATH "~/.vim," RUNTIME_GLOBAL ",$VIMRUNTIME," RUNTIME_GLOBAL "/after,~/.vim/after"
382# define CLEAN_RUNTIMEPATH RUNTIME_GLOBAL ",$VIMRUNTIME," RUNTIME_GLOBAL "/after"
383# endif
384# else
385# define DFLT_RUNTIMEPATH "~/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,~/.vim/after"
386# define CLEAN_RUNTIMEPATH "$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after"
387# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000388# endif
Bram Moolenaarb3f74062020-02-26 16:16:53 +0100389
Bram Moolenaar071d4272004-06-13 20:20:40 +0000390#endif
391
Bram Moolenaare7fedb62015-12-31 19:07:19 +0100392#ifdef VMS
393# ifndef VAX
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100394# define VMS_TEMPNAM // to fix default .LIS extension
Bram Moolenaar071d4272004-06-13 20:20:40 +0000395# endif
Bram Moolenaare7fedb62015-12-31 19:07:19 +0100396# define TEMPNAME "TMP:v?XXXXXX.txt"
397# define TEMPNAMELEN 28
398#else
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100399// Try several directories to put the temp files.
Bram Moolenaare7fedb62015-12-31 19:07:19 +0100400# define TEMPDIRNAMES "$TMPDIR", "/tmp", ".", "$HOME"
401# define TEMPNAMELEN 256
Bram Moolenaar071d4272004-06-13 20:20:40 +0000402#endif
403
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100404// Special wildcards that need to be handled by the shell
Bram Moolenaar071d4272004-06-13 20:20:40 +0000405#define SPECIAL_WILDCHAR "`'{"
406
Bram Moolenaar071d4272004-06-13 20:20:40 +0000407/*
408 * Unix has plenty of memory, use large buffers
409 */
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100410#define CMDBUFFSIZE 1024 // size of the command processing buffer
Bram Moolenaar38f12a92008-06-20 16:07:02 +0000411
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100412// Use the system path length if it makes sense.
Bram Moolenaar38f12a92008-06-20 16:07:02 +0000413#if defined(PATH_MAX) && (PATH_MAX > 1000)
414# define MAXPATHL PATH_MAX
415#else
416# define MAXPATHL 1024
417#endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000418
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100419#define CHECK_INODE // used when checking if a swap file already
420 // exists for a file
421#ifdef VMS // Use less memory because of older systems
Bram Moolenaar071d4272004-06-13 20:20:40 +0000422# ifndef DFLT_MAXMEM
423# define DFLT_MAXMEM (2*1024)
424# endif
425# ifndef DFLT_MAXMEMTOT
426# define DFLT_MAXMEMTOT (5*1024)
427# endif
428#else
429# ifndef DFLT_MAXMEM
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100430# define DFLT_MAXMEM (5*1024) // use up to 5 Mbyte for a buffer
Bram Moolenaar071d4272004-06-13 20:20:40 +0000431# endif
432# ifndef DFLT_MAXMEMTOT
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100433# define DFLT_MAXMEMTOT (10*1024) // use up to 10 Mbyte for Vim
Bram Moolenaar071d4272004-06-13 20:20:40 +0000434# endif
435#endif
436
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100437// memmove() is not present on all systems, use memmove, bcopy or memcpy.
438// Some systems have (void *) arguments, some (char *). If we use (char *) it
439// works for all
Bram Moolenaar52c0de12017-01-26 21:36:34 +0100440#if defined(USEMEMMOVE) || (!defined(USEBCOPY) && !defined(USEMEMCPY))
Bram Moolenaar071d4272004-06-13 20:20:40 +0000441# define mch_memmove(to, from, len) memmove((char *)(to), (char *)(from), len)
442#else
443# ifdef USEBCOPY
444# define mch_memmove(to, from, len) bcopy((char *)(from), (char *)(to), len)
445# else
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100446 // ifdef USEMEMCPY
Bram Moolenaar071d4272004-06-13 20:20:40 +0000447# define mch_memmove(to, from, len) memcpy((char *)(to), (char *)(from), len)
Bram Moolenaar071d4272004-06-13 20:20:40 +0000448# endif
449#endif
450
451#ifndef PROTO
452# ifdef HAVE_RENAME
453# define mch_rename(src, dst) rename(src, dst)
454# else
Bram Moolenaard99df422016-01-29 23:20:40 +0100455int mch_rename(const char *src, const char *dest);
Bram Moolenaar071d4272004-06-13 20:20:40 +0000456# endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000457# ifndef VMS
458# ifdef __MVS__
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100459 // on OS390 Unix getenv() doesn't return a pointer to persistent
460 // storage -> use __getenv()
Bram Moolenaar071d4272004-06-13 20:20:40 +0000461# define mch_getenv(x) (char_u *)__getenv((char *)(x))
462# else
463# define mch_getenv(x) (char_u *)getenv((char *)(x))
464# endif
465# define mch_setenv(name, val, x) setenv(name, val, x)
466# endif
467#endif
468
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100469// Note: Some systems need both string.h and strings.h (Savage). However,
470// some systems can't handle both, only use string.h in that case.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000471#ifdef HAVE_STRING_H
472# include <string.h>
473#endif
474#if defined(HAVE_STRINGS_H) && !defined(NO_STRINGS_WITH_STRING_H)
475# include <strings.h>
476#endif
477
478#if defined(HAVE_SETJMP_H)
479# include <setjmp.h>
480# ifdef HAVE_SIGSETJMP
481# define JMP_BUF sigjmp_buf
482# define SETJMP(x) sigsetjmp((x), 1)
483# define LONGJMP siglongjmp
484# else
485# define JMP_BUF jmp_buf
486# define SETJMP(x) setjmp(x)
487# define LONGJMP longjmp
488# endif
489#endif
490
Bram Moolenaarc41053062014-03-25 13:46:26 +0100491#ifndef HAVE_DUP
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100492# define HAVE_DUP // have dup()
Bram Moolenaarc41053062014-03-25 13:46:26 +0100493#endif
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100494#define HAVE_ST_MODE // have stat.st_mode
Bram Moolenaar071d4272004-06-13 20:20:40 +0000495
Bram Moolenaar9bf703d2019-11-30 19:44:38 +0100496// We have three kinds of ACL support.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000497#define HAVE_ACL (HAVE_POSIX_ACL || HAVE_SOLARIS_ACL || HAVE_AIX_ACL)