Annotation of parser3/src/lib/smtp/smtp.h, revision 1.3

1.1       paf         1: /** @file
                      2:        Parser: SMTP sender decl.
                      3: 
1.2       paf         4:        Copyright (c) 2001-2004 ArtLebedev Group (http://www.artlebedev.com)
1.1       paf         5:        Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
                      6: */
                      7: 
1.3     ! paf         8: static const char * const IDENT_SMTP_H="$Date: 2004/02/11 15:33:15 $";
1.1       paf         9: 
                     10: 
                     11: #include "pa_string.h"
                     12: 
1.3     ! paf        13: #ifdef CYGWIN
        !            14: #define _GNU_H_WINDOWS32_SOCKETS
        !            15: // for PASCAL
        !            16: #include <windows.h>
        !            17: // SOCKET
        !            18: typedef u_int  SOCKET;
        !            19: int PASCAL closesocket(SOCKET);
        !            20: #else
        !            21: #      if defined(WIN32)
        !            22: #              include <windows.h>
        !            23: #      else
        !            24:                typedef char    CHAR;
        !            25:                typedef u_int   SOCKET;
        !            26: #              define closesocket close
        !            27:                inline int WSAGetLastError() { return errno; }
        !            28: #              define WSAEPROTONOSUPPORT EPROTONOSUPPORT
        !            29: #              define WSAESOCKTNOSUPPORT ESOCKTNOSUPPORT
        !            30: #              define WSAENOTCONN ENOTCONN
        !            31: #              define WSAENETDOWN ESHUTDOWN
        !            32: #              define WSAENETUNREACH EHOSTUNREACH
        !            33: #              define WSAENETRESET ENETRESET
        !            34: #              define WSAECONNABORTED ECONNABORTED
        !            35: #              define WSAECONNRESET ECONNRESET
        !            36: #              define WSAEWOULDBLOCK EWOULDBLOCK
        !            37: #              define WSAECONNREFUSED ECONNREFUSED
        !            38: 
        !            39: #              define WSAHOST_NOT_FOUND (2)
        !            40: #              ifndef INADDR_NONE
        !            41: #                      define INADDR_NONE ((unsigned long) -1)
        !            42: #              endif
        !            43: #              ifndef INVALID_SOCKET
        !            44: #                      define INVALID_SOCKET  (SOCKET)(~0)
        !            45: #              endif
        !            46: #      endif
        !            47: #endif
1.1       paf        48: 
                     49: //////////////////////////////////////////////////////////////////////////////
                     50: 
                     51: #define SOCKET_BUFFER_SIZE     512
                     52: 
                     53: #define ERR_SENDING_DATA               4002
                     54: #define ERR_NOT_A_SOCKET               4010
                     55: #define ERR_CLOSING                    4012
                     56: #define WAIT_A_BIT                     4013
                     57: 
                     58: #define MAXOUTLINE 255
                     59: 
                     60: //////////////////////////////////////////////////////////////////////////////
                     61: 
                     62: /// SIMPLE MAIL TRANSPORT PROTOCOL Win32 realization
                     63: class SMTP: public PA_Object {
                     64:     char            *in_buffer;
                     65:     char            *out_buffer;
                     66:     unsigned int       in_index;
                     67:     unsigned int       out_index;
                     68:     unsigned int       in_buffer_total;
                     69:     unsigned int       out_buffer_total;
                     70:     unsigned int       last_winsock_error;
                     71:     fd_set             fds;
                     72:     struct timeval     timeout;
                     73: 
                     74:     SOCKET     the_socket;
                     75: 
                     76:        char    my_hostname[1024];
                     77: 
                     78:     CHAR    ServerProtocol[100];
                     79:     CHAR    RemoteAddress[100];
                     80:     CHAR    RemoteHost[100];
                     81:     CHAR    RemoteUser[100];
                     82:     CHAR    HttpAccept[100];
                     83:     CHAR    HttpUserAgent[256];
                     84: 
                     85:     CHAR    FirstName[100];
                     86:     CHAR    LastName[100];
                     87:     CHAR    WebUse[100];
                     88:     CHAR    EMail[100];
                     89:     CHAR    HomePage[100];
                     90:     CHAR    text[500];
                     91: 
                     92: public:
                     93:        SMTP();
                     94:        override ~SMTP();
                     95: 
                     96:     // smtp.C
                     97:        void    Send(const char* , const char* , const char* ,  char *, char *);
1.3     ! paf        98:        bool    MakeSmtpHeader(char *, char *, char *, char *);
1.1       paf        99:        void    prepare_message(char *, char *,  const char* , const char* );
                    100:        void    open_socket(const char* , const char* );
                    101:        int             get_line(void);
                    102:        void    SendSmtpError(const char* );
                    103:        void    transform_and_send_edit_data(const char* );
                    104:        void    send_data(const char* );
                    105:        void    ConnectToHost(const char* , const char* );
                    106:        int             GetBuffer(int);
                    107:        int             GetChar(int, char *);
                    108:        void    SendLine(const char* , unsigned long);
                    109:        void    SendBuffer(const char* , unsigned long);
                    110:        void    FlushBuffer();
1.3     ! paf       111:        bool    CloseConnect();
1.1       paf       112: 
                    113:     // comms.C
                    114:     int      IsAddressARawIpaddress(const char* );
                    115:     int      ResolveService(const char* , u_short *);
                    116:     int      ResolveHostname(const char* , struct sockaddr_in *);
                    117:     int      GetAndSetTheSocket(SOCKET *);
                    118:     int      GetConnection(SOCKET, struct sockaddr_in *);
                    119:     void     MiscSocketSetup(SOCKET, fd_set *, struct timeval *);
                    120: };

E-mail: