Click here to Skip to main content
13,596,556 members
Click here to Skip to main content

Stats

1.5M views
40.2K downloads
257 bookmarked
Posted 24 Aug 2007
Licenced CPOL

The Ultimate TCP/IP Home Page

, 25 Aug 2007
Ultimate TCP-IP is now Open Source
UTCP_IP42.chi
UTCP_IP42.chm
Ultimate TCP-IP
ActiveX
BuildAll
All.dsw
MinDependency_Dlls
MinDependency_EvalDlls
UTDns
dns.bmp
DNS.rgs
DNSPropPage.rgs
icon_fin.ico
UTDns.def
UTDns.dsp
UTDns.dsw
UTDns.vcproj
UTDnsps.def
UTFinger
finger.bmp
Finger.rgs
FingerProp.rgs
icon_fin.ico
UTFinger.def
UTFinger.dsp
UTFinger.dsw
UTFinger.vcproj
UTFingerps.def
UTFingerServ
fingerse.bmp
FingerServ.rgs
FingerServProp.rgs
icon_fin.ico
UTFingerServ.def
UTFingerServ.dsp
UTFingerServ.dsw
UTFingerServ.vcproj
UTFingerServps.def
utftp
ftp.bmp
Ftp.rgs
FtpPropPage.rgs
icon_fin.ico
UTFtp.def
UTFtp.dsp
UTFtp.dsw
UTFtp.vcproj
UTFtpps.def
utftpserv
FtpSercPropPage.rgs
ftpserve.bmp
FtpServer.rgs
FtpServPropPage.rgs
icon_fin.ico
UTFtpServ.def
UTFtpServ.dsp
UTFtpServ.dsw
UTFtpServ.vcproj
UTFtpServps.def
UTHistory
history.bmp
History.rgs
HistoryPropPage.rgs
icon1.ico
UTHistory.def
UTHistory.dsp
UTHistory.dsw
UTHistory.vcproj
UTHistoryps.def
uthttp
http.bmp
Http.rgs
HttpPropPage.rgs
icon_fin.ico
UTHttp.def
UTHttp.dsp
UTHttp.dsw
UTHttp.vcproj
UTImap4
icon_fin.ico
imap4.bmp
IMAP4.rgs
IMAP4PropPage.rgs
UTImap4.def
UTImap4.dsp
UTImap4.dsw
UTImap4.vcproj
UTImap4ps.def
UTMail
icon_fin.ico
mail.bmp
Mail.rgs
Mail2.rgs
MailPropPage.rgs
MailPropPage2.rgs
UTMail.def
UTMail.dsp
UTMail.dsw
UTMail.vcproj
UTMailps.def
UTMailServ
icon_fin.ico
mailserv.bmp
MailServ.rgs
MailServPropPage.rgs
UTMailServ.def
UTMailServ.dsp
UTMailServ.dsw
UTMailServ.vcproj
UTMailServps.def
UTMsg
icon_fin.ico
message.bmp
Message.rgs
UTMsg.def
UTMsg.dsp
UTMsg.dsw
UTMsg.vcproj
UTMsgps.def
UTNntp
icon_fin.ico
nntp.bmp
Nntp.rgs
NntpPropPage.rgs
UTNntp.def
UTNntp.dsp
UTNntp.dsw
UTNntp.vcproj
UTNntpps.def
utping
icon_fin.ico
ping.bmp
Ping.rgs
PingProp.rgs
UTPing.def
UTPing.dsp
UTPing.dsw
UTPing.vcproj
UTPingps.def
UTSocket
icon_fin.ico
socket.bmp
Socket.rgs
SocketPropPage.rgs
UTSocket.def
UTSocket.dsp
UTSocket.dsw
UTSocket.vcproj
UTSocketps.def
Demos
DemoMaster.dsw
MsgMapper
MsgMapper.reg
MsgMapper.vcproj
res
mainfram.bmp
MsgMapper.ico
MsgMapperDoc.ico
Toolbar.bmp
Prop2
dns.jpg
DSITools.dsp
DSITools.vcproj
finger.jpg
Help
CONTEXT.CDX
Context.CHJ
CONTEXT.DBF
Context.DTO
CONTEXT.FPT
Context.HH
Context.rbh
Context.RTF
DIALOG.CID
DSITools.akw
DSITools.doc
DSITools.err
DSITOOLS.HLP
DSITools.hpj
DSITools.hpr
DSITools.hpt
DSITools.kkw
DSITools.rbh
DSITools.rtf
icon1.ico
icon2.ico
ping.jpg
Prop2.dsp
Prop2.dsw
SPLSHNetTools.BMP
tracert.jpg
whois.jpg
QuickMailer
icon1.ico
properties.GIF
QuickMailer.dsp
QuickMailer.dsw
QuickMailer.vcproj
small2.ico
SplashQM.BMP
Examples
Client
ASP
headline.gif
smallogo.gif
MFC
Imap4
IMAPClient.dsp
IMAPClient.dsw
IMAPClient.vcproj
res
IMAPClient.ico
IMAPClientDoc.ico
Toolbar.bmp
Nntp
NNTPclient.dsp
NNTPclient.dsw
NNTPclient.vcproj
res
Filecopy.avi
Findcomp.avi
NNTPclient.ico
SDK
DNS
Data.ico
DNSClient.dsp
DNSClient.dsw
DNSClient.vcproj
Finger
FingerClient.dsp
FingerClient.dsw
FingerClient.vcproj
icon1.ico
Ftp
FTPClient.dsp
FTPClient.dsw
FTPClient.vcproj
FTPClient.vcproj.CODEPROJECT.Nish.user
FTPClient.vcproj.vspscc
icon1.ico
History
icon1.ico
log.dsp
log.dsw
log.vcproj
Http
HTTPClient.dsp
HTTPClient.dsw
HTTPClient.vcproj
icon1.ico
Mail
icon1.ico
test.dsp
test.dsw
test.vcproj
MX Lookup
Data.ico
MXLookup.dsp
MXLookup.dsw
MXLookup.vcproj
Ping
Ping_c.dsp
Ping_c.dsw
Ping_c.vcproj
UDP
Monitor
Monitor.dsp
Monitor.dsw
Monitor.vcproj
Trace
Trace.dsp
Trace.dsw
Trace.vcproj
VisualBasic
Dns
DNSTest.vbp
DNSTest.vbw
icon1.ico
Finger
FingerTest.vbp
FingerTest.vbw
Ftp
FtpTest.vbp
FtpTest.vbw
icon1.ico
History
HistoryTest.vbp
HistoryTest.vbw
icon1.ico
Http
HttpTest.vbp
HttpTest.vbw
icon1.ico
Imap4
icon1.ico
IMAP4Test.SUP
IMAP4Test.vbp
IMAP4Test.vbw
Mail
icon1.ico
MailTest.vbp
MailTest.vbw
MartsMail
Bld.bmp
bullet1.bmp
Clip01.ico
COPY.BMP
CUT.BMP
icon1.ico
Itl.bmp
Mail01a.ico
Mail03.ico
Mail16b.ico
MailClient.vbp
MailClient.vbw
PASTE.BMP
Print.bmp
SAVE.BMP
Undrln.bmp
Nntp
icon1.ico
NntpTest.vbp
NntpTest.vbw
Ping
icon1.ico
PingTest.vbp
PingTest.vbw
Search.avi
Socket
icon1.ico
SEARCH.AVI
SocketTest.vbp
SocketTest.vbw
UDPSocket
UDPTest.vbp
UDPTest.vbw
Master.dsw
Server
ASP
MFC
SampleServer
icon1.ico
res
Sample_S.dsp
Sample_S.vcproj
SDK
AccessControlServerDemo
AccessControlServerDemo.dsp
AccessControlServerDemo.vcproj
icon1.ico
Finger
fing_s.dsp
fing_s.vcproj
icon1.ico
Ftp
ftp_s.dsp
ftp_s.vcproj
icon1.ico
Http
HTTP_s.dsp
HTTP_s.vcproj
icon1.ico
Mail
icon1.ico
server.dsp
server.dsw
server.vcproj
SPLASHMlS.BMP
VisualBasic
Finger
FingerServTest.vbp
FingerServTest.vbw
Ftp
FTPServTest.vbp
FTPServTest.vbw
Http
HttpServerTest.vbp
HttpServerTest.vbw
Mail
MailServerTest.vbp
MailServerTest.vbw
service
Service.dsp
Service.vcproj
svrtest
SVRTest.dsp
SVRTest.vcproj
Security
Examples
Client
Echo
EchoClient.dsp
EchoClient.dsw
EchoClientS.dsp
EchoClientS.vcproj
FTPs
client.dsp
client.dsw
FtpClientS.dsp
FtpClientS.vcproj
icon1.ico
Https
client.dsp
client.dsw
HttpClientS.dsp
HttpClientS.vcproj
icon1.ico
Imap4s
IMAPClient.dsp
IMAPClient.dsw
IMAPClientS.dsp
IMAPClientS.vcproj
res
IMAPClient.ico
IMAPClientDoc.ico
Toolbar.bmp
Mail
icon1.ico
icon2.ico
MailClientS.dsp
MailClientS.vcproj
test.dsp
test.dsw
MasterS.dsw
Server
Echo
EchoServer.dsp
EchoServer.dsw
EchoServerS.dsp
EchoServerS.vcproj
FTPs
FTPs.dsp
FTPs.dsw
FtpServerS.dsp
FtpServerS.vcproj
icon1.ico
Https
HttpServerS.dsp
HttpServerS.vcproj
HTTP_s.dsp
HTTP_s.dsw
icon1.ico
Mail
icon1.ico
MailServerS.dsp
MailServerS.vcproj
server.dsp
server.dsw
SPLASHMlS.BMP
Test_Del
Test_Del.dsp
Test_Del.dsw
Util
CertManager
CertManager.dsp
CertManager.dsw
CertManager.vcproj
Include
Include
Lib
TestCert.pfx
Res
certif.bmp
certif_m.bmp
icon_cer_l.ico
icon_cer_s.ico
key.bmp
location.bmp
location_m.bmp
location_s.bmp
location_s_m.bmp
store.bmp
store_m.bmp
SecureServers
Source
UTSecureLayer
UTSecureLayer.dsp
UTSecureLayer.dsw
UTSecureLayer.vcproj
Servers
source
// ==================================================================
//  class:  CUT_DataManager, CUT_UserManager, CUT_UserInfo
//  struct: CUT_QUEFileHandleList
//  File:   fileman.h
//  
//  Purpose:
//
//  Declaration of mail server file and user utility classes
//
// ==================================================================
// Ultimate TCP/IP v4.2
// This software along with its related components, documentation and files ("The Libraries")
// is � 1994-2007 The Code Project (1612916 Ontario Limited) and use of The Libraries is
// governed by a software license agreement ("Agreement").  Copies of the Agreement are
// available at The Code Project (www.codeproject.com), as part of the package you downloaded
// to obtain this file, or directly from our office.  For a copy of the license governing
// this software, you may contact us at legalaffairs@codeproject.com, or by calling 416-849-8900.
// ==================================================================
 
