Annotation of src/usr.bin/vim/unix.h, Revision 1.2
1.2 ! downsj 1: /* $OpenBSD: unix.h,v 1.1.1.1 1996/09/07 21:40:27 downsj Exp $ */
1.1 downsj 2: /* vi:set ts=4 sw=4:
3: *
4: * VIM - Vi IMproved by Bram Moolenaar
5: *
6: * Do ":help uganda" in Vim to read copying and usage conditions.
7: * Do ":help credits" in Vim to see a list of people who contributed.
8: */
9:
10: #include <stdio.h>
11: #include <ctype.h>
12: #include <sys/types.h>
13: #include <sys/stat.h>
14:
15: #ifdef HAVE_STDLIB_H
16: # include <stdlib.h>
17: #endif
18:
19: #ifdef HAVE_UNISTD_H
20: # include <unistd.h>
21: #endif
22:
23: #ifdef HAVE_LIBC_H
24: # include <libc.h> /* for NeXT */
25: #endif
26:
27: /*
28: * SVR4 may be defined for linux, but linux isn't SVR4
29: */
30: #if defined(SVR4) && defined(__linux__)
31: # undef SVR4
32: #endif
33:
34: /*
35: * Sun defines FILE on SunOS 4.x.x, Solaris has a typedef for FILE
36: */
37: #if defined(sun) && !defined(FILE)
38: # define SOLARIS
39: #endif
40:
41: /*
42: * Using getcwd() is preferred, because it checks for a buffer overflow.
43: * Don't use getcwd() on systems do use system("sh -c pwd"). There is an
44: * autoconf check for this.
45: * Use getcwd() anyway if getwd() isn't present.
46: */
47: #if defined(HAVE_GETCWD) && !(defined(BAD_GETCWD) && defined(HAVE_GETWD))
48: # define USE_GETCWD
49: #endif
50:
51: #ifndef __ARGS
52: # if defined(__STDC__) || defined(__GNUC__)
53: # define __ARGS(x) x
54: # else
55: # define __ARGS(x) ()
56: # endif
57: #endif
58:
59: /* always use unlink() to remove files */
60: #define vim_remove(x) unlink((char *)(x))
61:
62: /* The number of arguments to a signal handler is configured here. */
63: /* It used to be a long list of almost all systems. Any system that doesn't
64: * have an argument??? */
65: /* #if defined(SVR4) || (defined(SYSV) && defined(ISC)) || defined(_AIX) || defined(__linux__) || defined(ultrix) || defined(__386BSD__) || defined(__FreeBSD__) || defined(__bsdi__) || defined(POSIX) || defined(NeXT) || defined(__alpha) || defined(apollo) */
66: #if !defined(SOME_SYSTEM)
67: # define SIGHASARG
68: #endif
69:
70: /* List 3 arg systems here. I guess __sgi, please test and correct me. jw. */
71: #if defined(__sgi)
72: # define SIGHAS3ARGS
73: #endif
74:
75: #ifdef SIGHASARG
76: # ifdef SIGHAS3ARGS
77: # define SIGPROTOARG (int, int, struct sigcontext *)
78: # define SIGDEFARG(s) (s, sig2, scont) int s, sig2; struct sigcontext *scont;
79: # define SIGDUMMYARG 0, 0, (struct sigcontext *)0
80: # else
81: # define SIGPROTOARG (int)
82: # define SIGDEFARG(s) (s) int s;
83: # define SIGDUMMYARG 0
84: # endif
85: #else
86: # define SIGPROTOARG (void)
87: # define SIGDEFARG(s) ()
88: # define SIGDUMMYARG
89: #endif
90:
91: #if HAVE_DIRENT_H
92: # include <dirent.h>
1.2 ! downsj 93: # ifndef NAMLEN
1.1 downsj 94: # define NAMLEN(dirent) strlen((dirent)->d_name)
1.2 ! downsj 95: # endif
1.1 downsj 96: #else
97: # define dirent direct
98: # define NAMLEN(dirent) (dirent)->d_namlen
99: # if HAVE_SYS_NDIR_H
100: # include <sys/ndir.h>
101: # endif
102: # if HAVE_SYS_DIR_H
103: # include <sys/dir.h>
104: # endif
105: # if HAVE_NDIR_H
106: # include <ndir.h>
107: # endif
108: #endif
109:
110: #if !defined(HAVE_SYS_TIME_H) || defined(TIME_WITH_SYS_TIME)
111: # include <time.h> /* on some systems time.h should not be
112: included together with sys/time.h */
113: #endif
114: #ifdef HAVE_SYS_TIME_H
115: # include <sys/time.h>
116: #endif
117:
118: #include <signal.h>
119:
120: #if defined(DIRSIZ) && !defined(MAXNAMLEN)
121: # define MAXNAMLEN DIRSIZ
122: #endif
123:
124: #if defined(UFS_MAXNAMLEN) && !defined(MAXNAMLEN)
125: # define MAXNAMLEN UFS_MAXNAMLEN /* for dynix/ptx */
126: #endif
127:
128: #if defined(NAME_MAX) && !defined(MAXNAMLEN)
129: # define MAXNAMLEN NAME_MAX /* for Linux before .99p3 */
130: #endif
131:
132: /*
133: * Note: if MAXNAMLEN has the wrong value, you will get error messages
134: * for not being able to open the swap file.
135: */
136: #if !defined(MAXNAMLEN)
137: # define MAXNAMLEN 512 /* for all other Unix */
138: #endif
139:
1.2 ! downsj 140: #define BASENAMELEN (MAXNAMLEN - 5)
! 141:
1.1 downsj 142: #ifdef HAVE_ERRNO_H
143: # include <errno.h>
144: #endif
145:
146: #ifdef HAVE_PWD_H
147: # include <pwd.h>
148: #endif
149:
150: #ifdef __COHERENT__
151: # undef __ARGS
152: #endif /* __COHERENT__ */
153:
154: #ifndef W_OK
155: # define W_OK 2 /* for systems that don't have W_OK in unistd.h */
156: #endif
157:
158: /*
159: * Unix system-dependent filenames
160: */
161:
162: #ifndef USR_EXRC_FILE
163: # define USR_EXRC_FILE "$HOME/.exrc"
164: #endif
165:
166: #ifndef USR_VIMRC_FILE
167: # define USR_VIMRC_FILE "$HOME/.vimrc"
168: #endif
169:
170: #ifdef USE_GUI
171: # ifndef USR_GVIMRC_FILE
172: # define USR_GVIMRC_FILE "$HOME/.gvimrc"
173: # endif
174: #endif
175:
176: #ifndef EXRC_FILE
177: # define EXRC_FILE ".exrc"
178: #endif
179:
180: #ifndef VIMRC_FILE
181: # define VIMRC_FILE ".vimrc"
182: #endif
183:
184: #ifdef USE_GUI
185: # ifndef GVIMRC_FILE
186: # define GVIMRC_FILE ".gvimrc"
187: # endif
188: #endif
189:
190: #ifdef VIMINFO
191: # ifndef VIMINFO_FILE
192: # define VIMINFO_FILE "$HOME/.viminfo"
193: # endif
194: #endif /* VIMINFO */
195:
196: #ifndef DEF_BDIR
197: # ifdef OS2
198: # define DEF_BDIR ".,c:/tmp,~/tmp,~/"
199: # else
200: # define DEF_BDIR ".,~/tmp,~/" /* default for 'backupdir' */
201: # endif
202: #endif
203:
204: #ifndef DEF_DIR
205: # ifdef OS2
206: # define DEF_DIR ".,~/tmp,c:/tmp,/tmp"
207: # else
208: # define DEF_DIR ".,~/tmp,/tmp" /* default for 'directory' */
209: # endif
210: #endif
211:
212: #ifdef OS2
1.2 ! downsj 213: /*
! 214: * Try several directories to put the temp files.
! 215: */
! 216: #define TEMPDIRNAMES "$TMP", "$TEMP", "c:\\TMP", "c:\\TEMP", ""
! 217: #define TEMPNAME "v?XXXXXX"
! 218: #define TEMPNAMELEN 128
1.1 downsj 219: #else
1.2 ! downsj 220: #define TEMPNAME "/tmp/v?XXXXXX"
! 221: #define TEMPNAMELEN 15
1.1 downsj 222: #endif
223:
224: /*
225: * Unix has plenty of memory, use large buffers
226: */
227: #define CMDBUFFSIZE 1024 /* size of the command processing buffer */
228: #define MAXPATHL 1024 /* Unix has long paths and plenty of memory */
229:
230: #define CHECK_INODE /* used when checking if a swap file already
231: exists for a file */
232: #define USE_MOUSE /* include mouse support */
233:
234: #ifndef MAXMEM
235: # define MAXMEM 512 /* use up to 512Kbyte for buffer */
236: #endif
237: #ifndef MAXMEMTOT
238: # define MAXMEMTOT 2048 /* use up to 2048Kbyte for Vim */
239: #endif
240:
241: /* memmove is not present on all systems, use memmove, bcopy, memcpy or our
242: * own version */
243: /* Some systems have (void *) arguments, some (char *). If we use (char *) it
244: * works for all */
245: #ifdef USEMEMMOVE
246: # define vim_memmove(to, from, len) memmove((char *)(to), (char *)(from), len)
247: #else
248: # ifdef USEBCOPY
249: # define vim_memmove(to, from, len) bcopy((char *)(from), (char *)(to), len)
250: # else
251: # ifdef USEMEMCPY
252: # define vim_memmove(to, from, len) memcpy((char *)(to), (char *)(from), len)
253: # else
254: # define VIM_MEMMOVE /* found in alloc.c */
255: # endif
256: # endif
257: #endif
258:
259: /* codes for xterm mouse event */
260: #define MOUSE_LEFT 0x00
261: #define MOUSE_MIDDLE 0x01
262: #define MOUSE_RIGHT 0x02
263: #define MOUSE_RELEASE 0x03
264: #define MOUSE_SHIFT 0x04
265: #define MOUSE_ALT 0x08
266: #define MOUSE_CTRL 0x10
267: #define MOUSE_DRAG (0x40 | MOUSE_RELEASE)
268:
269: #define MOUSE_CLICK_MASK 0x03
270:
271: #define NUM_MOUSE_CLICKS(code) \
272: ((((code) & 0xff) >> 6) + 1)
273:
274: #define SET_NUM_MOUSE_CLICKS(code, num) \
275: (code) = ((code) & 0x3f) + (((num) - 1) << 6)