home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume27 / screen-3.5.1 / part02 / os.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-08  |  8.5 KB  |  408 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.4 1993/08/05 14:23:53 mlschroe Exp $ 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. #ifndef linux /* all done in <errno.h> */
  49. extern int errno;
  50. extern int sys_nerr;
  51. extern char *sys_errlist[];
  52. #endif /* linux */
  53.  
  54. #ifdef sun
  55. # define getpgrp __getpgrp
  56. # define exit __exit
  57. #endif
  58.  
  59. #ifdef POSIX
  60. # include <unistd.h>
  61. # if defined(__STDC__)
  62. #  include <stdlib.h>
  63. # endif /* __STDC__ */
  64. #endif /* POSIX */
  65.  
  66. #ifdef sun
  67. # undef getpgrp
  68. # undef exit
  69. #endif /* sun */
  70.  
  71. #ifdef POSIX
  72. # include <termios.h>
  73. # ifdef hpux
  74. #  include <bsdtty.h>
  75. # endif /* hpux */
  76. # ifdef NCCS
  77. #  define MAXCC NCCS
  78. # else
  79. #  define MAXCC 256
  80. # endif
  81. #else /* POSIX */
  82. # ifdef TERMIO
  83. #  include <termio.h>
  84. #  ifdef NCC
  85. #   define MAXCC NCC
  86. #  else
  87. #   define MAXCC 256
  88. #  endif
  89. # else /* TERMIO */
  90. #  include <sgtty.h>
  91. # endif /* TERMIO */
  92. #endif /* POSIX */
  93.  
  94. #ifndef SYSV
  95. # ifdef NEWSOS
  96. #  define strlen ___strlen___
  97. #  include <strings.h>
  98. #  undef strlen
  99. # else /* NEWSOS */
  100. #  include <strings.h>
  101. # endif /* NEWSOS */
  102. #else /* BSD */
  103. # if defined(SVR4) || defined(NEWSOS)
  104. #  define strlen ___strlen___
  105. #  include <string.h>
  106. #  undef strlen
  107. #  ifndef NEWSOS
  108.     extern size_t strlen(const char *);
  109. #  endif /* NEWSOS */
  110. # else /* SVR4 */
  111. #  include <string.h>
  112. # endif /* SVR4 */
  113. #endif /* BSD */
  114.  
  115. #ifdef USEVARARGS
  116. # if defined(__STDC__)
  117. #  include <stdarg.h>
  118. # else
  119. #  include <varargs.h>
  120. # endif
  121. #endif
  122.  
  123. #if !defined(sun) && !defined(B43) && !defined(ISC) && !defined(pyr) && !defined(_CX_UX)
  124. # include <time.h>
  125. #endif
  126. #include <sys/time.h>
  127.  
  128. #if (defined(TIOCGWINSZ) || defined(TIOCSWINSZ)) && defined(M_UNIX)
  129. # include <sys/stream.h>
  130. # include <sys/ptem.h>
  131. #endif
  132.  
  133. #ifdef UTMPOK
  134. # ifdef SVR4
  135. #  include <utmpx.h>
  136. #  define UTMPFILE    UTMPX_FILE
  137. #  define utmp        utmpx
  138. #  define getutent    getutxent
  139. #  define getutid    getutxid
  140. #  define getutline    getutxline
  141. #  define pututline    pututxline
  142. #  define setutent    setutxent
  143. #  define endutent    endutxent
  144. #  define ut_time    ut_xtime
  145. # else /* SVR4 */
  146. #  include <utmp.h>
  147. # endif /* SVR4 */
  148. # if defined(apollo) || defined(linux)
  149.    /* 
  150.     * We don't have GETUTENT, so we dig into utmp ourselves.
  151.     * But we save the permanent filedescriptor and
  152.     * open utmp just when we need to. 
  153.     * This code supports an unsorted utmp. jw.
  154.     */
  155. #  define UTNOKEEP
  156. # endif /* apollo || linux */
  157. #endif
  158.  
  159. #ifndef UTMPFILE
  160. # ifdef UTMP_FILE
  161. #  define UTMPFILE    UTMP_FILE
  162. # else
  163. #  ifdef _PATH_UTMP
  164. #   define UTMPFILE    _PATH_UTMP
  165. #  else
  166. #   define UTMPFILE    "/etc/utmp"
  167. #  endif /* _PATH_UTMP */
  168. # endif
  169. #endif
  170.  
  171. #ifndef UTMPOK
  172. #  ifdef USRLIMIT
  173. #     undef USRLIMIT
  174. #  endif
  175. #endif
  176.  
  177. #ifdef LOGOUTOK
  178. # ifndef LOGINDEFAULT
  179. #  define LOGINDEFAULT 0
  180. # endif
  181. #else
  182. # undef LOGINDEFAULT
  183. # define LOGINDEFAULT 1
  184. #endif
  185.  
  186. #ifndef F_OK
  187. #define F_OK 0
  188. #endif
  189. #ifndef X_OK
  190. #define X_OK 1
  191. #endif
  192. #ifndef W_OK
  193. #define W_OK 2
  194. #endif
  195. #ifndef R_OK
  196. #define R_OK 4
  197. #endif
  198.  
  199. #ifndef S_IFIFO
  200. #define S_IFIFO  0010000
  201. #endif
  202. #ifndef S_IREAD
  203. #define S_IREAD  0000400
  204. #endif
  205. #ifndef S_IWRITE
  206. #define S_IWRITE 0000200
  207. #endif
  208. #ifndef S_IEXEC
  209. #define S_IEXEC  0000100
  210. #endif
  211.  
  212. #if defined(S_IFIFO) && defined(S_IFMT) && !defined(S_ISFIFO)
  213. #define S_ISFIFO(mode) ((mode & S_IFMT) == S_IFIFO)
  214. #endif
  215. #if defined(S_IFSOCK) && defined(S_IFMT) && !defined(S_ISSOCK)
  216. #define S_ISSOCK(mode) ((mode & S_IFMT) == S_IFSOCK)
  217. #endif
  218.  
  219. #ifndef TERMCAP_BUFSIZE
  220. # define TERMCAP_BUFSIZE 1024
  221. #endif
  222.  
  223. #ifndef MAXPATHLEN
  224. # define MAXPATHLEN 1024
  225. #endif
  226.  
  227. #ifndef SIG_T_DEFINED
  228. # ifdef SIGVOID
  229. #  if defined(ultrix)
  230. #   define sig_t void
  231. #  else /* nice compilers: */
  232.     typedef void sig_t;
  233. #  endif
  234. # else
  235.    typedef int sig_t; /* (* sig_t) */
  236. # endif
  237. #else
  238. # if defined (__alpha)
  239. #   define sig_t void    /* From: Dietrich Wiegandt <dietrich@afsw01.cern.ch> */
  240. #  endif
  241. #endif /* SIG_T_DEFINED */
  242.  
  243. #if defined(SVR4) || (defined(SYSV) && defined(ISC)) || defined(_AIX) || defined(linux) || defined(ultrix) || defined(__386BSD__) || defined(BSDI)
  244. # define SIGPROTOARG   (int)
  245. # define SIGDEFARG     int sigsig
  246. # define SIGARG        0
  247. #else
  248. # define SIGPROTOARG   (void)
  249. # define SIGDEFARG
  250. # define SIGARG
  251. #endif
  252.  
  253. #ifndef SIGCHLD
  254. #define SIGCHLD SIGCLD
  255. #endif
  256.  
  257. #ifdef USESIGSET
  258. # define signal sigset
  259. #endif /* USESIGSET */
  260.  
  261. #ifndef PID_T_DEFINED
  262. typedef int pid_t;
  263. #endif
  264.  
  265. #ifndef UID_T_DEFINED
  266. typedef int gid_t;
  267. typedef int uid_t;
  268. #endif
  269.  
  270. #ifdef GETUTENT
  271.   typedef char *slot_t;
  272. #else
  273.   typedef int slot_t;
  274. #endif
  275.  
  276. #ifdef SYSV
  277. # define index strchr
  278. # define rindex strrchr
  279. # define bzero(poi,len) memset(poi,0,len)
  280. # define bcmp memcmp
  281. # define killpg(pgrp,sig) kill( -(pgrp), sig)
  282. #endif /* SYSV */
  283.  
  284. #ifndef USEBCOPY
  285. # ifdef USEMEMCPY
  286. #  define bcopy(s,d,len) memcpy(d,s,len)
  287. # else
  288. #  ifdef USEMEMMOVE
  289. #   define bcopy(s,d,len) memmove(d,s,len)
  290. #  else
  291. #   define NEED_OWN_BCOPY
  292. #  endif
  293. # endif
  294. #endif
  295.  
  296. #if defined(_POSIX_SOURCE) && defined(ISC)
  297. # ifndef O_NDELAY
  298. #  define O_NDELAY O_NONBLOCK
  299. # endif
  300. #endif
  301.  
  302. #ifdef hpux
  303. # define setreuid(ruid, euid) setresuid(ruid, euid, -1)
  304. # define setregid(rgid, egid) setresgid(rgid, egid, -1)
  305. #endif
  306.  
  307. #if (!defined(sysV68) && !defined(M_XENIX)) || defined(NeXT)
  308. # include <sys/wait.h>
  309. #endif
  310.  
  311. #ifndef WTERMSIG
  312. # ifndef BSDWAIT /* if wait is NOT a union: */
  313. #  define WTERMSIG(status) (status & 0177)
  314. # else
  315. #  define WTERMSIG(status) status.w_T.w_Termsig 
  316. # endif
  317. #endif
  318.  
  319. #ifndef WSTOPSIG
  320. # ifndef BSDWAIT /* if wait is NOT a union: */
  321. #  define WSTOPSIG(status) ((status >> 8) & 0377)
  322. # else
  323. #  define WSTOPSIG(status) status.w_S.w_Stopsig 
  324. # endif
  325. #endif
  326.  
  327. /* NET-2 uses WCOREDUMP */
  328. #if defined(WCOREDUMP) && !defined(WIFCORESIG)
  329. # define WIFCORESIG(status) WCOREDUMP(status)
  330. #endif
  331.  
  332. #ifndef WIFCORESIG
  333. # ifndef BSDWAIT /* if wait is NOT a union: */
  334. #  define WIFCORESIG(status) (status & 0200)
  335. # else
  336. #  define WIFCORESIG(status) status.w_T.w_Coredump
  337. # endif
  338. #endif
  339.  
  340. #ifndef WEXITSTATUS
  341. # ifndef BSDWAIT /* if wait is NOT a union: */
  342. #  define WEXITSTATUS(status) ((status >> 8) & 0377)
  343. # else
  344. #  define WEXITSTATUS(status) status.w_T.w_Retcode
  345. # endif
  346. #endif
  347.  
  348. #if defined(M_XENIX) || defined(M_UNIX) || defined(_SEQUENT_)
  349. #include <sys/select.h> /* for timeval + FD... */
  350. #endif
  351.  
  352.  
  353. /*
  354.  * SunOS 3.5 - Tom Schmidt - Micron Semiconductor, Inc - 27-Jul-93
  355.  * tschmidt@vax.micron.com
  356.  */
  357. #ifndef FD_SET
  358. # ifdef SUNOS3
  359. typedef struct fd_set
  360. {
  361.   int fds_bits[1];
  362. }      fd_set;
  363. # endif
  364. # define FD_ZERO(fd) ((fd)->fds_bits[0] = 0)
  365. # define FD_SET(b, fd) ((fd)->fds_bits[0] |= 1 << (b))
  366. # define FD_ISSET(b, fd) ((fd)->fds_bits[0] & 1 << (b))
  367. # define FD_SETSIZE 32
  368. #endif
  369.  
  370.  
  371. #if defined(sgi) 
  372. /* on IRIX, regardless of the stream head's read mode (RNORM/RMSGN/RMSGD)
  373.  * TIOCPKT mode causes data loss if our buffer is too small (IOSIZE)
  374.  * to hold the whole packet at first read().
  375.  * (Marc Boucher)
  376.  */
  377. # undef TIOCPKT
  378. #endif
  379.  
  380. #if !defined(VDISABLE)
  381. # ifdef _POSIX_VDISABLE
  382. #  define VDISABLE _POSIX_VDISABLE
  383. # else
  384. #  define VDISABLE 0377
  385. # endif /* _POSIX_VDISABLE */
  386. #endif /* !VDISABLE */
  387.  
  388. #if !defined(FNDELAY) && defined(O_NDELAY)
  389. # define FNDELAY O_NDELAY
  390. #endif
  391.  
  392. /*typedef long off_t; */    /* Someone might need this */
  393.  
  394.  
  395. /* 
  396.  * 4 <= IOSIZE <=1000
  397.  * you may try to vary this value. Use low values if your (VMS) system
  398.  * tends to choke when pasting. Use high values if you want to test
  399.  * how many characters your pty's can buffer.
  400.  */
  401. #define IOSIZE        4096
  402.  
  403. /* used in screen.c and attacher.c */
  404. #if !defined(NSIG)    /* kbeal needs these w/o SYSV */
  405. # define NSIG 32
  406. #endif /* !NSIG */
  407.  
  408.