#ifndef CUT_DataManagerInclude
#define CUT_DataManagerInclude

class CUT_MailServer;
class CUT_UserInfo;
class CUT_QUEFileHandle;

#include <time.h>
#include <UT_CriticalSection.h>



// suppress level 4 warnings generated by STL - Transitional for VC6 support
#pragma warning ( push, 3 )	
#pragma warning (disable : 4018)
#include <vector>
#pragma warning (pop)
#pragma warning ( push, 3 )		
#include <list>
#pragma warning (pop)



using namespace std ;

typedef list<CUT_UserInfo>      USER_LIST;          // User information list
typedef list<CUT_QUEFileHandle> QUEUE_FILE_LIST;    // Queue file handles list
typedef vector<long>            LONG_VECTOR;        // Long vector


#define     MAX_USER_NAME_LENGTH    100

// ===================================
//  User information class
// ===================================
class CUT_UserInfo {
public:

    _TCHAR  szUserName[MAX_USER_NAME_LENGTH + 1];   // User name
    _TCHAR  szPassword[MAX_USER_NAME_LENGTH + 1];   // User password
    _TCHAR	szMailDir[MAX_PATH+1];                  // User mail directory

    CUT_TStringList  listEmailAddresses;             // List of e-mail addresses

    LONG_VECTOR     vcFileList;                     // List of Files IDs
    LONG_VECTOR     vcFileDeleteList;               // List of Deleted Files IDs
    LONG_VECTOR     vcFileSizeList;                 // List of Files lengths
    int             nFileListLength;                // Number of files in the list
    BOOL            bOpenFlag;                      // If TRUE user is opened
    long            nID;                            // User ID

public:

