--- parser3/src/lib/smtp/smtp.h 2004/02/11 15:33:15 1.2 +++ parser3/src/lib/smtp/smtp.h 2012/06/20 20:54:26 1.9 @@ -1,16 +1,105 @@ /** @file Parser: SMTP sender decl. - Copyright (c) 2001-2004 ArtLebedev Group (http://www.artlebedev.com) + Copyright (c) 2001-2012 Art. Lebedev Studio (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char * const IDENT_SMTP_H="$Date: 2004/02/11 15:33:15 $"; +#define IDENT_SMTP_H "$Id: smtp.h,v 1.9 2012/06/20 20:54:26 moko Exp $" #include "pa_string.h" -#include +#ifdef WIN32 +#include + +#ifdef CYGWIN +typedef u_int SOCKET; +#define INVALID_SOCKET (SOCKET)(~0) + +extern "C" int PASCAL FAR closesocket(SOCKET); +extern "C" int PASCAL FAR WSAGetLastError(); +extern "C" int PASCAL FAR ioctlsocket(SOCKET, long, u_long FAR *); +#endif + +#else // WIN32 + +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 // WIN32 ////////////////////////////////////////////////////////////////////////////// @@ -21,7 +110,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 +151,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 +164,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* );