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