1 /* syshdrs.h
2  *
3  * Copyright (c) 1996-2004 Mike Gleason, NcFTP Software.
4  * All rights reserved.
5  *
6  */
7 
8 #ifdef HAVE_CONFIG_H
9 #	include <config.h>
10 #endif
11 
12 #if defined(AIX) || defined(_AIX) || defined(__HOS_AIX__)
13 #	define _ALL_SOURCE 1
14 #endif
15 
16 #ifdef LINUX
17 #	define _GNU_SOURCE 1
18 #endif
19 
20 #if defined(DIGITAL_UNIX) || defined(TRU64UNIX)
21 #	define _OSF_SOURCE 1
22 #	define _XOPEN_SOURCE 500
23 #	define _XOPEN_SOURCE_EXTENDED 1
24 #endif
25 
26 #ifdef HPUX
27 #	define _HPUX_SOURCE 1
28 #	define _XOPEN_SOURCE 500
29 #	define _XOPEN_SOURCE_EXTENDED 1
30 #endif
31 
32 #ifdef IRIX
33 #	define _SGI_SOURCE 1
34 #endif
35 
36 #ifdef SOLARIS
37 /* #define __EXTENSIONS__ 1 */
38 #endif
39 
40 
41 #ifdef HAVE_UNISTD_H
42 #	include <unistd.h>
43 #endif
44 #include <sys/types.h>
45 #include <sys/stat.h>
46 #include <sys/socket.h>
47 #include <sys/time.h>
48 #include <sys/wait.h>
49 
50 #ifdef CAN_USE_SYS_SELECT_H
51 #	include <sys/select.h>
52 #endif
53 
54 #if defined(HAVE_SYS_UTSNAME_H) && defined(HAVE_UNAME)
55 #	include <sys/utsname.h>
56 #endif
57 
58 /* The only reason we need to include this junk, is because on some systems
59  * the function killchar() is actually a macro that uses definitions in
60  * termios.h.  Example:  #define killchar()      (__baset.c_cc[VKILL])
61  */
62 
63 #ifdef HAVE_TERMIOS_H
64 #	include <termios.h>
65 #else
66 #	ifdef HAVE_TERMIO_H
67 #		include <termio.h>
68 #	else
69 #		ifdef HAVE_SYS_IOCTL_H
70 #			include <sys/ioctl.h>	/* For TIOxxxx constants. */
71 #		endif
72 #		ifdef HAVE_SGTTY_H
73 #			include <sgtty.h>
74 #		endif
75 #	endif
76 #endif /* !HAVE_TERMIOS_H */
77 
78 #include <netinet/in.h>
79 #include <arpa/inet.h>
80 #include <netdb.h>
81 #include <errno.h>
82 #include <stdio.h>
83 #include <string.h>
84 #ifdef HAVE_STRINGS_H
85 #	include <strings.h>
86 #endif
87 #include <stddef.h>
88 #include <stdlib.h>
89 #include <ctype.h>
90 #include <signal.h>
91 #include <setjmp.h>
92 #include <stdarg.h>
93 #include <assert.h>
94 #include <time.h>
95 #include <pwd.h>
96 #include <fcntl.h>
97 
98 #ifdef HAVE_LOCALE_H
99 #	include <locale.h>
100 #endif
101 #ifdef NEED_GETOPT_H
102 #	include <getopt.h>
103 #elif defined(NEED_GETOPT_EXTERN_DECLS)
104 	extern int optind, opterr, optopt;
105 	extern char *optarg;
106 #endif
107 
108 #ifdef __CYGWIN__
109 #	ifndef FOPEN_READ_TEXT
110 #		define FOPEN_READ_TEXT "rt"
111 #		define FOPEN_WRITE_TEXT "wt"
112 #		define FOPEN_APPEND_TEXT "at"
113 #	endif
114 #	ifndef FOPEN_READ_BINARY
115 #		define FOPEN_READ_BINARY "rb"
116 #		define FOPEN_WRITE_BINARY "wb"
117 #		define FOPEN_APPEND_BINARY "ab"
118 #	endif
119 #else
120 #	ifndef FOPEN_READ_TEXT
121 #		define FOPEN_READ_TEXT "r"
122 #		define FOPEN_WRITE_TEXT "w"
123 #		define FOPEN_APPEND_TEXT "a"
124 #	endif
125 #	ifndef FOPEN_READ_BINARY
126 #		define FOPEN_READ_BINARY "r"
127 #		define FOPEN_WRITE_BINARY "w"
128 #		define FOPEN_APPEND_BINARY "a"
129 #	endif
130 #endif
131 
132 #if defined(MACOSX) || defined(BSDOS)
133 #	undef SIG_DFL
134 #	undef SIG_IGN
135 #	undef SIG_ERR
136 #	define SIG_DFL         (void (*)(int))0
137 #	define SIG_IGN         (void (*)(int))1
138 #	define SIG_ERR         (void (*)(int))-1
139 #endif
140 
141 #ifdef HAVE_NCURSES_H
142 #	define NCURSES_OPAQUE 0
143 #	include <ncurses.h>
144 #else
145 #	ifdef HAVE_CURSES_H
146 #		include <curses.h>
147 #	endif
148 #endif
149 
150 /* These next three sections are mostly for HP-UX 10. */
151 #if defined(HAVE___GETCURX) && defined(HAVE___GETCURY)
152 #	ifndef HAVE_GETYX
153 #		define HAVE_GETYX 1
154 #	endif
155 #	undef getyx
156 #	define getyx(w,y,x) (y) = __getcury((w)); (x) = __getcurx((w))
157 #endif
158 
159 #if defined(HAVE___GETMAXX) && !defined(HAVE_GETMAXX)
160 #	define HAVE_GETMAXX 1
161 #	undef getmaxx
162 #	define getmaxx __getmaxx
163 #endif
164 #if defined(HAVE___GETMAXY) && !defined(HAVE_GETMAXY)
165 #	define HAVE_GETMAXY 1
166 #	undef getmaxy
167 #	define getmaxy __getmaxy
168 #endif
169 #if defined(HAVE___GETMAXY) && defined(HAVE___GETMAXX) && !defined(HAVE_GETMAXYX)
170 #	define HAVE_GETMAXYX 1
171 #	undef getmaxyx
172 #	define getmaxyx(w,y,x) (y) = __getmaxy((w)); (x) = __getmaxx((w))
173 #endif
174 
175 #if defined(HAVE___GETBEGX) && !defined(HAVE_GETBEGX)
176 #	define HAVE_GETBEGX 1
177 #	undef getbegx
178 #	define getbegx __getbegx
179 #endif
180 #if defined(HAVE___GETBEGY) && !defined(HAVE_GETBEGY)
181 #	define HAVE_GETBEGY 1
182 #	undef getbegy
183 #	define getbegy __getbegy
184 #endif
185 #if defined(HAVE___GETBEGY) && defined(HAVE___GETBEGX) && !defined(HAVE_GETBEGYX)
186 #	define HAVE_GETBEGYX 1
187 #	undef getbegyx
188 #	define getbegyx(w,y,x) (y) = __getbegy((w)); (x) = __getbegx((w))
189 #endif
190 
191 /* Otherwise, try accessing the structure directly. */
192 #ifndef HAVE_GETMAXYX
193 #	ifdef HAVE__MAXX
194 #		ifndef getmaxyx
195 #			define getmaxyx(w,y,x) y = w->_maxy;  x = w->_maxx
196 #		endif
197 #		ifndef getbegyx
198 #			define getbegyx(w,y,x) y = w->_begy;  x = w->_begx
199 #		endif
200 #	else
201 #		ifndef getmaxyx
202 #			define getmaxyx(w,y,x) y = w->maxy;  x = w->maxx
203 #		endif
204 #		ifndef getbegyx
205 #			define getbegyx(w,y,x) y = w->begy;  x = w->begx
206 #		endif
207 #	endif
208 #endif
209 
210 #ifndef HAVE_GETMAXX
211 #	ifdef HAVE__MAXX
212 #		ifndef getmaxy
213 #			define getmaxy(win) ((win)->_maxy)
214 #		endif
215 #		ifndef getmaxx
216 #			define getmaxx(win) ((win)->_maxx)
217 #		endif
218 #	else
219 #		ifndef getmaxy
220 #			define getmaxy(win) ((win)->maxy)
221 #		endif
222 #		ifndef getmaxx
223 #			define getmaxx(win) ((win)->maxx)
224 #		endif
225 #	endif
226 #endif
227 
228 #ifndef HAVE_GETBEGX
229 #	ifdef HAVE__MAXX
230 #		ifndef getbegy
231 #			define getbegy(win) ((win)->_begy)
232 #		endif
233 #		ifndef getbegx
234 #			define getbegx(win) ((win)->_begx)
235 #		endif
236 #	else
237 #		ifndef getbegy
238 #			define getbegy(win) ((win)->begy)
239 #		endif
240 #		ifndef getbegx
241 #			define getbegx(win) ((win)->begx)
242 #		endif
243 #	endif
244 #endif
245 
246 #ifndef HAVE_TOUCHWIN
247 #	ifdef HAVE__MAXX
248 #		ifndef touchwin
249 #			define touchwin(win) wtouchln((win), 0, (win)->_maxy, 1)
250 #		endif
251 #	else
252 #		ifndef touchwin
253 #			define touchwin(win) wtouchln((win), 0, (win)->maxy, 1)
254 #		endif
255 #	endif
256 #endif
257 
258 #ifndef HAVE_CURS_SET
259 #	ifndef curs_set
260 #		define curs_set(a)
261 #	endif
262 #endif
263 
264 #ifdef HAVE_DOUPDATE
265 #	define DOUPDATE(a) doupdate()
266 #else
267 #	define DOUPDATE(a)
268 #endif
269 
270 #ifndef HAVE_NODELAY
271 #	ifndef nodelay
272 #		define nodelay(win,boolval)
273 #	endif
274 #endif
275 
276 #ifndef HAVE_WNOUTREFRESH
277 #	ifndef wnoutrefresh
278 #		define wnoutrefresh wrefresh
279 #	endif
280 #endif
281 
282 #ifndef HAVE_KEYPAD
283 #	ifndef keypad
284 #		define keypad(win,boolval)
285 #	endif
286 #endif
287 
288 #ifdef HAVE_BEEP
289 #	define BEEP(a)	beep()
290 #else
291 #	define BEEP(a)
292 #endif
293 
294 #define NDEBUG 1			/* For assertions. */
295 
296 #if ((defined(HAVE_LONG_LONG)) && (defined(_LARGEFILE64_SOURCE)) && (defined(HAVE_OPEN64)))
297 #	define Open open64
298 #else
299 #	define Open open
300 #endif
301 
302 #if (defined(WIN32) || defined(_WINDOWS)) && !defined(__CYGWIN__)
303 #	define Stat WinStat64
304 #	define Lstat WinStat64
305 #	define Fstat WinFStat64
306 #elif ((defined(HAVE_LONG_LONG)) && (defined(_LARGEFILE64_SOURCE)) && (defined(HAVE_STAT64)) && (defined(HAVE_STRUCT_STAT64)))
307 #	define Stat stat64
308 #	ifdef HAVE_FSTAT64
309 #		define Fstat fstat64
310 #	else
311 #		define Fstat fstat
312 #	endif
313 #	ifdef HAVE_LSTAT64
314 #		define Lstat lstat64
315 #	else
316 #		define Lstat lstat
317 #	endif
318 #else
319 #	define Stat stat
320 #	define Fstat fstat
321 #	define Lstat lstat
322 #endif
323 
324 #if (((defined(_FILE_OFFSET_BITS)) && (_FILE_OFFSET_BITS > 32)) || ((defined(SIZEOF_OFF_T)) && (SIZEOF_OFF_T > 4)))
325 #	define Lseek(a,b,c) lseek(a, (off_t) b, c)
326 #elif ((defined(HAVE_LONG_LONG)) && (defined(_LARGEFILE64_SOURCE)) && (defined(HAVE_LSEEK64)))
327 #	define Lseek(a,b,c) lseek64(a, (longest_int) b, c)
328 #else
329 #	define Lseek(a,b,c) lseek(a, (off_t) b, c)
330 #endif
331 
332 #if (defined(SOCKS)) && (SOCKS >= 5)
333 #	ifdef HAVE_SOCKS_H
334 #		ifdef HAVE_SOCKS5P_H
335 #			define INCLUDE_PROTOTYPES 1
336 #		endif
337 #		include <socks.h>
338 #	endif
339 #endif	/* SOCKS */
340 
341 #include <Strn.h>			/* Library header. */
342 #include <sio.h>			/* Because ../ncftp/util.c needs it. */
343 #include <ncftp.h>			/* Mostly for utility routines it has. */
344 
345 #ifdef DNSSEC_LOCAL_VALIDATION
346 #include <validator/validator.h>
347 #endif
348 
349