--- parser3/src/lib/smtp/smtp.h 2003/11/21 12:35:50 1.1 +++ parser3/src/lib/smtp/smtp.h 2006/04/09 13:38:47 1.7 @@ -1,16 +1,93 @@ /** @file Parser: SMTP sender decl. - Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com) + Copyright (c) 2001-2005 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char * const IDENT_SMTP_H="$Date: 2003/11/21 12:35:50 $"; +static const char * const IDENT_SMTP_H="$Date: 2006/04/09 13:38:47 $"; #include "pa_string.h" -#include +#ifdef CYGWIN +#define _GNU_H_WINDOWS32_SOCKETS +// for PASCAL +#include +// SOCKET +typedef u_int SOCKET; +int PASCAL closesocket(SOCKET); +#else +# if defined(WIN32) +# define WINVER 0x0400 +# include +# else + typedef char CHAR; + typedef u_int SOCKET; +# define closesocket close + inline int WSAGetLastError() { return errno; } + +#ifdef EPROTONOSUPPORT +# define WSAEPROTONOSUPPORT EPROTONOSUPPORT +#else +# define WSAEPROTONOSUPPORT (10000) +#endif +#ifdef ESOCKTNOSUPPORT +# define WSAESOCKTNOSUPPORT ESOCKTNOSUPPORT +#else +# define WSAESOCKTNOSUPPORT (10001) +#endif +#ifdef ENOTCONN +# define WSAENOTCONN ENOTCONN +#else +# define WSAENOTCONN (10002) +#endif +#ifdef ESHUTDOWN +# define WSAENETDOWN ESHUTDOWN +#else +# define WSAENETDOWN (10003) +#endif +#ifdef EHOSTUNREACH +# define WSAENETUNREACH EHOSTUNREACH +#else +# define WSAENETUNREACH (10004) +#endif +#ifdef ENETRESET +# define WSAENETRESET ENETRESET +#else +# define WSAENETRESET (10005) +#endif +#ifdef ECONNABORTED +# define WSAECONNABORTED ECONNABORTED +#else +# define WSAECONNABORTED (10006) +#endif +#ifdef ECONNRESET +# define WSAECONNRESET ECONNRESET +#else +# define WSAECONNRESET (10007) +#endif +#ifdef EWOULDBLOCK +# define WSAEWOULDBLOCK EWOULDBLOCK +#else +# define WSAEWOULDBLOCK (10008) +#endif +#ifdef ECONNREFUSED +# define WSAECONNREFUSED ECONNREFUSED +#else +# define WSAECONNREFUSED (10009) +#endif +# define WSAHOST_NOT_FOUND (10010) + +# ifndef INADDR_NONE +# define INADDR_NONE ((unsigned long) -1) +# endif + +# ifndef INVALID_SOCKET +# define INVALID_SOCKET (SOCKET)(~0) +# endif +# endif +#endif ////////////////////////////////////////////////////////////////////////////// @@ -21,7 +98,8 @@ static const char * const IDENT_SMTP_H=" #define ERR_CLOSING 4012 #define WAIT_A_BIT 4013 -#define MAXOUTLINE 255 +/// must be >=SOCKET_BUFFER_SIZE, thanks to Lev Walkin for pointing that out +#define MAXOUTLINE (SOCKET_BUFFER_SIZE*2) ////////////////////////////////////////////////////////////////////////////// @@ -61,7 +139,7 @@ public: // smtp.C void Send(const char* , const char* , const char* , char *, char *); - BOOL MakeSmtpHeader(char *, char *, char *, char *); + bool MakeSmtpHeader(char *, char *, char *, char *); void prepare_message(char *, char *, const char* , const char* ); void open_socket(const char* , const char* ); int get_line(void); @@ -74,7 +152,7 @@ public: void SendLine(const char* , unsigned long); void SendBuffer(const char* , unsigned long); void FlushBuffer(); - BOOL CloseConnect(); + bool CloseConnect(); // comms.C int IsAddressARawIpaddress(const char* );