]>
git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - readline/readline/examples/rlfe/os.h
1 /* Copyright (c) 1993-2002
2 * Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
3 * Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
4 * Copyright (c) 1987 Oliver Laumann
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)
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.
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.,
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
21 ****************************************************************
22 * $Id: os.h,v 1.10 1994/05/31 12:32:22 mlschroe Exp $ FAU
28 #include <sys/param.h>
30 /* In strict ANSI mode, HP-UX machines define __hpux but not hpux */
31 #if defined(__hpux) && !defined(hpux)
35 #if defined(__bsdi__) || defined(__386BSD__) || defined(_CX_UX) || defined(hpux) || defined(_IBMR2) || defined(linux)
37 #endif /* __bsdi__ || __386BSD__ || _CX_UX || hpux || _IBMR2 || linux */
46 # include <sys/bsdtypes.h>
47 # include <net/errno.h>
51 # define getpgrp __getpgrp
56 # if defined(__STDC__)
58 # endif /* __STDC__ */
65 #ifndef linux /* all done in <errno.h> */
69 /* No macros, please */
73 #if !defined(SYSV) && !defined(linux)
75 # define strlen ___strlen___
82 # if defined(SVR4) || defined(NEWSOS)
83 # define strlen ___strlen___
86 # if !defined(NEWSOS) && !defined(__hpux)
87 extern size_t strlen(const char *);
95 # if defined(__STDC__)
97 # define VA_LIST(var) va_list var;
100 # define VA_START(ap, fmt) va_start(ap, fmt)
101 # define VA_ARGS(ap) ap
102 # define VA_END(ap) va_end(ap)
104 # include <varargs.h>
105 # define VA_LIST(var) va_list var;
106 # define VA_DOTS va_alist
107 # define VA_DECL va_dcl
108 # define VA_START(ap, fmt) va_start(ap)
109 # define VA_ARGS(ap) ap
110 # define VA_END(ap) va_end(ap)
113 # define VA_LIST(var)
114 # define VA_DOTS p1, p2, p3, p4, p5, p6
115 # define VA_DECL unsigned long VA_DOTS;
116 # define VA_START(ap, fmt)
117 # define VA_ARGS(ap) VA_DOTS
120 # define vsnprintf xsnprintf
123 #if !defined(sun) && !defined(B43) && !defined(ISC) && !defined(pyr) && !defined(_CX_UX)
126 #include <sys/time.h>
128 #ifdef M_UNIX /* SCO */
129 # include <sys/stream.h>
130 # include <sys/ptem.h>
131 # define ftruncate(fd, s) chsize(fd, s)
135 # define index strchr
136 # define rindex strrchr
137 # define bzero(poi,len) memset(poi,0,len)
139 # define killpg(pgrp,sig) kill( -(pgrp), sig)
143 # define getcwd(b,l) getwd(b)
148 # define bcopy(s,d,len) memmove(d,s,len)
151 # define bcopy(s,d,len) memcpy(d,s,len)
153 # define NEED_OWN_BCOPY
154 # define bcopy xbcopy
160 # define setreuid(ruid, euid) setresuid(ruid, euid, -1)
161 # define setregid(rgid, egid) setresgid(rgid, egid, -1)
164 #if defined(HAVE_SETEUID) || defined(HAVE_SETREUID)
168 #if !defined(HAVE__EXIT) && !defined(_exit)
169 #define _exit(x) exit(x)
173 # define utimes utime
176 #ifdef BUILTIN_TELNET
177 # include <netinet/in.h>
178 # include <arpa/inet.h>
181 #if defined(USE_LOCALE) && (!defined(HAVE_SETLOCALE) || !defined(HAVE_STRFTIME))
185 /*****************************************************************
189 #if defined (POSIX) || defined (__FreeBSD__)
190 # include <termios.h>
208 # include <cytermio.h>
211 # if defined (HAVE_SGTTY_H)
218 # ifdef _POSIX_VDISABLE
219 # define VDISABLE _POSIX_VDISABLE
221 # define VDISABLE 0377
222 # endif /* _POSIX_VDISABLE */
223 #endif /* !VDISABLE */
226 /* on sgi, regardless of the stream head's read mode (RNORM/RMSGN/RMSGD)
227 * TIOCPKT mode causes data loss if our buffer is too small (IOSIZE)
228 * to hold the whole packet at first read().
232 * TIOCPKT is broken on dgux 5.4.1 generic AViiON mc88100
234 * Joe Traister: On AIX4, programs like irc won't work if screen
235 * uses TIOCPKT (select fails to return on pty read).
237 #if defined(sgi) || defined(DGUX) || defined(_IBMR2)
241 /* linux ncurses is broken, we have to use our own tputs */
242 #if defined(linux) && defined(TERMINFO)
243 # define tputs xtputs
246 /* Alexandre Oliva: SVR4 style ptys don't work with osf */
248 # undef HAVE_SVR4_PTYS
251 /*****************************************************************
256 typedef char *slot_t
;
261 #if defined(UTMPOK) || defined(BUGGYGETLOGIN)
262 # if defined(SVR4) && !defined(DGUX) && !defined(__hpux) && !defined(linux)
264 # define UTMPFILE UTMPX_FILE
266 # define getutent getutxent
267 # define getutid getutxid
268 # define getutline getutxline
269 # define pututline pututxline
270 # define setutent setutxent
271 # define endutent endutxent
272 # define ut_time ut_xtime
278 * We don't have GETUTENT, so we dig into utmp ourselves.
279 * But we save the permanent filedescriptor and
280 * open utmp just when we need to.
281 * This code supports an unsorted utmp. jw.
288 # define UTMPFILE UTMP_FILE
291 # define UTMPFILE _PATH_UTMP
293 # define UTMPFILE "/etc/utmp"
294 # endif /* _PATH_UTMP */
298 #endif /* UTMPOK || BUGGYGETLOGIN */
300 #if !defined(UTMPOK) && defined(USRLIMIT)
305 # ifndef LOGINDEFAULT
306 # define LOGINDEFAULT 0
312 # define LOGINDEFAULT 1
316 /*****************************************************************
334 #define S_IFIFO 0010000
337 #define S_IREAD 0000400
340 #define S_IWRITE 0000200
343 #define S_IEXEC 0000100
346 #if defined(S_IFIFO) && defined(S_IFMT) && !defined(S_ISFIFO)
347 #define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO)
349 #if defined(S_IFSOCK) && defined(S_IFMT) && !defined(S_ISSOCK)
350 #define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
352 #if defined(S_IFCHR) && defined(S_IFMT) && !defined(S_ISCHR)
353 #define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
355 #if defined(S_IFDIR) && defined(S_IFMT) && !defined(S_ISDIR)
356 #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
358 #if defined(S_IFLNK) && defined(S_IFMT) && !defined(S_ISLNK)
359 #define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
363 * SunOS 4.1.3: `man 2V open' has only one line that mentions O_NOBLOCK:
365 * O_NONBLOCK Same as O_NDELAY above.
367 * on the very same SunOS 4.1.3, I traced the open system call and found
368 * that an open("/dev/ttyy08", O_RDWR|O_NONBLOCK|O_NOCTTY) was blocked,
369 * whereas open("/dev/ttyy08", O_RDWR|O_NDELAY |O_NOCTTY) went through.
371 * For this simple reason I now favour O_NDELAY. jw. 4.5.95
373 #if defined(sun) && !defined(SVR4)
377 #if !defined(O_NONBLOCK) && defined(O_NDELAY)
378 # define O_NONBLOCK O_NDELAY
381 #if !defined(FNBLOCK) && defined(FNONBLOCK)
382 # define FNBLOCK FNONBLOCK
384 #if !defined(FNBLOCK) && defined(FNDELAY)
385 # define FNBLOCK FNDELAY
387 #if !defined(FNBLOCK) && defined(O_NONBLOCK)
388 # define FNBLOCK O_NONBLOCK
393 #define mkfifo(n,m) mknod(n,S_IFIFO|(m),0)
396 #if !defined(HAVE_LSTAT) && !defined(lstat)
400 /*****************************************************************
406 # define sigret_t void
408 # define SIGRETURN return 0;
409 # define sigret_t int
412 /* Geeeee, reverse it? */
413 #if defined(SVR4) || (defined(SYSV) && defined(ISC)) || defined(_AIX) || defined(linux) || defined(ultrix) || defined(__386BSD__) || defined(__bsdi__) || defined(POSIX) || defined(NeXT)
418 # define SIGPROTOARG (int)
419 # define SIGDEFARG (sigsig) int sigsig;
422 # define SIGPROTOARG (void)
423 # define SIGDEFARG ()
428 #define SIGCHLD SIGCLD
431 #if defined(POSIX) || defined(hpux)
432 # define signal xsignal
435 # define signal sigset
436 # endif /* USESIGSET */
439 /* used in screen.c and attacher.c */
440 #ifndef NSIG /* kbeal needs these w/o SYSV */
445 /*****************************************************************
449 #if (!defined(sysV68) && !defined(M_XENIX)) || defined(NeXT) || defined(M_UNIX)
450 # include <sys/wait.h>
454 # ifndef BSDWAIT /* if wait is NOT a union: */
455 # define WTERMSIG(status) (status & 0177)
457 # define WTERMSIG(status) status.w_T.w_Termsig
462 # ifndef BSDWAIT /* if wait is NOT a union: */
463 # define WSTOPSIG(status) ((status >> 8) & 0377)
465 # define WSTOPSIG(status) status.w_S.w_Stopsig
469 /* NET-2 uses WCOREDUMP */
470 #if defined(WCOREDUMP) && !defined(WIFCORESIG)
471 # define WIFCORESIG(status) WCOREDUMP(status)
475 # ifndef BSDWAIT /* if wait is NOT a union: */
476 # define WIFCORESIG(status) (status & 0200)
478 # define WIFCORESIG(status) status.w_T.w_Coredump
483 # ifndef BSDWAIT /* if wait is NOT a union: */
484 # define WEXITSTATUS(status) ((status >> 8) & 0377)
486 # define WEXITSTATUS(status) status.w_T.w_Retcode
491 /*****************************************************************
495 #if defined(M_XENIX) || defined(M_UNIX) || defined(_SEQUENT_) || defined (__INTERIX)
496 #include <sys/select.h> /* for timeval + FD... */
500 * SunOS 3.5 - Tom Schmidt - Micron Semiconductor, Inc - 27-Jul-93
501 * tschmidt@vax.micron.com
505 typedef struct fd_set
{ int fds_bits
[1]; } fd_set
;
507 # define FD_ZERO(fd) ((fd)->fds_bits[0] = 0)
508 # define FD_SET(b, fd) ((fd)->fds_bits[0] |= 1 << (b))
509 # define FD_ISSET(b, fd) ((fd)->fds_bits[0] & 1 << (b))
510 # define FD_SETSIZE 32
514 /*****************************************************************
515 * user defineable stuff
518 #ifndef TERMCAP_BUFSIZE
519 # define TERMCAP_BUFSIZE 2048
523 # define MAXPATHLEN 1024
527 * you may try to vary this value. Use low values if your (VMS) system
528 * tends to choke when pasting. Use high values if you want to test
529 * how many characters your pty's can buffer.