PageRenderTime 51ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 1ms

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