⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 warsvrprotocolftpcmd.h

📁 ftpserver very good sample
💻 H
字号:
/**     Virtual Base class for FTP commands*/#ifndef WAR_SVR_PROTOCOL_FTP_CMD_H#define WAR_SVR_PROTOCOL_FTP_CMD_H/* SYSTEM INCLUDES */#ifndef WAR_ASSERT_H_INCLUDED#   include "assert.h"#endif#ifndef WAR_SET_INCLUDED#   define WAR_SET_INCLUDED#   include <set>#endif/* PROJECT INCLUDES */#ifndef WAR_SMART_POINTER_H#   include "WarSmartPointer.h"#endif#ifndef WAR_PTR_WRAPPER#   include "WarPtrWrapper.h"#endif#ifndef WAR_SVR_PROTOCOL_FTP_ENUMS_H#   include "WarSvrProtocolFtpEnums.h"#endif#ifndef WAR_SVR_ENUMS_H#   include "WarSvrEnums.h"#endif#ifndef WAR_FILE_ENUMS_H#   include "WarFileEnums.h"#endif/* LOCAL INCLUDES *//* FORWARD REFERENCES */class WarSvrProtocolFtp;class WarSvrProtocolFtpReply;#ifdef __cplusplusextern "C" {#endif/****************** BEGIN OLD STYLE C spesific ********//****************** END OLD STYLE C spesific **********/#ifdef __cplusplus }#endif/****************** BEGIN C++ spesific ****************/#ifdef __cplusplusclass WarSvrProtocolFtpCmd :     public WarSmartPointer,    public WarSvrEnums,    public WarFileEnums,    public WarSvrProtocolFtpEnums{public:    enum LastCommandresultE    {        CMD_VOID, // Unavaiable        CMD_SUCCESS,        CMD_FAIL    };    // LIFECYCLE       WarSvrProtocolFtpCmd(war_ccstr_t commandName,         war_ccstr_t commandExplanation, /* Human help*/        war_ccstr_t commandSyntax, /* Formal */        war_ccstr_t commandReference, /* RFC */        WarSvrProtocolFtp& serverCompanion);    // Constructor for lookups    WarSvrProtocolFtpCmd(war_ccstr_t commandName);    // OPERATORS    bool operator < (const WarSvrProtocolFtpCmd& from) const    {        return mName < from.mName;    }        bool operator == (const WarSvrProtocolFtpCmd& from) const    {        return mName == from.mName;    }    // OPERATIONS                           /** Entry point for a FTP command. The commandBuffer      * is 'raw', that is - it must be parsed down      * by the copmmand.      *      * On errors, the command is responsible for       * informing the client before an exception      * is thrown.      */    void OnCommand(war_ccstr_t commandBuffer,         size_t bufferLength,        size_t commandLenght)        throw(WarException);    // ACCESS    WarSvrProtocolFtp& GetServer()    {        assert(mpCompanion != NULL);        return *mpCompanion;    }    war_ccstr_t GetArgument() const    {        return mpCommandArgument;    }    // INQUIRY    virtual const std::string GetName() const    {        return mName;    }    virtual const std::string GetExplanation() const    {        return mExplanation;    }    virtual const std::string GetSyntax() const    {        return mSyntax;    }    virtual const std::string GetReference() const    {        return mReference;    }    /** Return true if the user can be logged in to      * run the command */    virtual bool CanBeLoggedIn() const    {        return true;    }    /** Returns true if this command can be used      * while a transfer is active. This is      * normally not allowed, but a few commands      * like ABOR, STAT, SYST, HELP must be      * available       */    virtual bool CanBeInTransfer() const    {        return false;    }    /** Return false if the user must be logged in to      * run the command */    virtual bool CanBePrelogin() const    {        return false;    }    virtual bool IsArgumentRequiered() const    {        return false;    }    virtual bool IsArgumentAllowed() const    {        return true;    }    virtual bool IsImplemented() const    {        return true;    }    virtual LastCommandresultE GetLastResult() const    {        return mLastCommandResult;    }    virtual bool HaveArgument() const    {        return mpCommandArgument && *mpCommandArgument;    }#if WAR_RFC2389    // Returns a single-line string as part of a FEAT    // response, as defined in RFC 2389    virtual std::string GetFeatureString() const    {        return "";    }    virtual void OnOpts(war_ccstr_t commandName,        war_ccstr_t commandArgument,         LastCommandresultE& outResult,        FtpSvrMsgsE& outReplyMsg,        WarFTPDReplyCodesE outReplyCode)    {        WarThrow(WarError(WAR_ERR_NOT_IMPLEMENTED), NULL);    }#endif // WAR_RFC2389protected:    WarSvrProtocolFtpReply *mpReply; // Output stream to the client    WarError mStatus; // Error-status of the current command    ~WarSvrProtocolFtpCmd();    // Validate the command string and add it to mCommandString    virtual void PreProcessCommand(        war_ccstr_t commandBuffer,         size_t bufferLength,        size_t commandLenght);    // This is where the action takes place!    virtual LastCommandresultE ExecuteCommand()     {        WarThrow(WarError(WAR_ERR_NOT_IMPLEMENTED), NULL);    }    virtual void HandleError(const WarError& error);    // Executed after the ExecuteCommand has finished    virtual void PostProcessCommand() {}    // Reset    virtual void OnResetTimer();    private:    const std::string mName;    const std::string mExplanation;    const std::string mSyntax;    const std::string mReference;    std::string mCommandString;    war_ccstr_t mpCommandArgument;    WarSvrProtocolFtp *mpCompanion;    LastCommandresultE mLastCommandResult;};/* INLINE METHODS *//* EXTERNAL REFERENCES */typedef WarPtrWrapper<WarSvrProtocolFtpCmd> war_ftpcmd_ptr_t;typedef std::set<war_ftpcmd_ptr_t> war_ftpcmd_set_t;#endif /* __cplusplus *//****************** END C++ spesific ******************/#endif  /* WAR_SVR_PROTOCOL_FTP_MACROS_H_ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -