PageRenderTime 32ms CodeModel.GetById 20ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/ncftp-3.2.5/libncftp/syshdrs.h

#
C Header | 360 lines | 318 code | 25 blank | 17 comment | 31 complexity | 6b6ecfa34ce13e902dcbb2de2c765864 MD5 | raw file
Possible License(s): AGPL-3.0
  1/* syshdrs.h
  2 *
  3 * Copyright (c) 1996-2005 Mike Gleason, NcFTP Software.
  4 * All rights reserved.
  5 *
  6 */
  7
  8#if (defined(WIN32) || defined(_WINDOWS)) && !defined(__CYGWIN__)
  9#	pragma once
 10#	define _CRT_SECURE_NO_WARNINGS 1
 11#	ifndef __MINGW32__
 12#		pragma warning(disable : 4127)	// warning C4127: conditional expression is constant
 13#		pragma warning(disable : 4100)	// warning C4100: 'lpReserved' : unreferenced formal parameter
 14#		pragma warning(disable : 4514)	// warning C4514: unreferenced inline function has been removed
 15#		pragma warning(disable : 4115)	// warning C4115: '_RPC_ASYNC_STATE' : named type definition in parentheses
 16#		pragma warning(disable : 4201)	// warning C4201: nonstandard extension used : nameless struct/union
 17#		pragma warning(disable : 4214)	// warning C4214: nonstandard extension used : bit field types other than int
 18#		pragma warning(disable : 4115)	// warning C4115: 'IRpcStubBuffer' : named type definition in parentheses
 19#	endif
 20	/* Include "wincfg.h" in place of "config.h" */
 21#	include "wincfg.h"
 22	/* We now try for at least Windows 2000 compatibility (0x0500).
 23	 * The code will still work on older systems, though.
 24	 * Prior versions used 0x0400 instead.
 25	 */
 26#	ifndef WINVER
 27#		define WINVER 0x0500
 28#	endif
 29#	ifndef _WIN32_WINNT
 30#		define _WIN32_WINNT 0x0500
 31#	endif
 32#	include <windows.h>		/* includes <winsock2.h> if _WIN32_WINNT >= 0x400 */
 33#	include <shlobj.h>
 34#	include <io.h>
 35#	include <conio.h>
 36#	include <direct.h>
 37#	include <errno.h>
 38#	include <stdio.h>
 39#	include <string.h>
 40#	include <stddef.h>
 41#	include <stdlib.h>
 42#	include <ctype.h>
 43#	include <stdarg.h>
 44#	include <time.h>
 45#	include <sys/types.h>
 46#	include <sys/stat.h>
 47#	include <sys/utime.h>
 48#	include <fcntl.h>
 49#	define strcasecmp _stricmp
 50#	define strncasecmp _strnicmp
 51#	define strdup _strdup
 52#	define fdopen _fdopen
 53#	define sleep WinSleep
 54#	ifndef mode_t
 55#		define mode_t int
 56#	endif
 57#	ifndef S_ISREG
 58#		define S_ISREG(m)      (((m) & _S_IFMT) == _S_IFREG)
 59#		define S_ISDIR(m)      (((m) & _S_IFMT) == _S_IFDIR)
 60#		define S_ISLNK(m)      (0)
 61#	endif
 62#	ifndef S_IFREG
 63#		define S_IFREG _S_IFREG
 64#		define S_IFDIR _S_IFDIR
 65#	endif
 66#	ifndef open
 67#		define open _open
 68#		define write _write
 69#		define read _read
 70#		define close _close
 71#		define lseek _lseek
 72#		define stat _stat
 73#		define lstat _stat
 74#		define fstat _fstat
 75#		define dup _dup
 76#		define utime _utime
 77#		define utimbuf _utimbuf
 78#	endif
 79#	ifndef unlink
 80#		define unlink remove
 81#	endif
 82#	ifndef vsnprintf
 83#		define vsnprintf _vsnprintf
 84#	endif
 85#	ifndef snprintf
 86#		define snprintf _snprintf
 87#	endif
 88#	ifndef FOPEN_READ_TEXT
 89#		define FOPEN_READ_TEXT "rt"
 90#		define FOPEN_WRITE_TEXT "wt"
 91#		define FOPEN_APPEND_TEXT "at"
 92#	endif
 93#	ifndef FOPEN_READ_BINARY
 94#		define FOPEN_READ_BINARY "rb"
 95#		define FOPEN_WRITE_BINARY "wb"
 96#		define FOPEN_APPEND_BINARY "ab"
 97#	endif
 98#	define MY_FD_ZERO FD_ZERO
 99#	define MY_FD_SET(s,set) FD_SET((SOCKET) (s), set)
