Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cFTPAccount.h
Go to the documentation of this file.
1 //
4 //
5 #ifndef _INC_cFTPAccount_H
6 #define _INC_cFTPAccount_H
7 #ifndef NO_PRAGMA_ONCE
8 #pragma once
9 #endif
10 
11 #include "GrayFTPInt.h"
12 
13 namespace GrayFTP
14 {
16  class cFTPCfg;
17  class cClientFTP;
18 
19 #ifdef USE_MAX_LIMITS
20  struct cFTPGroupStats
21  {
26 
27  DWORD m_dwObjects;
28  DWORD m_dwLevels;
29  DWORD m_dwSize;
30  };
31 #endif
32 
34  {
38  FTP_PRIV_LIST = 0x0001,
39  FTP_PRIV_READ = 0x0002,
40  FTP_PRIV_WRITE = 0x0004,
41  FTP_PRIV_CREATE = 0x0008,
42  FTP_PRIV_DELETE = 0x0010,
43  FTP_PRIV_MKDIR = 0x0020,
44  FTP_PRIV_RMDIR = 0x0040,
45  //FTP_PRIV_RECURSE =0x0001, //!< rights apply to all directories below this.
46  //FTP_PRIV_EXEC =0x0100, //!< Execute the file ?
47  };
48  typedef WORD FTP_PRIV_MASK;
49 
50  class cFTPAccount : public cRefBase // , public IAuthUser
51  {
55 
56  private:
57  cFTPCfg* m_pCfg; // FTP server config.
58 
59  cStringA m_sAccountName;
60 
62  cStringA m_sPass;
63 
65  cStringA m_sGroup;
66 
67  // GREET=override the default greeting for a specific account
68 
69  public:
70 
71 #ifdef USE_ACCOUNT_STATS
72  // Record stats for account usage.
73  // LASTLOGIP
74  // LASTLOGTIME
75  // FIRSTLOGIP
76  // FIRSTLOGTIME
77  // PREVLOGIP
78  // PREVLOGTIME - previous day.
79 #endif
80 
81 #ifdef USE_ACCOUNT_QUOTA
82  // Daily transfer quotas
83  DWORD m_dwMaxUploadRate;
84  DWORD m_dwMaxDownloadRate;
85 
86  // MAXDAYSIZERX
87  DWORD m_dwMaxDaySizeRx;
88  // MAXDAYSIZETX
89  DWORD m_dwMaxDaySizeTx;
90  // DAYCUR
91  DWORD m_dwDayCur;
92  // DAYSIZERX
93  DWORD m_dwDaySizeRx;
94  // DAYSIZETX
95  DWORD m_dwDaySizeTx;
96 #endif
97 
98  public:
99  cFTPAccount(const char* pszAccount, const char* pszPass, const char* pszGroup);
100  virtual ~cFTPAccount();
101 
102  static StrLen_t GRAYCALL MakeRegName(FILECHAR_t* pszRegPath, const char* pszBase, const char *pszBranch);
103  StrLen_t MakeGroupRegName(FILECHAR_t* pszRegPath, const char* pszGroupName) const;
104 
105  StrLen_t GetSubGroups(const char* pszGroup, char* pszGroups, StrLen_t iLenMax) const;
106  bool IsSubGroup(const char* pszGroup, const char* pszSubGroup) const;
107  const char* SeparateGroupPath(char* pszGroup, const char* pszUserPath) const;
108 
110  {
111  return(m_sAccountName);
112  }
113 
114  bool isAnon() const
115  {
116  return !m_sAccountName.CompareNoCase("Anonymous");
117  }
118 
119  bool CheckPass(const char* pszPass);
120  StrLen_t LoginGreet(cClientFTP* pClient, char* pszGreet, StrLen_t iSizeMax);
121 
122  HTTPRET_TYPE CheckRights(const char* pszUserPath, FILECHAR_t* pszSysPath, StrLen_t nLenSysMax, cClientFTP* pClient, FTP_PRIV_MASK& wRights) const;
123  StrLen_t ListGroups(const char* pszUserPath, char* pBuffer, StrLen_t iSizeMax, bool bVerbose, TZ_TYPE nTZDisp);
124  };
125 
127 }
128 #endif
#define GRAYCALL
declare calling convention for static functions so everyone knows the arg passing scheme....
Definition: GrayCore.h:36
Definition: cClientFTP.h:86
Definition: cFTPAccount.h:51
bool IsSubGroup(const char *pszGroup, const char *pszSubGroup) const
Definition: cFTPAccount.cpp:191
cFTPAccount(const char *pszAccount, const char *pszPass, const char *pszGroup)
Definition: cFTPAccount.cpp:15
virtual ~cFTPAccount()
Definition: cFTPAccount.cpp:23
cStringA get_Name() const
Definition: cFTPAccount.h:109
bool isAnon() const
Definition: cFTPAccount.h:114
const char * SeparateGroupPath(char *pszGroup, const char *pszUserPath) const
Definition: cFTPAccount.cpp:211
bool CheckPass(const char *pszPass)
Definition: cFTPAccount.cpp:27
HTTPRET_TYPE CheckRights(const char *pszUserPath, FILECHAR_t *pszSysPath, StrLen_t nLenSysMax, cClientFTP *pClient, FTP_PRIV_MASK &wRights) const
Definition: cFTPAccount.cpp:283
StrLen_t MakeGroupRegName(FILECHAR_t *pszRegPath, const char *pszGroupName) const
Definition: cFTPAccount.cpp:49
static StrLen_t GRAYCALL MakeRegName(FILECHAR_t *pszRegPath, const char *pszBase, const char *pszBranch)
Definition: cFTPAccount.cpp:36
StrLen_t ListGroups(const char *pszUserPath, char *pBuffer, StrLen_t iSizeMax, bool bVerbose, TZ_TYPE nTZDisp)
Definition: cFTPAccount.cpp:250
StrLen_t LoginGreet(cClientFTP *pClient, char *pszGreet, StrLen_t iSizeMax)
Definition: cFTPAccount.cpp:57
StrLen_t GetSubGroups(const char *pszGroup, char *pszGroups, StrLen_t iLenMax) const
Definition: cFTPAccount.cpp:117
Definition: cFTPCfg.h:117
COMPARE_t CompareNoCase(const _TYPE_CH *pszStr) const
Definition: cString.h:269
Definition: cRefPtr.h:22
Definition: cFTPAccount.h:14
WORD FTP_PRIV_MASK
Definition: cFTPAccount.h:48
FTP_PRIV_TYPE_
Definition: cFTPAccount.h:34
@ FTP_PRIV_MKDIR
Definition: cFTPAccount.h:43
@ FTP_PRIV_RMDIR
Definition: cFTPAccount.h:44
@ FTP_PRIV_WRITE
Overwrite existing files.
Definition: cFTPAccount.h:40
@ FTP_PRIV_LIST
List files and directories.
Definition: cFTPAccount.h:38
@ FTP_PRIV_DELETE
Delete existing files.
Definition: cFTPAccount.h:42
@ FTP_PRIV_CREATE
Create new files.
Definition: cFTPAccount.h:41
@ FTP_PRIV_NONE
Definition: cFTPAccount.h:37
@ FTP_PRIV_READ
Read files.
Definition: cFTPAccount.h:39
const StrLen_t k_MAX_GROUP_NAME
Definition: cFTPAccount.h:15
cRefPtr< cFTPAccount > cFTPAccountPtr
Definition: cFTPAccount.h:126
HTTPRET_TYPE
Definition: cHttpCommon.h:24
TZ_TYPE
Definition: cTimeUnits.h:29
int StrLen_t
the length of a string in chars (bytes for UTF8, wchar_t for UNICODE). or offset in characters....
Definition: StrConst.h:32
char FILECHAR_t
a UTF8 char in a file name. like TCHAR
Definition: FileName.h:22