//---------------------------------------------------------------------------

#ifndef qfspopH
#define qfspopH
#define str(X) IntToStr(X)
#define ROWS DM1->SQLQuery2->RecordCount
#define ROWSM DM1->SQLQuery3->RecordCount
#define reStr(X) DM1->SQLQuery2->Fields->Fields[X]->AsString
#define reInt(X) DM1->SQLQuery2->Fields->Fields[X]->AsInteger
#define reStrm(X) DM1->SQLQuery3->Fields->Fields[X]->AsString
#define reIntm(X) DM1->SQLQuery3->Fields->Fields[X]->AsInteger
#define reDatem(X) DM1->SQLQuery3->Fields->Fields[X]->AsDateTime
#define FIRST DM1->SQLQuery2->First()
#define NEXT DM1->SQLQuery2->Next()
#define CLOSE DM1->SQLQuery2->Close();DM1->SQLConnection1->CloseDataSets()
#define CLOSEM DM1->SQLQuery3->Close();DM1->SQLConnection1->CloseDataSets()
#define DBLOOP while(!DM1->SQLQuery2->Eof)
#define PopName 0
#define PopHost 1
#define PopUser 2
#define PopPassword 3
#define PopPort 4
#define PopApop 5
#define PopNoDelete 6
#define PopDeleteDay 7
//---------------------------------------------------------------------------
#include <Classes.hpp>
//---------------------------------------------------------------------------
class ThPop : public TThread
{
private:
        void __fastcall WriteHeader(int m_id,char *st);
        void __fastcall ToSjis(AnsiString &st);
        int __fastcall sql(AnsiString q);
        void __fastcall sql2(AnsiString q);
        int __fastcall sqm(AnsiString q);
        void __fastcall sqm2(AnsiString q);
        void __fastcall RecieveMail(int sv);
//        void __fastcall Split(AnsiString txt,char c);
        void __fastcall Split2(AnsiString txt,char c);
        AnsiString __fastcall GenChar(AnsiString st);
        void __fastcall GenCharStore(AnsiString st,TStringList *li_sql);
        int __fastcall InsertMail(int m_id,int d_id,char flag,char state,
AnsiString mailfrom,AnsiString recipients,AnsiString cc,AnsiString replyto,
AnsiString sdate,AnsiString subject,char priority,
AnsiString header,AnsiString body,int size,AnsiString MessageId);
        int __fastcall InsertAttachment(int m_id,AnsiString filename,AnsiString encode);
        AnsiString fi_head,fi_list;
        void __fastcall AddLog1(void);
        void __fastcall Status1(void);
        TStringList *li_split2,*li_sql,*li_list,*li_head;
        bool __fastcall delTab(AnsiString &st);
        AnsiString RecieveResult;
        void __fastcall DeleteEscape(AnsiString &st);
        AnsiString __fastcall HeadVal(AnsiString na,TStringList *li);
        AnsiString __fastcall Bencode(AnsiString st);
        void __fastcall ToSjisChar(char *buf,char *buf2,unsigned short cod,int len);
protected:
        void __fastcall Execute();
public:
        __fastcall ThPop(bool CreateSuspended);
        int errcnt;
};
//---------------------------------------------------------------------------
#endif
