Annotation of src/usr.bin/ssh/includes.h, Revision 1.3
1.1 deraadt 1: /*
2:
3: includes.h
4:
5: Author: Tatu Ylonen <ylo@cs.hut.fi>
6:
7: Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
8: All rights reserved
9:
10: Created: Thu Mar 23 16:29:37 1995 ylo
11:
12: This file includes most of the needed system headers.
13:
14: */
15:
1.3 ! dugsong 16: /* RCSID("$Id: includes.h,v 1.2 1999/09/29 12:59:13 provos Exp $"); */
1.1 deraadt 17:
18: #ifndef INCLUDES_H
19: #define INCLUDES_H
20:
21: /* Note: autoconf documentation tells to use the <...> syntax and have -I. */
22: #include <config.h>
23:
24: #include "version.h"
25:
26: typedef unsigned short word16;
27:
28: #if SIZEOF_LONG == 4
29: typedef unsigned long word32;
30: #else
31: #if SIZEOF_INT == 4
32: typedef unsigned int word32;
33: #else
34: #if SIZEOF_SHORT >= 4
35: typedef unsigned short word32;
36: #else
37: YOU_LOSE
38: #endif
39: #endif
40: #endif
41:
42: #ifdef SCO
43: /* this is defined so that winsize gets ifdef'd in termio.h */
44: #define _IBCS2
45: #endif
46:
47: #if defined(__mips)
48: /* Mach3 on MIPS defines conflicting garbage. */
49: #define uint32 hidden_uint32
50: #endif /* __mips */
51: #include <sys/types.h>
52: #if defined(__mips)
53: #undef uint32
54: #endif /* __mips */
55:
56: #if defined(bsd_44) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__PARAGON__)
57: #include <sys/param.h>
58: #include <machine/endian.h>
1.3 ! dugsong 59: #include <netgroup.h>
1.1 deraadt 60: #endif
61: #if defined(linux)
62: #include <endian.h>
63: #endif
64:
65: #include <stdio.h>
66: #include <ctype.h>
67: #include <sys/stat.h>
68: #include <errno.h>
69: #include <fcntl.h>
70: #include <assert.h>
71: #include <signal.h>
72:
73: #ifdef HAVE_SYS_IOCTL_H
74: #include <sys/ioctl.h>
75: #endif /* HAVE_SYS_IOCTL_H */
76:
77: #ifdef HAVE_TERMIOS_H
78: #include <termios.h>
79: #define USING_TERMIOS
80: #endif /* HAVE_TERMIOS_H */
81:
82: #if defined(HAVE_SGTTY_H) && !defined(USING_TERMIOS)
83: #include <sgtty.h>
84: #define USING_SGTTY
85: #endif
86:
87: #if !defined(USING_SGTTY) && !defined(USING_TERMIOS)
88: ERROR_NO_TERMIOS_OR_SGTTY
89: #endif
90:
91: #ifdef STDC_HEADERS
92: #include <stdlib.h>
93: #include <string.h>
94: #include <stdarg.h>
95: #else /* STDC_HEADERS */
96: /* stdarg.h is present almost everywhere, and comes with gcc; I am too lazy
97: to make things work with both it and varargs. */
98: #include <stdarg.h>
99: #ifndef HAVE_STRCHR
100: #define strchr index
101: #define strrchr rindex
102: #endif
103: char *strchr(), *strrchr();
104: #ifndef HAVE_MEMCPY
105: #define memcpy(d, s, n) bcopy((s), (d), (n))
106: #define memmove(d, s, n) bcopy((s), (d), (n))
107: #define memset(d, ch, n) bzero((d), (n)) /* We only memset to 0. */
108: #define memcmp(a, b, n) bcmp((a), (b), (n))
109: #endif
110: #endif /* STDC_HEADERS */
111:
112: #include <sys/socket.h>
113: #include <netinet/in.h>
114: #ifdef HAVE_NETINET_IN_SYSTM_H
115: #include <netinet/in_systm.h>
116: #else /* Some old linux systems at least have in_system.h instead. */
117: #include <netinet/in_system.h>
118: #endif /* HAVE_NETINET_IN_SYSTM_H */
119: #ifdef SCO
120: /* SCO does not have a un.h and there is no appropriate substitute. */
121: /* Latest news: it doesn't have AF_UNIX at all, but this allows
122: it to compile, and outgoing forwarded connections appear to work. */
123: struct sockaddr_un {
124: short sun_family; /* AF_UNIX */
125: char sun_path[108]; /* path name (gag) */
126: };
127: /* SCO needs sys/stream.h and sys/ptem.h */
128: #include <sys/stream.h>
129: #include <sys/ptem.h>
130: #else /* SCO */
131: #include <sys/un.h>
132: #endif /* SCO */
133: #if !defined(__PARAGON__)
134: #include <netinet/ip.h>
135: #endif /* !__PARAGON__ */
136: #include <netinet/tcp.h>
137: #include <arpa/inet.h>
138: #include <netdb.h>
139: #ifdef HAVE_SYS_SELECT_H
140: #include <sys/select.h>
141: #endif /* HAVE_SYS_SELECT_H */
142:
143: #include <pwd.h>
144: #include <grp.h>
145: #ifdef HAVE_GETSPNAM
146: #include <shadow.h>
147: #endif /* HAVE_GETSPNAM */
148:
149: #ifdef HAVE_SYS_WAIT_H
150: #include <sys/wait.h>
151: #else /* HAVE_SYS_WAIT_H */
152: #if !defined(WNOHANG) /* && (defined(bsd43) || defined(vax)) */
153: #define WNOHANG 1
154: #endif
155: #ifndef WEXITSTATUS
156: #define WEXITSTATUS(X) ((unsigned)(X) >> 8)
157: #endif
158: #ifndef WIFEXITED
159: #define WIFEXITED(X) (((X) & 255) == 0)
160: #endif
161: #ifndef WIFSIGNALED
162: #define WIFSIGNALED(X) ((((X) & 255) != 0x255 && ((X) & 255) != 0))
163: #endif
164: #ifndef WTERMSIG
165: #define WTERMSIG(X) ((X) & 255)
166: #endif
167: #endif /* HAVE_SYS_WAIT_H */
168:
169: #ifdef HAVE_UNISTD_H
170: #include <unistd.h>
171: #endif /* HAVE_UNISTD_H */
172:
173: #ifdef TIME_WITH_SYS_TIME
174: #ifndef SCO
175: /* I excluded <sys/time.h> to avoid redefinition of timeval
176: which SCO puts in both <sys/select.h> and <sys/time.h> */
177: #include <sys/time.h>
178: #endif /* SCO */
179: #include <time.h>
180: #else /* TIME_WITH_SYS_TIME */
181: #ifdef HAVE_SYS_TIME_H
182: #include <sys/time.h>
183: #else /* HAVE_SYS_TIME_H */
184: #include <time.h>
185: #endif /* HAVE_SYS_TIME_H */
186: #endif /* TIME_WITH_SYS_TIME */
187:
188: #ifdef HAVE_PATHS_H
189: #include <paths.h>
190: #endif
191:
192: #if HAVE_DIRENT_H
193: #include <dirent.h>
194: #define NAMLEN(dirent) strlen((dirent)->d_name)
195: #else
196: #define dirent direct
197: #define NAMLEN(dirent) (dirent)->d_namlen
198: #if HAVE_SYS_NDIR_H
199: #include <sys/ndir.h>
200: #endif
201: #if HAVE_SYS_DIR_H
202: #include <sys/dir.h>
203: #endif
204: #if HAVE_NDIR_H
205: #include <ndir.h>
206: #endif
207: #endif
208:
209: #ifdef HAVE_SETRLIMIT
210: #include <sys/resource.h>
211: #endif
212:
213: /* These POSIX macros are not defined in every system. */
214:
215: #ifndef S_IRWXU
216: #define S_IRWXU 00700 /* read, write, execute: owner */
217: #define S_IRUSR 00400 /* read permission: owner */
218: #define S_IWUSR 00200 /* write permission: owner */
219: #define S_IXUSR 00100 /* execute permission: owner */
220: #define S_IRWXG 00070 /* read, write, execute: group */
221: #define S_IRGRP 00040 /* read permission: group */
222: #define S_IWGRP 00020 /* write permission: group */
223: #define S_IXGRP 00010 /* execute permission: group */
224: #define S_IRWXO 00007 /* read, write, execute: other */
225: #define S_IROTH 00004 /* read permission: other */
226: #define S_IWOTH 00002 /* write permission: other */
227: #define S_IXOTH 00001 /* execute permission: other */
228: #endif /* S_IRWXU */
229:
230: #ifndef S_ISUID
231: #define S_ISUID 0x800
232: #endif /* S_ISUID */
233: #ifndef S_ISGID
234: #define S_ISGID 0x400
235: #endif /* S_ISGID */
236:
237: #ifndef S_ISDIR
238: /* NextStep apparently fails to define this. */
239: #define S_ISDIR(mode) (((mode)&(_S_IFMT))==(_S_IFDIR))
240: #endif
241:
242: #ifdef STAT_MACROS_BROKEN
243: /* Some systems have broken S_ISDIR etc. macros in sys/stat.h. Please ask
244: your vendor to fix them. You can then remove the line below, but only
245: after you have sent a complaint to your vendor. */
246: WARNING_MACROS_IN_SYS_STAT_H_ARE_BROKEN_ON_YOUR_SYSTEM_READ_INCLUDES_H
247: #endif /* STAT_MACROS_BROKEN */
248:
249: #if USE_STRLEN_FOR_AF_UNIX
250: #define AF_UNIX_SIZE(unaddr) \
251: (sizeof((unaddr).sun_family) + strlen((unaddr).sun_path) + 1)
252: #else
253: #define AF_UNIX_SIZE(unaddr) sizeof(unaddr)
254: #endif
255:
256: #endif /* INCLUDES_H */