Release v.5.0.0
[screen.git] / src / os.h
blobb350e43bdd5ade5571daf083ff04abf8af1ea586
1 /* Copyright (c) 2008, 2009
2 * Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
3 * Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
4 * Micah Cowan (micah@cowan.name)
5 * Sadrul Habib Chowdhury (sadrul@users.sourceforge.net)
6 * Copyright (c) 1993-2002, 2003, 2005, 2006, 2007
7 * Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
8 * Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
9 * Copyright (c) 1987 Oliver Laumann
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3, or (at your option)
14 * any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program (see the file COPYING); if not, see
23 * https://www.gnu.org/licenses/, or contact Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
26 ****************************************************************
27 * $Id$ GNU
30 #include "config.h"
32 #include <stdio.h>
33 #include <errno.h>
34 #include <sys/param.h>
35 #include <fcntl.h>
37 #include <limits.h>
39 #include <unistd.h>
40 #include <stdlib.h>
41 #include <string.h>
42 #include <stdarg.h>
43 #include <time.h>
44 #include <sys/time.h>
46 #if defined(HAVE_SETRESUID) && !defined(HAVE_SETREUID)
47 # define setreuid(ruid, euid) setresuid(ruid, euid, -1)
48 # define setregid(rgid, egid) setresgid(rgid, egid, -1)
49 #endif
51 #ifndef HAVE_UTIMES
52 # define utimes utime
53 #endif
55 #ifdef ENABLE_TELNET
56 # include <netinet/in.h>
57 # include <arpa/inet.h>
58 #endif
60 /*****************************************************************
61 * terminal handling
64 #include <termios.h>
65 #ifdef NCCS
66 # define MAXCC NCCS
67 #else
68 # define MAXCC 256
69 #endif
71 #ifndef VDISABLE
72 # ifdef _POSIX_VDISABLE
73 # define VDISABLE _POSIX_VDISABLE
74 # else
75 # define VDISABLE 0377
76 # endif /* _POSIX_VDISABLE */
77 #endif /* !VDISABLE */
79 /*****************************************************************
80 * utmp handling
83 #if defined(ENABLE_UTMP)
84 # include <utmpx.h>
86 typedef char* slot_t; /* used internally in utmp.c */
88 # ifndef UTMPFILE
89 # ifdef UTMPX_FILE
90 # define UTMPXFILE UTMPX_FILE
91 # else
92 # ifdef _PATH_UTMPX
93 # define UTMPXFILE _PATH_UTMPX
94 # else
95 # define UTMPXFILE "/etc/utmpx"
96 # endif /* _PATH_UTMPX */
97 # endif
98 # endif
100 #endif /* ENABLE_UTMP */
102 /*****************************************************************
103 * signal stuff
106 /* apparently NSIG is not part of standard, but it's present some form in most
107 * libc headers, if not define sane default
109 #if !defined(NSIG)
110 # if defined(_NSIG)
111 # define NSIG _NSIG
112 # else
113 # define NSIG 32
114 # endif
115 #endif
117 /*****************************************************************
118 * file stuff
122 * SunOS 4.1.3: `man 2V open' has only one line that mentions O_NOBLOCK:
124 * O_NONBLOCK Same as O_NDELAY above.
126 * on the very same SunOS 4.1.3, I traced the open system call and found
127 * that an open("/dev/ttyy08", O_RDWR|O_NONBLOCK|O_NOCTTY) was blocked,
128 * whereas open("/dev/ttyy08", O_RDWR|O_NDELAY |O_NOCTTY) went through.
130 * For this simple reason I now favour O_NDELAY. jw. 4.5.95
132 #if !defined(O_NONBLOCK) && defined(O_NDELAY)
133 # define O_NONBLOCK O_NDELAY
134 #endif
136 #if !defined(FNBLOCK) && defined(FNONBLOCK)
137 # define FNBLOCK FNONBLOCK
138 #endif
139 #if !defined(FNBLOCK) && defined(FNDELAY)
140 # define FNBLOCK FNDELAY
141 #endif
142 #if !defined(FNBLOCK) && defined(O_NONBLOCK)
143 # define FNBLOCK O_NONBLOCK
144 #endif
146 /*****************************************************************
147 * user defineable stuff
150 #ifndef TERMCAP_BUFSIZE
151 # define TERMCAP_BUFSIZE 1023
152 #endif
155 * you may try to vary this value. Use low values if your (VMS) system
156 * tends to choke when pasting. Use high values if you want to test
157 * how many characters your pty's can buffer.
159 #define IOSIZE 4096
161 /* Changing those you won't be able to attach to your old sessions
162 * when changing those values in official tree don't forget to bump
163 * MSG_VERSION */
164 #define MAXTERMLEN 32
165 #define MAXLOGINLEN 256