100#	define MY_FD_CLR(s,set) FD_CLR((SOCKET) (s), set)
101#	define MY_FD_ISSET FD_ISSET
102#	define NO_SIGNALS 1
103#	define USE_SIO 1
104#else /* ---------------------------- UNIX ---------------------------- */
105#	if defined(HAVE_CONFIG_H)
106#		include <config.h>
107#	endif
108#	if defined(AIX) || defined(_AIX) || defined(__HOS_AIX__)
109#		define _ALL_SOURCE 1
110#	endif
111#	ifdef HAVE_UNISTD_H
112#		include <unistd.h>
113#	endif
114#	include <sys/types.h>
115#	include <sys/stat.h>
116#	include <sys/time.h>
117#	include <sys/socket.h>
118#	include <sys/ioctl.h>
119#	include <sys/wait.h>
120#	if !defined(HAVE_GETCWD) && defined(HAVE_GETWD)
121#		include <sys/param.h>
122#	endif
123#	if defined(HAVE_UNAME) && defined(HAVE_SYS_UTSNAME_H)
124#		include <sys/utsname.h>
125#	endif
126#	ifdef HAVE_SYS_SYSTEMINFO_H
127#		include <sys/systeminfo.h>
128#	endif
129#	ifdef HAVE_GNU_LIBC_VERSION_H
130#		include <gnu/libc-version.h>
131#	endif
132
133#	include <netinet/in_systm.h>
134#	include <netinet/in.h>
135#	include <netinet/ip.h>
136#	include <netinet/tcp.h>
137#	include <arpa/inet.h>
138#	include <arpa/telnet.h>
139#	include <netdb.h>
140#	include <errno.h>
141#	include <stdio.h>
142#	include <string.h>
143#	ifdef HAVE_STRINGS_H
144#		include <strings.h>
145#	endif
146#	include <stddef.h>
147#	include <stdlib.h>
148#	include <ctype.h>
149#	include <signal.h>
150#	include <setjmp.h>
151#	include <stdarg.h>
152#	include <time.h>
153#	include <pwd.h>
154#	include <dirent.h>
155#	include <fcntl.h>
156
157#	ifdef HAVE_NET_ERRNO_H
158#		include <net/errno.h>
159#	endif
160#	ifdef HAVE_ARPA_NAMESER_H
161#		include <arpa/nameser.h>
162#	endif
163#	ifdef HAVE_NSERVE_H
164#		ifdef SCO
165#			undef MAXDNAME
166#		endif
167#		include <nserve.h>
168#	endif
169#	ifdef HAVE_RESOLV_H
170#		include <resolv.h>
171#	endif
172
173#	ifdef CAN_USE_SYS_SELECT_H
174#		include <sys/select.h>
175#	endif
176#	define MY_FD_ZERO FD_ZERO
177#	define MY_FD_SET FD_SET
178#	define MY_FD_CLR FD_CLR
179#	define MY_FD_ISSET FD_ISSET
180
181#	ifndef SETSOCKOPT_ARG4
182#		define SETSOCKOPT_ARG4
183#		define GETSOCKOPT_ARG4
184#	endif
185
186#	ifdef HAVE_UTIME_H
187#		include <utime.h>
188#	elif defined(HAVE_SYS_UTIME_H)
189#		include <sys/utime.h>
190#	else
191		struct utimbuf { time_t actime, modtime; };
192#	endif
193
194#	ifdef HAVE_GETCWD
195#		ifndef HAVE_UNISTD_H
196			extern char *getcwd();
197#		endif
198#	else
199#		ifdef HAVE_GETWD
200#			include <sys/param.h>
201#			ifndef MAXPATHLEN
202#				define MAXPATHLEN 1024
203#			endif
204			extern char *getwd(char *);
205#		endif
206#	endif
207
208#	ifdef __CYGWIN__
209#		ifndef FOPEN_READ_TEXT
210#			define FOPEN_READ_TEXT "rt"
211#			define FOPEN_WRITE_TEXT "wt"
212#			define FOPEN_APPEND_TEXT "at"
213#		endif
214#		ifndef FOPEN_READ_BINARY
215#			define FOPEN_READ_BINARY "rb"
216#			define FOPEN_WRITE_BINARY "wb"
217#			define FOPEN_APPEND_BINARY "ab"
218#		endif
219#	else
220#		ifndef FOPEN_READ_TEXT
221#			define FOPEN_READ_TEXT "r"
222#			define FOPEN_WRITE_TEXT "w"
223#			define FOPEN_APPEND_TEXT "a"
224#		endif
225#		ifndef FOPEN_READ_BINARY
226#			define FOPEN_READ_BINARY "r"
227#			define FOPEN_WRITE_BINARY "w"
228#			define FOPEN_APPEND_BINARY "a"
229#		endif
230#	endif
231
232#	if defined(MACOSX) || defined(BSDOS)
233#		undef SIG_DFL
234#		undef SIG_IGN
235#		undef SIG_ERR
236#		define SIG_DFL         (void (*)(int))0
237#		define SIG_IGN         (void (*)(int))1
238#		define SIG_ERR         (void (*)(int))-1
239#	endif
240#endif /* ---------------------------- UNIX ---------------------------- */
241
242
243#if ((defined(HAVE_LONG_LONG)) && (defined(_LARGEFILE64_SOURCE)) && (defined(HAVE_OPEN64)))
244#	define Open open64
245#else
246#	define Open open
247#endif
248
249#if (defined(WIN32) || defined(_WINDOWS)) && !defined(__CYGWIN__)
250#	define Stat WinStat64
251#	define Lstat WinStat64
252#	define Fstat WinFStat64
253#elif ((defined(HAVE_LONG_LONG)) && (defined(_LARGEFILE64_SOURCE)) && (defined(HAVE_STAT64)) && (defined(HAVE_STRUCT_STAT64)))
254#	define Stat stat64
255#	ifdef HAVE_FSTAT64
256#		define Fstat fstat64
257#	else
258#		define Fstat fstat
259#	endif
260#	ifdef HAVE_LSTAT64
261#		define Lstat lstat64
262#	else
263#		define Lstat lstat
264#	endif
265#else
266#	define Stat stat
267#	define Fstat fstat
268#	define Lstat lstat
269#endif
270
271#ifndef Lseek
272#	if (defined(WIN32) || defined(_WINDOWS)) && !defined(__CYGWIN__)
273#		define Lseek(a,b,c) _lseeki64(a, (__int64) b, c)
274#	elif (((defined(_FILE_OFFSET_BITS)) && (_FILE_OFFSET_BITS > 32)) || ((defined(SIZEOF_OFF_T)) && (SIZEOF_OFF_T > 4)))
275#		define Lseek(a,b,c) lseek(a, (off_t) b, c)
276#	elif ((defined(HAVE_LONG_LONG)) && (defined(_LARGEFILE64_SOURCE)) && (defined(HAVE_LSEEK64)))
277#		define Lseek(a,b,c) lseek64(a, (longest_int) b, c)
278#	else
279#		define Lseek(a,b,c) lseek(a, (off_t) b, c)
280#	endif
281#endif
282
283#if (defined(AIX) && (AIX >= 430))
284/* AIX 4.3's sys/socket.h doesn't properly prototype these for C */
285extern int naccept(int, struct sockaddr *, socklen_t *);
286extern int ngetpeername(int, struct sockaddr *, socklen_t *);
287extern int ngetsockname(int, struct sockaddr *, socklen_t *);
288extern ssize_t nrecvfrom(int, void *, size_t, int, struct sockaddr *, socklen_t *);
289extern ssize_t nrecvmsg(int, struct msghdr *, int);
290extern ssize_t nsendmsg(int, const struct msghdr *, int);
291#endif
292
293
294#ifndef IAC
295
296/*
297 * Definitions for the TELNET protocol.
298 */
299#define IAC     255             /* interpret as command: */
300#define DONT    254             /* you are not to use option */
301#define DO      253             /* please, you use option */
302#define WONT    252             /* I won't use option */
303#define WILL    251             /* I will use option */
304#define SB      250             /* interpret as subnegotiation */
305#define GA      249             /* you may reverse the line */
306#define EL      248             /* erase the current line */
307#define EC      247             /* erase the current character */
308#define AYT     246             /* are you there */
309#define AO      245             /* abort output--but let prog finish */
310#define IP      244             /* interrupt process--permanently */
311#define BREAK   243             /* break */
312#define DM      242             /* data mark--for connect. cleaning */
313#define NOP     241             /* nop */
314#define SE      240             /* end sub negotiation */
315#define EOR     239             /* end of record (transparent mode) */
316#define ABORT   238             /* Abort process */
317#define SUSP    237             /* Suspend process */
318#define xEOF    236             /* End of file: EOF is already used... */
319
320#define SYNCH   242             /* for telfunc calls */
321#endif
322
323#if (defined(SOCKS)) && (SOCKS >= 5)
324#	ifdef HAVE_SOCKS_H
325#		ifdef HAVE_SOCKS5P_H
326#			define INCLUDE_PROTOTYPES 1
327#		endif
328#		include <socks.h>
329#	endif
330#endif	/* SOCKS */
331
332#if 1 /* %config2% -- set by configure script -- do not modify */
333#	ifndef USE_SIO
334#		define USE_SIO 1
335#	endif
336#	ifndef NO_SIGNALS
337#		define NO_SIGNALS 1
338#	endif
339#else
340#	ifndef USE_SIO
341#		define USE_SIO 0
342#	endif
343	/* #undef NO_SIGNALS */
344#endif
345
346#if USE_SIO
347#	include <sio.h>			/* Library header. */
348#endif
349
350#include <Strn.h>			/* Library header. */
351#include "ncftp.h"			/* Library header. */
352
353#include "util.h"
354#include "ftp.h"
355
356#ifdef DNSSEC_LOCAL_VALIDATION
357#include <validator/validator.h>
358#endif
359
360/* eof */