1*56bb7041Schristos /* Copyright (c) 1993-2002
2*56bb7041Schristos  *      Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
3*56bb7041Schristos  *      Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
4*56bb7041Schristos  * Copyright (c) 1987 Oliver Laumann
5*56bb7041Schristos  *
6*56bb7041Schristos  * This program is free software; you can redistribute it and/or modify
7*56bb7041Schristos  * it under the terms of the GNU General Public License as published by
8*56bb7041Schristos  * the Free Software Foundation; either version 2, or (at your option)
9*56bb7041Schristos  * any later version.
10*56bb7041Schristos  *
11*56bb7041Schristos  * This program is distributed in the hope that it will be useful,
12*56bb7041Schristos  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13*56bb7041Schristos  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14*56bb7041Schristos  * GNU General Public License for more details.
15*56bb7041Schristos  *
16*56bb7041Schristos  * You should have received a copy of the GNU General Public License
17*56bb7041Schristos  * along with this program (see the file COPYING); if not, write to the
18*56bb7041Schristos  * Free Software Foundation, Inc.,
19*56bb7041Schristos  * 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
20*56bb7041Schristos  *
21*56bb7041Schristos  ****************************************************************
22*56bb7041Schristos  * $Id: os.h,v 1.1.1.1 2023/03/21 16:41:16 christos Exp $ FAU
23*56bb7041Schristos  */
24*56bb7041Schristos 
25*56bb7041Schristos #include <stdio.h>
26*56bb7041Schristos #include <errno.h>
27*56bb7041Schristos 
28*56bb7041Schristos #include <sys/param.h>
29*56bb7041Schristos 
30*56bb7041Schristos /* In strict ANSI mode, HP-UX machines define __hpux but not hpux */
31*56bb7041Schristos #if defined(__hpux) && !defined(hpux)
32*56bb7041Schristos # define hpux
33*56bb7041Schristos #endif
34*56bb7041Schristos 
35*56bb7041Schristos #if defined(__bsdi__) || defined(__386BSD__) || defined(_CX_UX) || defined(hpux) || defined(_IBMR2) || defined(linux)
36*56bb7041Schristos # include <signal.h>
37*56bb7041Schristos #endif /* __bsdi__ || __386BSD__ || _CX_UX || hpux || _IBMR2 || linux */
38*56bb7041Schristos 
39*56bb7041Schristos #ifdef ISC
40*56bb7041Schristos # ifdef ENAMETOOLONG
41*56bb7041Schristos #  undef ENAMETOOLONG
42*56bb7041Schristos # endif
43*56bb7041Schristos # ifdef ENOTEMPTY
44*56bb7041Schristos #  undef ENOTEMPTY
45*56bb7041Schristos # endif
46*56bb7041Schristos # include <sys/bsdtypes.h>
47*56bb7041Schristos # include <net/errno.h>
48*56bb7041Schristos #endif
49*56bb7041Schristos 
50*56bb7041Schristos #ifdef sun
51*56bb7041Schristos # define getpgrp __getpgrp
52*56bb7041Schristos # define exit __exit
53*56bb7041Schristos #endif
54*56bb7041Schristos #ifdef POSIX
55*56bb7041Schristos # include <unistd.h>
56*56bb7041Schristos # if defined(__STDC__)
57*56bb7041Schristos #  include <stdlib.h>
58*56bb7041Schristos # endif /* __STDC__ */
59*56bb7041Schristos #endif /* POSIX */
60*56bb7041Schristos #ifdef sun
61*56bb7041Schristos # undef getpgrp
62*56bb7041Schristos # undef exit
63*56bb7041Schristos #endif /* sun */
64*56bb7041Schristos 
65*56bb7041Schristos #ifndef linux /* all done in <errno.h> */
66*56bb7041Schristos extern int errno;
67*56bb7041Schristos #endif /* linux */
68*56bb7041Schristos #ifndef HAVE_STRERROR
69*56bb7041Schristos /* No macros, please */
70*56bb7041Schristos #undef strerror
71*56bb7041Schristos #endif
72*56bb7041Schristos 
73*56bb7041Schristos #if !defined(SYSV) && !defined(linux)
74*56bb7041Schristos # ifdef NEWSOS
75*56bb7041Schristos #  define strlen ___strlen___
76*56bb7041Schristos #  include <strings.h>
77*56bb7041Schristos #  undef strlen
78*56bb7041Schristos # else /* NEWSOS */
79*56bb7041Schristos #  include <strings.h>
80*56bb7041Schristos # endif /* NEWSOS */
81*56bb7041Schristos #else /* SYSV */
82*56bb7041Schristos # if defined(SVR4) || defined(NEWSOS)
83*56bb7041Schristos #  define strlen ___strlen___
84*56bb7041Schristos #  include <string.h>
85*56bb7041Schristos #  undef strlen
86*56bb7041Schristos #  if !defined(NEWSOS) && !defined(__hpux)
87*56bb7041Schristos     extern size_t strlen(const char *);
88*56bb7041Schristos #  endif
89*56bb7041Schristos # else /* SVR4 */
90*56bb7041Schristos #  include <string.h>
91*56bb7041Schristos # endif /* SVR4 */
92*56bb7041Schristos #endif /* SYSV */
93*56bb7041Schristos 
94*56bb7041Schristos #ifdef USEVARARGS
95*56bb7041Schristos # if defined(__STDC__)
96*56bb7041Schristos #  include <stdarg.h>
97*56bb7041Schristos #  define VA_LIST(var) va_list var;
98*56bb7041Schristos #  define VA_DOTS ...
99*56bb7041Schristos #  define VA_DECL
100*56bb7041Schristos #  define VA_START(ap, fmt) va_start(ap, fmt)
101*56bb7041Schristos #  define VA_ARGS(ap) ap
102*56bb7041Schristos #  define VA_END(ap) va_end(ap)
103*56bb7041Schristos # else
104*56bb7041Schristos #  include <varargs.h>
105*56bb7041Schristos #  define VA_LIST(var) va_list var;
106*56bb7041Schristos #  define VA_DOTS va_alist
107*56bb7041Schristos #  define VA_DECL va_dcl
108*56bb7041Schristos #  define VA_START(ap, fmt) va_start(ap)
109*56bb7041Schristos #  define VA_ARGS(ap) ap
110*56bb7041Schristos #  define VA_END(ap) va_end(ap)
111*56bb7041Schristos # endif
112*56bb7041Schristos #else
113*56bb7041Schristos # define VA_LIST(var)
114*56bb7041Schristos # define VA_DOTS p1, p2, p3, p4, p5, p6
115*56bb7041Schristos # define VA_DECL unsigned long VA_DOTS;
116*56bb7041Schristos # define VA_START(ap, fmt)
117*56bb7041Schristos # define VA_ARGS(ap) VA_DOTS
118*56bb7041Schristos # define VA_END(ap)
119*56bb7041Schristos # undef vsnprintf
120*56bb7041Schristos # define vsnprintf xsnprintf
121*56bb7041Schristos #endif
122*56bb7041Schristos 
123*56bb7041Schristos #if !defined(sun) && !defined(B43) && !defined(ISC) && !defined(pyr) && !defined(_CX_UX)
124*56bb7041Schristos # include <time.h>
125*56bb7041Schristos #endif
126*56bb7041Schristos #include <sys/time.h>
127*56bb7041Schristos 
128*56bb7041Schristos #ifdef M_UNIX   /* SCO */
129*56bb7041Schristos # include <sys/stream.h>
130*56bb7041Schristos # include <sys/ptem.h>
131*56bb7041Schristos # define ftruncate(fd, s) chsize(fd, s)
132*56bb7041Schristos #endif
133*56bb7041Schristos 
134*56bb7041Schristos #ifdef SYSV
135*56bb7041Schristos # define index strchr
136*56bb7041Schristos # define rindex strrchr
137*56bb7041Schristos # define bzero(poi,len) memset(poi,0,len)
138*56bb7041Schristos # define bcmp memcmp
139*56bb7041Schristos # define killpg(pgrp,sig) kill( -(pgrp), sig)
140*56bb7041Schristos #endif
141*56bb7041Schristos 
142*56bb7041Schristos #ifndef HAVE_GETCWD
143*56bb7041Schristos # define getcwd(b,l) getwd(b)
144*56bb7041Schristos #endif
145*56bb7041Schristos 
146*56bb7041Schristos #ifndef USEBCOPY
147*56bb7041Schristos # ifdef USEMEMMOVE
148*56bb7041Schristos #  define bcopy(s,d,len) memmove(d,s,len)
149*56bb7041Schristos # else
150*56bb7041Schristos #  ifdef USEMEMCPY
151*56bb7041Schristos #   define bcopy(s,d,len) memcpy(d,s,len)
152*56bb7041Schristos #  else
153*56bb7041Schristos #   define NEED_OWN_BCOPY
154*56bb7041Schristos #   define bcopy xbcopy
155*56bb7041Schristos #  endif
156*56bb7041Schristos # endif
157*56bb7041Schristos #endif
158*56bb7041Schristos 
159*56bb7041Schristos #ifdef hpux
160*56bb7041Schristos # define setreuid(ruid, euid) setresuid(ruid, euid, -1)
161*56bb7041Schristos # define setregid(rgid, egid) setresgid(rgid, egid, -1)
162*56bb7041Schristos #endif
163*56bb7041Schristos 
164*56bb7041Schristos #if defined(HAVE_SETEUID) || defined(HAVE_SETREUID)
165*56bb7041Schristos # define USE_SETEUID
166*56bb7041Schristos #endif
167*56bb7041Schristos 
168*56bb7041Schristos #if !defined(HAVE__EXIT) && !defined(_exit)
169*56bb7041Schristos #define _exit(x) exit(x)
170*56bb7041Schristos #endif
171*56bb7041Schristos 
172*56bb7041Schristos #ifndef HAVE_UTIMES
173*56bb7041Schristos # define utimes utime
174*56bb7041Schristos #endif
175*56bb7041Schristos 
176*56bb7041Schristos #ifdef BUILTIN_TELNET
177*56bb7041Schristos # include <netinet/in.h>
178*56bb7041Schristos # include <arpa/inet.h>
179*56bb7041Schristos #endif
180*56bb7041Schristos 
181*56bb7041Schristos #if defined(USE_LOCALE) && (!defined(HAVE_SETLOCALE) || !defined(HAVE_STRFTIME))
182*56bb7041Schristos # undef USE_LOCALE
183*56bb7041Schristos #endif
184*56bb7041Schristos 
185*56bb7041Schristos /*****************************************************************
186*56bb7041Schristos  *    terminal handling
187*56bb7041Schristos  */
188*56bb7041Schristos 
189*56bb7041Schristos #if defined (POSIX) || defined (__FreeBSD__)
190*56bb7041Schristos # include <termios.h>
191*56bb7041Schristos # ifdef hpux
192*56bb7041Schristos #  include <bsdtty.h>
193*56bb7041Schristos # endif /* hpux */
194*56bb7041Schristos # ifdef NCCS
195*56bb7041Schristos #  define MAXCC NCCS
196*56bb7041Schristos # else
197*56bb7041Schristos #  define MAXCC 256
198*56bb7041Schristos # endif
199*56bb7041Schristos #else /* POSIX */
200*56bb7041Schristos # ifdef TERMIO
201*56bb7041Schristos #  include <termio.h>
202*56bb7041Schristos #  ifdef NCC
203*56bb7041Schristos #   define MAXCC NCC
204*56bb7041Schristos #  else
205*56bb7041Schristos #   define MAXCC 256
206*56bb7041Schristos #  endif
207*56bb7041Schristos #  ifdef CYTERMIO
208*56bb7041Schristos #   include <cytermio.h>
209*56bb7041Schristos #  endif
210*56bb7041Schristos # else /* TERMIO */
211*56bb7041Schristos #  if defined (HAVE_SGTTY_H)
212*56bb7041Schristos #    include <sgtty.h>
213*56bb7041Schristos #  endif
214*56bb7041Schristos # endif /* TERMIO */
215*56bb7041Schristos #endif /* POSIX */
216*56bb7041Schristos 
217*56bb7041Schristos #ifndef VDISABLE
218*56bb7041Schristos # ifdef _POSIX_VDISABLE
219*56bb7041Schristos #  define VDISABLE _POSIX_VDISABLE
220*56bb7041Schristos # else
221*56bb7041Schristos #  define VDISABLE 0377
222*56bb7041Schristos # endif /* _POSIX_VDISABLE */
223*56bb7041Schristos #endif /* !VDISABLE */
224*56bb7041Schristos 
225*56bb7041Schristos 
226*56bb7041Schristos /* on sgi, regardless of the stream head's read mode (RNORM/RMSGN/RMSGD)
227*56bb7041Schristos  * TIOCPKT mode causes data loss if our buffer is too small (IOSIZE)
228*56bb7041Schristos  * to hold the whole packet at first read().
229*56bb7041Schristos  * (Marc Boucher)
230*56bb7041Schristos  *
231*56bb7041Schristos  * matthew green:
232*56bb7041Schristos  * TIOCPKT is broken on dgux 5.4.1 generic AViiON mc88100
233*56bb7041Schristos  *
234*56bb7041Schristos  * Joe Traister: On AIX4, programs like irc won't work if screen
235*56bb7041Schristos  * uses TIOCPKT (select fails to return on pty read).
236*56bb7041Schristos  */
237*56bb7041Schristos #if defined(sgi) || defined(DGUX) || defined(_IBMR2)
238*56bb7041Schristos # undef TIOCPKT
239*56bb7041Schristos #endif
240*56bb7041Schristos 
241*56bb7041Schristos /* linux ncurses is broken, we have to use our own tputs */
242*56bb7041Schristos #if defined(linux) && defined(TERMINFO)
243*56bb7041Schristos # define tputs xtputs
244*56bb7041Schristos #endif
245*56bb7041Schristos 
246*56bb7041Schristos /* Alexandre Oliva: SVR4 style ptys don't work with osf */
247*56bb7041Schristos #ifdef __osf__
248*56bb7041Schristos # undef HAVE_SVR4_PTYS
249*56bb7041Schristos #endif
250*56bb7041Schristos 
251*56bb7041Schristos /*****************************************************************
252*56bb7041Schristos  *   utmp handling
253*56bb7041Schristos  */
254*56bb7041Schristos 
255*56bb7041Schristos #ifdef GETUTENT
256*56bb7041Schristos   typedef char *slot_t;
257*56bb7041Schristos #else
258*56bb7041Schristos   typedef int slot_t;
259*56bb7041Schristos #endif
260*56bb7041Schristos 
261*56bb7041Schristos #if defined(UTMPOK) || defined(BUGGYGETLOGIN)
262*56bb7041Schristos # if defined(SVR4) && !defined(DGUX) && !defined(__hpux) && !defined(linux)
263*56bb7041Schristos #  include <utmpx.h>
264*56bb7041Schristos #  define UTMPFILE	UTMPX_FILE
265*56bb7041Schristos #  define utmp		utmpx
266*56bb7041Schristos #  define getutent	getutxent
267*56bb7041Schristos #  define getutid	getutxid
268*56bb7041Schristos #  define getutline	getutxline
269*56bb7041Schristos #  define pututline	pututxline
270*56bb7041Schristos #  define setutent	setutxent
271*56bb7041Schristos #  define endutent	endutxent
272*56bb7041Schristos #  define ut_time	ut_xtime
273*56bb7041Schristos # else /* SVR4 */
274*56bb7041Schristos #  include <utmp.h>
275*56bb7041Schristos # endif /* SVR4 */
276*56bb7041Schristos # ifdef apollo
277*56bb7041Schristos    /*
278*56bb7041Schristos     * We don't have GETUTENT, so we dig into utmp ourselves.
279*56bb7041Schristos     * But we save the permanent filedescriptor and
280*56bb7041Schristos     * open utmp just when we need to.
281*56bb7041Schristos     * This code supports an unsorted utmp. jw.
282*56bb7041Schristos     */
283*56bb7041Schristos #  define UTNOKEEP
284*56bb7041Schristos # endif /* apollo */
285*56bb7041Schristos 
286*56bb7041Schristos # ifndef UTMPFILE
287*56bb7041Schristos #  ifdef UTMP_FILE
288*56bb7041Schristos #   define UTMPFILE	UTMP_FILE
289*56bb7041Schristos #  else
290*56bb7041Schristos #   ifdef _PATH_UTMP
291*56bb7041Schristos #    define UTMPFILE	_PATH_UTMP
292*56bb7041Schristos #   else
293*56bb7041Schristos #    define UTMPFILE	"/etc/utmp"
294*56bb7041Schristos #   endif /* _PATH_UTMP */
295*56bb7041Schristos #  endif
296*56bb7041Schristos # endif
297*56bb7041Schristos 
298*56bb7041Schristos #endif /* UTMPOK || BUGGYGETLOGIN */
299*56bb7041Schristos 
300*56bb7041Schristos #if !defined(UTMPOK) && defined(USRLIMIT)
301*56bb7041Schristos # undef USRLIMIT
302*56bb7041Schristos #endif
303*56bb7041Schristos 
304*56bb7041Schristos #ifdef LOGOUTOK
305*56bb7041Schristos # ifndef LOGINDEFAULT
306*56bb7041Schristos #  define LOGINDEFAULT 0
307*56bb7041Schristos # endif
308*56bb7041Schristos #else
309*56bb7041Schristos # ifdef LOGINDEFAULT
310*56bb7041Schristos #  undef LOGINDEFAULT
311*56bb7041Schristos # endif
312*56bb7041Schristos # define LOGINDEFAULT 1
313*56bb7041Schristos #endif
314*56bb7041Schristos 
315*56bb7041Schristos 
316*56bb7041Schristos /*****************************************************************
317*56bb7041Schristos  *    file stuff
318*56bb7041Schristos  */
319*56bb7041Schristos 
320*56bb7041Schristos #ifndef F_OK
321*56bb7041Schristos #define F_OK 0
322*56bb7041Schristos #endif
323*56bb7041Schristos #ifndef X_OK
324*56bb7041Schristos #define X_OK 1
325*56bb7041Schristos #endif
326*56bb7041Schristos #ifndef W_OK
327*56bb7041Schristos #define W_OK 2
328*56bb7041Schristos #endif
329*56bb7041Schristos #ifndef R_OK
330*56bb7041Schristos #define R_OK 4
331*56bb7041Schristos #endif
332*56bb7041Schristos 
333*56bb7041Schristos #ifndef S_IFIFO
334*56bb7041Schristos #define S_IFIFO  0010000
335*56bb7041Schristos #endif
336*56bb7041Schristos #ifndef S_IREAD
337*56bb7041Schristos #define S_IREAD  0000400
338*56bb7041Schristos #endif
339*56bb7041Schristos #ifndef S_IWRITE
340*56bb7041Schristos #define S_IWRITE 0000200
341*56bb7041Schristos #endif
342*56bb7041Schristos #ifndef S_IEXEC
343*56bb7041Schristos #define S_IEXEC  0000100
344*56bb7041Schristos #endif
345*56bb7041Schristos 
346*56bb7041Schristos #if defined(S_IFIFO) && defined(S_IFMT) && !defined(S_ISFIFO)
347*56bb7041Schristos #define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO)
348*56bb7041Schristos #endif
349*56bb7041Schristos #if defined(S_IFSOCK) && defined(S_IFMT) && !defined(S_ISSOCK)
350*56bb7041Schristos #define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
351*56bb7041Schristos #endif
352*56bb7041Schristos #if defined(S_IFCHR) && defined(S_IFMT) && !defined(S_ISCHR)
353*56bb7041Schristos #define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
354*56bb7041Schristos #endif
355*56bb7041Schristos #if defined(S_IFDIR) && defined(S_IFMT) && !defined(S_ISDIR)
356*56bb7041Schristos #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
357*56bb7041Schristos #endif
358*56bb7041Schristos #if defined(S_IFLNK) && defined(S_IFMT) && !defined(S_ISLNK)
359*56bb7041Schristos #define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
360*56bb7041Schristos #endif
361*56bb7041Schristos 
362*56bb7041Schristos /*
363*56bb7041Schristos  * SunOS 4.1.3: `man 2V open' has only one line that mentions O_NOBLOCK:
364*56bb7041Schristos  *
365*56bb7041Schristos  *     O_NONBLOCK     Same as O_NDELAY above.
366*56bb7041Schristos  *
367*56bb7041Schristos  * on the very same SunOS 4.1.3, I traced the open system call and found
368*56bb7041Schristos  * that an open("/dev/ttyy08", O_RDWR|O_NONBLOCK|O_NOCTTY) was blocked,
369*56bb7041Schristos  * whereas open("/dev/ttyy08", O_RDWR|O_NDELAY  |O_NOCTTY) went through.
370*56bb7041Schristos  *
371*56bb7041Schristos  * For this simple reason I now favour O_NDELAY. jw. 4.5.95
372*56bb7041Schristos  */
373*56bb7041Schristos #if defined(sun) && !defined(SVR4)
374*56bb7041Schristos # undef O_NONBLOCK
375*56bb7041Schristos #endif
376*56bb7041Schristos 
377*56bb7041Schristos #if !defined(O_NONBLOCK) && defined(O_NDELAY)
378*56bb7041Schristos # define O_NONBLOCK O_NDELAY
379*56bb7041Schristos #endif
380*56bb7041Schristos 
381*56bb7041Schristos #if !defined(FNBLOCK) && defined(FNONBLOCK)
382*56bb7041Schristos # define FNBLOCK FNONBLOCK
383*56bb7041Schristos #endif
384*56bb7041Schristos #if !defined(FNBLOCK) && defined(FNDELAY)
385*56bb7041Schristos # define FNBLOCK FNDELAY
386*56bb7041Schristos #endif
387*56bb7041Schristos #if !defined(FNBLOCK) && defined(O_NONBLOCK)
388*56bb7041Schristos # define FNBLOCK O_NONBLOCK
389*56bb7041Schristos #endif
390*56bb7041Schristos 
391*56bb7041Schristos #ifndef POSIX
392*56bb7041Schristos #undef mkfifo
393*56bb7041Schristos #define mkfifo(n,m) mknod(n,S_IFIFO|(m),0)
394*56bb7041Schristos #endif
395*56bb7041Schristos 
396*56bb7041Schristos #if !defined(HAVE_LSTAT) && !defined(lstat)
397*56bb7041Schristos # define lstat stat
398*56bb7041Schristos #endif
399*56bb7041Schristos 
400*56bb7041Schristos /*****************************************************************
401*56bb7041Schristos  *    signal handling
402*56bb7041Schristos  */
403*56bb7041Schristos 
404*56bb7041Schristos #ifdef SIGVOID
405*56bb7041Schristos # define SIGRETURN
406*56bb7041Schristos # define sigret_t void
407*56bb7041Schristos #else
408*56bb7041Schristos # define SIGRETURN return 0;
409*56bb7041Schristos # define sigret_t int
410*56bb7041Schristos #endif
411*56bb7041Schristos 
412*56bb7041Schristos /* Geeeee, reverse it? */
413*56bb7041Schristos #if defined(SVR4) || (defined(SYSV) && defined(ISC)) || defined(_AIX) || defined(linux) || defined(ultrix) || defined(__386BSD__) || defined(__bsdi__) || defined(POSIX) || defined(NeXT)
414*56bb7041Schristos # define SIGHASARG
415*56bb7041Schristos #endif
416*56bb7041Schristos 
417*56bb7041Schristos #ifdef SIGHASARG
418*56bb7041Schristos # define SIGPROTOARG   (int)
419*56bb7041Schristos # define SIGDEFARG     (sigsig) int sigsig;
420*56bb7041Schristos # define SIGARG        0
421*56bb7041Schristos #else
422*56bb7041Schristos # define SIGPROTOARG   (void)
423*56bb7041Schristos # define SIGDEFARG     ()
424*56bb7041Schristos # define SIGARG
425*56bb7041Schristos #endif
426*56bb7041Schristos 
427*56bb7041Schristos #ifndef SIGCHLD
428*56bb7041Schristos #define SIGCHLD SIGCLD
429*56bb7041Schristos #endif
430*56bb7041Schristos 
431*56bb7041Schristos #if defined(POSIX) || defined(hpux)
432*56bb7041Schristos # define signal xsignal
433*56bb7041Schristos #else
434*56bb7041Schristos # ifdef USESIGSET
435*56bb7041Schristos #  define signal sigset
436*56bb7041Schristos # endif /* USESIGSET */
437*56bb7041Schristos #endif
438*56bb7041Schristos 
439*56bb7041Schristos /* used in screen.c and attacher.c */
440*56bb7041Schristos #ifndef NSIG		/* kbeal needs these w/o SYSV */
441*56bb7041Schristos # define NSIG 32
442*56bb7041Schristos #endif /* !NSIG */
443*56bb7041Schristos 
444*56bb7041Schristos 
445*56bb7041Schristos /*****************************************************************
446*56bb7041Schristos  *    Wait stuff
447*56bb7041Schristos  */
448*56bb7041Schristos 
449*56bb7041Schristos #if (!defined(sysV68) && !defined(M_XENIX)) || defined(NeXT) || defined(M_UNIX)
450*56bb7041Schristos # include <sys/wait.h>
451*56bb7041Schristos #endif
452*56bb7041Schristos 
453*56bb7041Schristos #ifndef WTERMSIG
454*56bb7041Schristos # ifndef BSDWAIT /* if wait is NOT a union: */
455*56bb7041Schristos #  define WTERMSIG(status) (status & 0177)
456*56bb7041Schristos # else
457*56bb7041Schristos #  define WTERMSIG(status) status.w_T.w_Termsig
458*56bb7041Schristos # endif
459*56bb7041Schristos #endif
460*56bb7041Schristos 
461*56bb7041Schristos #ifndef WSTOPSIG
462*56bb7041Schristos # ifndef BSDWAIT /* if wait is NOT a union: */
463*56bb7041Schristos #  define WSTOPSIG(status) ((status >> 8) & 0377)
464*56bb7041Schristos # else
465*56bb7041Schristos #  define WSTOPSIG(status) status.w_S.w_Stopsig
466*56bb7041Schristos # endif
467*56bb7041Schristos #endif
468*56bb7041Schristos 
469*56bb7041Schristos /* NET-2 uses WCOREDUMP */
470*56bb7041Schristos #if defined(WCOREDUMP) && !defined(WIFCORESIG)
471*56bb7041Schristos # define WIFCORESIG(status) WCOREDUMP(status)
472*56bb7041Schristos #endif
473*56bb7041Schristos 
474*56bb7041Schristos #ifndef WIFCORESIG
475*56bb7041Schristos # ifndef BSDWAIT /* if wait is NOT a union: */
476*56bb7041Schristos #  define WIFCORESIG(status) (status & 0200)
477*56bb7041Schristos # else
478*56bb7041Schristos #  define WIFCORESIG(status) status.w_T.w_Coredump
479*56bb7041Schristos # endif
480*56bb7041Schristos #endif
481*56bb7041Schristos 
482*56bb7041Schristos #ifndef WEXITSTATUS
483*56bb7041Schristos # ifndef BSDWAIT /* if wait is NOT a union: */
484*56bb7041Schristos #  define WEXITSTATUS(status) ((status >> 8) & 0377)
485*56bb7041Schristos # else
486*56bb7041Schristos #  define WEXITSTATUS(status) status.w_T.w_Retcode
487*56bb7041Schristos # endif
488*56bb7041Schristos #endif
489*56bb7041Schristos 
490*56bb7041Schristos 
491*56bb7041Schristos /*****************************************************************
492*56bb7041Schristos  *    select stuff
493*56bb7041Schristos  */
494*56bb7041Schristos 
495*56bb7041Schristos #if defined(M_XENIX) || defined(M_UNIX) || defined(_SEQUENT_) || defined (__INTERIX)
496*56bb7041Schristos #include <sys/select.h>		/* for timeval + FD... */
497*56bb7041Schristos #endif
498*56bb7041Schristos 
499*56bb7041Schristos /*
500*56bb7041Schristos  * SunOS 3.5 - Tom Schmidt - Micron Semiconductor, Inc - 27-Jul-93
501*56bb7041Schristos  * tschmidt@vax.micron.com
502*56bb7041Schristos  */
503*56bb7041Schristos #ifndef FD_SET
504*56bb7041Schristos # ifndef SUNOS3
505*56bb7041Schristos typedef struct fd_set { int fds_bits[1]; } fd_set;
506*56bb7041Schristos # endif
507*56bb7041Schristos # define FD_ZERO(fd) ((fd)->fds_bits[0] = 0)
508*56bb7041Schristos # define FD_SET(b, fd) ((fd)->fds_bits[0] |= 1 << (b))
509*56bb7041Schristos # define FD_ISSET(b, fd) ((fd)->fds_bits[0] & 1 << (b))
510*56bb7041Schristos # define FD_SETSIZE 32
511*56bb7041Schristos #endif
512*56bb7041Schristos 
513*56bb7041Schristos 
514*56bb7041Schristos /*****************************************************************
515*56bb7041Schristos  *    user defineable stuff
516*56bb7041Schristos  */
517*56bb7041Schristos 
518*56bb7041Schristos #ifndef TERMCAP_BUFSIZE
519*56bb7041Schristos # define TERMCAP_BUFSIZE 2048
520*56bb7041Schristos #endif
521*56bb7041Schristos 
522*56bb7041Schristos #ifndef MAXPATHLEN
523*56bb7041Schristos # define MAXPATHLEN 1024
524*56bb7041Schristos #endif
525*56bb7041Schristos 
526*56bb7041Schristos /*
527*56bb7041Schristos  * you may try to vary this value. Use low values if your (VMS) system
528*56bb7041Schristos  * tends to choke when pasting. Use high values if you want to test
529*56bb7041Schristos  * how many characters your pty's can buffer.
530*56bb7041Schristos  */
531*56bb7041Schristos #define IOSIZE		4096
532