home *** CD-ROM | disk | FTP | other *** search
/ ftp.ncftp.com / ftp.ncftp.com.zip / ftp.ncftp.com / ncftp / older_versions / ncftp-3.2.2-src.tar.bz2 / ncftp-3.2.2-src.tar / ncftp-3.2.2 / libncftp / syshdrs.h < prev    next >
C/C++ Source or Header  |  2008-09-04  |  9KB  |  351 lines

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