summaryrefslogtreecommitdiff
path: root/src/os.h
blob: 4a89c66027217d450f15201ec1300e9930c0e800 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/* Copyright (c) 2008, 2009
 *      Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
 *      Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
 *      Micah Cowan (micah@cowan.name)
 *      Sadrul Habib Chowdhury (sadrul@users.sourceforge.net)
 * Copyright (c) 1993-2002, 2003, 2005, 2006, 2007
 *      Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
 *      Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
 * Copyright (c) 1987 Oliver Laumann
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program (see the file COPYING); if not, see
 * http://www.gnu.org/licenses/, or contact Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
 *
 ****************************************************************
 * $Id$ GNU
 */

#include "config.h"

#include <stdio.h>
#include <errno.h>
#include <sys/param.h>
#include <fcntl.h>

#include <limits.h>

#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <time.h>
#include <sys/time.h>

#if defined(HAVE_SETRESUID) && !defined(HAVE_SETREUID)
# define setreuid(ruid, euid) setresuid(ruid, euid, -1)
# define setregid(rgid, egid) setresgid(rgid, egid, -1)
#endif

#ifndef HAVE_UTIMES
# define utimes utime
#endif

#ifdef ENABLE_TELNET
# include <netinet/in.h>
# include <arpa/inet.h>
#endif

/*****************************************************************
 *    terminal handling
 */

#include <termios.h>
#ifdef NCCS
# define MAXCC NCCS
#else
# define MAXCC 256
#endif

#ifndef VDISABLE
# ifdef _POSIX_VDISABLE
#  define VDISABLE _POSIX_VDISABLE
# else
#  define VDISABLE 0377
# endif /* _POSIX_VDISABLE */
#endif /* !VDISABLE */

/*****************************************************************
 *   utmp handling
 */

#if defined(ENABLE_UTMP)
# include <utmpx.h>

typedef char* slot_t;	/* used internally in utmp.c */

# ifndef UTMPFILE
#  ifdef UTMPX_FILE
#   define UTMPXFILE	UTMPX_FILE
#  else
#   ifdef _PATH_UTMPX
#    define UTMPXFILE	_PATH_UTMPX
#   else
#    define UTMPXFILE	"/etc/utmpx"
#   endif /* _PATH_UTMPX */
#  endif
# endif

#endif /* ENABLE_UTMP */

/*****************************************************************
 *    signal stuff
 */

/* apparently NSIG is not part of standard, but it's present some form in most
 * libc headers, if not define sane default
 */
#if !defined(NSIG)
# if defined(_NSIG)
#  define NSIG _NSIG
# else
#  define NSIG 32
# endif
#endif

/*****************************************************************
 *    file stuff
 */

/*
 * SunOS 4.1.3: `man 2V open' has only one line that mentions O_NOBLOCK:
 *
 *     O_NONBLOCK     Same as O_NDELAY above.
 *
 * on the very same SunOS 4.1.3, I traced the open system call and found
 * that an open("/dev/ttyy08", O_RDWR|O_NONBLOCK|O_NOCTTY) was blocked,
 * whereas open("/dev/ttyy08", O_RDWR|O_NDELAY  |O_NOCTTY) went through.
 *
 * For this simple reason I now favour O_NDELAY. jw. 4.5.95
 */
#if !defined(O_NONBLOCK) && defined(O_NDELAY)
# define O_NONBLOCK O_NDELAY
#endif

#if !defined(FNBLOCK) && defined(FNONBLOCK)
# define FNBLOCK FNONBLOCK
#endif
#if !defined(FNBLOCK) && defined(FNDELAY)
# define FNBLOCK FNDELAY
#endif
#if !defined(FNBLOCK) && defined(O_NONBLOCK)
# define FNBLOCK O_NONBLOCK
#endif


/*****************************************************************
 *    Wait stuff
 */

# include <sys/wait.h>

#ifndef WTERMSIG
# define WTERMSIG(status) (status & 0177)
#endif

#ifndef WSTOPSIG
# define WSTOPSIG(status) ((status >> 8) & 0377)
#endif

/* NET-2 uses WCOREDUMP */
#if defined(WCOREDUMP) && !defined(WIFCORESIG)
# define WIFCORESIG(status) WCOREDUMP(status)
#endif

#ifndef WIFCORESIG
# define WIFCORESIG(status) (status & 0200)
#endif

#ifndef WEXITSTATUS
# define WEXITSTATUS(status) ((status >> 8) & 0377)
#endif

/*****************************************************************
 *    user defineable stuff
 */

#ifndef TERMCAP_BUFSIZE
# define TERMCAP_BUFSIZE 2048
#endif

/*
 * you may try to vary this value. Use low values if your (VMS) system
 * tends to choke when pasting. Use high values if you want to test
 * how many characters your pty's can buffer.
 */
#define IOSIZE		4096

/* Changing those you won't be able to attach to your old sessions
 * when changing those values in official tree don't forget to bump
 * MSG_VERSION */
#define MAXTERMLEN	32
#define MAXLOGINLEN	256