    // Default constructor
    CUT_UserInfo() : nID(-1), bOpenFlag(FALSE), nFileListLength(0)
    {
        szUserName[0] = szPassword[0] = 0;
    }

};


// ===================================
//  Linked list item of open files and their names
// ===================================
class CUT_QUEFileHandle {
public:
    long    m_lHandle;                              // File handle
    _TCHAR    m_szFileName[MAX_PATH + 1];         // File name

    // Default constructor
    CUT_QUEFileHandle() : m_lHandle(0)
    {
        m_szFileName[0] = 0;
    }

    // Constructor
    CUT_QUEFileHandle(long lHandle, LPCTSTR szFileName) : m_lHandle(lHandle)
    {
#pragma warning(disable : 4996)
        _tcsncpy(m_szFileName, szFileName, MAX_PATH);
        m_szFileName[MAX_PATH] = 0;
#pragma warning(default : 4996)
    }

};


// ===================================
//  Data manager class
// ===================================
class CUT_DataManager {

protected:
    CUT_MailServer          *m_ptrMailServer;       // Pointer to the Mail Server class
    QUEUE_FILE_LIST         m_listFileHandle;       // Queue file handles list
    CUT_InitCriticalSection	m_criticalSection;      // Critical section
    
protected:

    // Adds a file handle and name to a linked list
    virtual void    Que_AddFileHandle(long handle,LPCTSTR fileName);

