home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / amiga / vim46src.lha / vim-4.6 / src / unix.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-04  |  6.2 KB  |  275 lines

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