home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume26 / screen-3.5 / part02 / os.h < prev    next >
C/C++ Source or Header  |  1993-07-25  |  8KB  |  357 lines

  1. /* Copyright (c) 1993
  2.  *      Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
  3.  *      Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
  4.  * Copyright (c) 1987 Oliver Laumann
  5.  *
  6.  * This program is free software; you can redistribute it and/or modify
  7.  * it under the terms of the GNU General Public License as published by
  8.  * the Free Software Foundation; either version 2, or (at your option)
  9.  * any later version.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program (see the file COPYING); if not, write to the
  18.  * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  *
  20.  ****************************************************************
  21.  * $Id: os.h,v 1.1 1993/07/23 15:59:24 vixie Exp vixie $ FAU
  22.  */
  23.  
  24. #include <stdio.h>
  25. #include <errno.h>
  26. #include <sys/param.h>
  27.  
  28. #if defined(BSDI) || defined(__386BSD__) || defined(_CX_UX)
  29. # include <signal.h>
  30. #endif /* BSDI || __386BSD__ || _CX_UX */
  31.  
  32. #ifdef ISC
  33. # ifdef ENAMETOOLONG
  34. #  undef ENAMETOOLONG
  35. # endif
  36. # ifdef ENOTEMPTY
  37. #  undef ENOTEMPTY
  38. # endif
  39. # include <net/errno.h>
  40. #endif
  41.  
  42. #ifdef hpux
  43. # ifndef GETUTENT
  44. #  define GETUTENT 1
  45. # endif 
  46. #endif
  47.  
  48. #if defined(pyr) || defined(MIPS) || defined(GOULD_NP1) || defined(B43)
  49. extern int errno;
  50. #endif
  51. #ifndef linux /* all done in <errno.h> */
  52. extern int sys_nerr;
  53. extern char *sys_errlist[];
  54. #endif /* linux */
  55.  
  56. #ifdef sun
  57. # define getpgrp __getpgrp
  58. # define exit __exit
  59. #endif
  60.  
  61. #ifdef POSIX
  62. # include <unistd.h>
  63. # if defined(__STDC__)
  64. #  include <stdlib.h>
  65. # endif /* __STDC__ */
  66. #endif /* POSIX */
  67.  
  68. #ifdef sun
  69. # undef getpgrp
  70. # undef exit
  71. #endif /* sun */
  72.  
  73. #ifdef POSIX
  74. # include <termios.h>
  75. # ifdef hpux
  76. #  include <bsdtty.h>
  77. # endif /* hpux */
  78. #else /* POSIX */
  79. # ifdef TERMIO
  80. #  include <termio.h>
  81. # else /* TERMIO */
  82. #  include <sgtty.h>
  83. # endif /* TERMIO */
  84. #endif /* POSIX */
  85.  
  86. #ifndef SYSV
  87. # ifdef NEWSOS
  88. #  define strlen ___strlen___
  89. #  include <strings.h>
  90. #  undef strlen
  91. # else /* NEWSOS */
  92. #  include <strings.h>
  93. # endif /* NEWSOS */
  94. #else /* BSD */
  95. # if defined(SVR4) || defined(NEWSOS)
  96. #  define strlen ___strlen___
  97. #  include <string.h>
  98. #  undef strlen
  99. #  ifndef NEWSOS
  100.     extern size_t strlen(const char *);
  101. #  endif /* NEWSOS */
  102. # else /* SVR4 */
  103. #  include <string.h>
  104. # endif /* SVR4 */
  105. #endif /* BSD */
  106.  
  107. #if (defined(TIOCGWINSZ) || defined(TIOCSWINSZ)) && defined(M_UNIX)
  108. # include <sys/stream.h>
  109. # include <sys/ptem.h>
  110. #endif
  111.  
  112. #ifdef UTMPOK
  113. # ifdef SVR4
  114. #  include <utmpx.h>
  115. #  define UTMPFILE    UTMPX_FILE
  116. #  define utmp        utmpx
  117. #  define getutent    getutxent
  118. #  define getutid    getutxid
  119. #  define getutline    getutxline
  120. #  define pututline    pututxline
  121. #  define setutent    setutxent
  122. #  define endutent    endutxent
  123. #  ifdef sun
  124. #   define ut_time    ut_xtime
  125. #  endif
  126. # else /* SVR4 */
  127. #  include <utmp.h>
  128. # endif /* SVR4 */
  129. # if defined(apollo) || defined(linux)
  130.    /* 
  131.     * We don't have GETUTENT, so we dig into utmp ourselves.
  132.     * But we save the permanent filedescriptor and
  133.     * open utmp just when we need to. 
  134.     * This code supports an unsorted utmp. jw.
  135.     */
  136. #  define UTNOKEEP
  137. # endif /* apollo || linux */
  138. #endif
  139.  
  140. #ifndef UTMPFILE
  141. # ifdef UTMP_FILE
  142. #  define UTMPFILE    UTMP_FILE
  143. # else
  144. #  ifdef _PATH_UTMP
  145. #   define UTMPFILE    _PATH_UTMP
  146. #  else
  147. #   define UTMPFILE    "/etc/utmp"
  148. #  endif /* _PATH_UTMP */
  149. # endif
  150. #endif
  151.  
  152. #ifndef UTMPOK
  153. #  ifdef USRLIMIT
  154. #     undef USRLIMIT
  155. #  endif
  156. #endif
  157.  
  158. #ifndef LOGINDEFAULT
  159. #  define LOGINDEFAULT 0
  160. #endif
  161.  
  162. #ifndef F_OK
  163. #define F_OK 0
  164. #endif
  165. #ifndef X_OK
  166. #define X_OK 1
  167. #endif
  168. #ifndef W_OK
  169. #define W_OK 2
  170. #endif
  171. #ifndef R_OK
  172. #define R_OK 4
  173. #endif
  174.  
  175. #ifndef S_IFIFO
  176. #define S_IFIFO  0010000
  177. #endif
  178. #ifndef S_IREAD
  179. #define S_IREAD  0000400
  180. #endif
  181. #ifndef S_IWRITE
  182. #define S_IWRITE 0000200
  183. #endif
  184. #ifndef S_IEXEC
  185. #define S_IEXEC  0000100
  186. #endif
  187.  
  188. #if defined(S_IFIFO) && defined(S_IFMT) && !defined(S_ISFIFO)
  189. #define S_ISFIFO(mode) ((mode & S_IFMT) == S_IFIFO)
  190. #endif
  191. #if defined(S_IFSOCK) && defined(S_IFMT) && !defined(S_ISSOCK)
  192. #define S_ISSOCK(mode) ((mode & S_IFMT) == S_IFSOCK)
  193. #endif
  194.  
  195. #ifndef TERMCAP_BUFSIZE
  196. # define TERMCAP_BUFSIZE 1024
  197. #endif
  198.  
  199. #ifndef MAXPATHLEN
  200. # define MAXPATHLEN 1024
  201. #endif
  202.  
  203. #ifndef SIG_T_DEFINED
  204. # ifdef SIGVOID
  205. #  if defined(ultrix)
  206. #   define sig_t void
  207. #  else /* nice compilers: */
  208.     typedef void sig_t;
  209. #  endif
  210. # else
  211.    typedef int sig_t; /* (* sig_t) */
  212. # endif
  213. #endif /* SIG_T_DEFINED */
  214.  
  215. #if defined(SVR4) || (defined(SYSV) && defined(ISC)) || defined(_AIX) || defined(linux) || defined(ultrix) || defined(__386BSD__) || defined(BSDI)
  216. # define SIGPROTOARG   (int)
  217. # define SIGDEFARG     int sigsig
  218. # define SIGARG        0
  219. #else
  220. # define SIGPROTOARG   (void)
  221. # define SIGDEFARG
  222. # define SIGARG
  223. #endif
  224.  
  225. #ifndef SIGCHLD
  226. #define SIGCHLD SIGCLD
  227. #endif
  228.  
  229. #ifdef USESIGSET
  230. # define signal sigset
  231. #endif /* USESIGSET */
  232.  
  233. #ifndef PID_T_DEFINED
  234. typedef int pid_t;
  235. #endif
  236.  
  237. #ifndef UID_T_DEFINED
  238. typedef int gid_t;
  239. typedef int uid_t;
  240. #endif
  241.  
  242. #ifdef GETUTENT
  243.   typedef char *slot_t;
  244. #else
  245.   typedef int slot_t;
  246. #endif
  247.  
  248. #ifdef SYSV
  249. # define index strchr
  250. # define rindex strrchr
  251. # define bzero(poi,len) memset(poi,0,len)
  252. # define bcmp memcmp
  253. # define killpg(pgrp,sig) kill( -(pgrp), sig)
  254. #endif /* SYSV */
  255.  
  256. #ifndef USEBCOPY
  257. # ifdef USEMEMCPY
  258. #  define bcopy(s,d,len) memcpy(d,s,len)
  259. # else
  260. #  ifdef USEMEMMOVE
  261. #   define bcopy(s,d,len) memmove(d,s,len)
  262. #  else
  263. #   define NEED_OWN_BCOPY
  264. #  endif
  265. # endif
  266. #endif
  267.  
  268. #if defined(_POSIX_SOURCE) && defined(ISC)
  269. # ifndef O_NDELAY
  270. #  define O_NDELAY O_NONBLOCK
  271. # endif
  272. #endif
  273.  
  274. #ifdef hpux
  275. # define setreuid(ruid, euid) setresuid(ruid, euid, -1)
  276. # define setregid(rgid, egid) setresgid(rgid, egid, -1)
  277. #endif
  278.  
  279. #if !defined(m68k) && !defined(M_XENIX)
  280. # include <sys/wait.h>
  281. #endif
  282.  
  283. #ifndef WTERMSIG
  284. # ifndef BSDWAIT /* if wait is NOT a union: */
  285. #  define WTERMSIG(status) (status & 0177)
  286. # else
  287. #  define WTERMSIG(status) status.w_T.w_Termsig 
  288. # endif
  289. #endif
  290.  
  291. #ifndef WSTOPSIG
  292. # ifndef BSDWAIT /* if wait is NOT a union: */
  293. #  define WSTOPSIG(status) ((status >> 8) & 0377)
  294. # else
  295. #  define WSTOPSIG(status) status.w_S.w_Stopsig 
  296. # endif
  297. #endif
  298.  
  299. /* NET-2 uses WCOREDUMP */
  300. #if defined(WCOREDUMP) && !defined(WIFCORESIG)
  301. # define WIFCORESIG(status) WCOREDUMP(status)
  302. #endif
  303.  
  304. #ifndef WIFCORESIG
  305. # ifndef BSDWAIT /* if wait is NOT a union: */
  306. #  define WIFCORESIG(status) (status & 0200)
  307. # else
  308. #  define WIFCORESIG(status) status.w_T.w_Coredump
  309. # endif
  310. #endif
  311.  
  312. #ifndef WEXITSTATUS
  313. # ifndef BSDWAIT /* if wait is NOT a union: */
  314. #  define WEXITSTATUS(status) ((status >> 8) & 0377)
  315. # else
  316. #  define WEXITSTATUS(status) status.w_T.w_Retcode
  317. # endif
  318. #endif
  319.  
  320. #if defined(sgi) 
  321. /* on IRIX, regardless of the stream head's read mode (RNORM/RMSGN/RMSGD)
  322.  * TIOCPKT mode causes data loss if our buffer is too small (IOSIZE)
  323.  * to hold the whole packet at first read().
  324.  * (Marc Boucher)
  325.  */
  326. # undef TIOCPKT
  327. #endif
  328.  
  329. #if !defined(VDISABLE)
  330. # ifdef _POSIX_VDISABLE
  331. #  define VDISABLE _POSIX_VDISABLE
  332. # else
  333. #  define VDISABLE 0377
  334. # endif /* _POSIX_VDISABLE */
  335. #endif /* !VDISABLE */
  336.  
  337. #if !defined(FNDELAY) && defined(O_NDELAY)
  338. # define FNDELAY O_NDELAY
  339. #endif
  340.  
  341. /*typedef long off_t; */    /* Someone might need this */
  342.  
  343.  
  344. /* 
  345.  * 4 <= IOSIZE <=1000
  346.  * you may try to vary this value. Use low values if your (VMS) system
  347.  * tends to choke when pasting. Use high values if you want to test
  348.  * how many characters your pty's can buffer.
  349.  */
  350. #define IOSIZE        4096
  351.  
  352. /* used in screen.c and attacher.c */
  353. #if !defined(NSIG)    /* kbeal needs these w/o SYSV */
  354. # define NSIG 32
  355. #endif /* !NSIG */
  356.  
  357.