    // Returns a filename from its handle
    virtual LPCTSTR  Que_GetFileName(long handle);

    // Removes the given handle from the file handle linked list
    virtual void    Que_RemoveFileHandle(long handle);

public:

    // Constructor/Destructor
    CUT_DataManager(CUT_MailServer &ptrMailServer);
    virtual ~CUT_DataManager();

    // Opens a file from the QUE
    virtual long    Que_OpenFile();

    // Creates a new file for writing to in the QUE
    virtual long    Que_CreateFile();

    // Closes an open QUE file
    virtual int     Que_CloseFile(long fileHandle,BOOLEAN deleteFlag = FALSE);

    // Reads bytes from the given file
    virtual int     Que_ReadFile(long fileHandle,LPBYTE buf,int bufLen);

    // Reads the header information from the given file.
    // Header information includes, to, from, write time, retry count, 
    // and if the mail is being returned
    virtual int     Que_ReadFileHeader(long fileHandle,LPSTR to,int maxToLen,LPSTR from,
                            int maxFromLen,time_t* tm,DWORD *numRetries,DWORD * returnMail);

    // Writes the given data to an open QUE file
    virtual int     Que_WriteFile(long fileHandle,LPBYTE buf,int bufLen);

    // Writes a file header to a QUE file.
    // Header items include to, form, retry count and if the mail is being returned
    virtual int     Que_WriteFileHeader(long fileHandle,LPCSTR to,LPCSTR from, DWORD numRetries,DWORD returnMail);
    virtual int     Que_WriteFileHeader(long fileHandle,DWORD numRetries,DWORD returnMail);

    // Copies a QUE file to another QUE file but changes the TO: name to the given name
    virtual int     Que_CarbonCopyFile(long origFileHandle,LPCSTR toAddr);

};


// ===================================
//  User manager class
// ===================================
class CUT_UserManager {

protected:
    CUT_MailServer      *m_ptrMailServer;       // Pointer to the Mail Server class
    USER_LIST           m_userList;             // User information list
    CUT_InitCriticalSection m_criticalSection;	// Critical section
    BOOL                bUserInfoChanged;       // TRUE if the user info have been changed

public:

    // Constructor/Destructor
    CUT_UserManager(CUT_MailServer &ptrMailServer);
    virtual ~CUT_UserManager();

    // Loads/Save users settings from the registry
    virtual int     LoadUserInfo(LPCTSTR subKey);
    virtual int     SaveUserInfo(LPCTSTR subKey);

    // Opens/Close the given users account
    virtual long    User_OpenUser(LPCTSTR user,LPCTSTR password);
    virtual long    User_CloseUser(long userHandle);

    // Adds new user to the list
    virtual int     User_Add(LPCTSTR lpszName, LPCTSTR szPassword, CUT_TStringList &MailAddresses);
    virtual int     User_Add(LPCTSTR lpszName, LPCTSTR szPassword, LPCTSTR MailAddress);

    // Delete user from the list
    virtual int     User_Delete(LPCTSTR lpszName);

    // Modify user from the list
    virtual int     User_Modify(LPCTSTR lpszName, LPCTSTR lpszNewName, LPCTSTR lpszNewPassword, CUT_TStringList *listNewAddresses);
    
    // Returns number of users in the list
    virtual int     User_GetCount();

    // Returns number of users in the list
    virtual CUT_UserInfo * User_GetUser(int index);

    // Returns the number of files available in the the users email box
    virtual int     User_GetFileCount(long userHandle);
    
    // Returns the file ID and size of a file in the users email box
    virtual long    User_GetFileSize(long userHandle,int index);
    virtual long    User_GetFileID(long userHandle,int index);
    
    // Opens a file in the users email box
    virtual long    User_OpenFile(long userHandle,int index);

    // Creates a new file for writing in a USER email box
    virtual long    User_CreateUserFile(LPCTSTR emailAddress);

    // Reads/Writes bytes from the open USER file
    virtual int     User_ReadFile(long fileHandle,LPBYTE buf,int bufLen);
    virtual int     User_WriteFile(long fileHandle,LPBYTE buf,int bufLen);

    // Closes an open USER file
    virtual int     User_CloseFile(long fileHandle);

    // Puts the given file into the delete list
    virtual int     User_DeleteFile(long userHandle,int index);

    // Clears all user files from the delete list
    virtual int     User_ResetDelete(long userHandle);

    // Returns a list of available files in a users account
    virtual int     User_GetFileList(CUT_UserInfo *info);

    // Deletes all the files found the the USER delete file list
    virtual int     User_DeleteAllFiles(CUT_UserInfo *info);

    // Gets free user mail directory name
    virtual int     User_GetFreeMailDir(CUT_UserInfo &info);

    // Checks if the file marked for deletion
    virtual BOOL    User_IsFileDeleted(long userHandle, int nFileIndex);
};

#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

The Ultimate Toolbox
Web Developer
Canada Canada
In January 2005, David Cunningham and Chris Maunder created TheUltimateToolbox.com, a new group dedicated to the continued development, support and growth of Dundas Software’s award winning line of MFC, C++ and ActiveX control products.

Ultimate Grid for MFC, Ultimate Toolbox for MFC, and Ultimate TCP/IP have been stalwarts of C++/MFC development for a decade. Thousands of developers have used these products to speed their time to market, improve the quality of their finished products, and enhance the reliability and flexibility of their software.
Group type: Organisation

453 members


You may also be interested in...

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web01-2016 | 2.8.180621.3 | Last Updated 25 Aug 2007
Article Copyright 2007 by The Ultimate Toolbox
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid