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

📄 request.h

📁 伯克利做的SFTP安全文件传输协议
💻 H
字号:
// request.h// Request, which holds ftp requests// copyright SafeTP Development Group, Inc., 2000  Terms of use are as specified in license.txt#ifndef __REQUEST_H#define __REQUEST_H    #include "str.h"          // string#ifdef SAFETPC#include "sockutil.h"#else#include "socketd.h"      // SOCKET    class StreamLineReader;   // lineread.h#endif    // all known valid FTP requestsenum RequestCommand {  CMD_UNKNOWN,      // 959 commands  CMD_USER,  CMD_PASS,  CMD_ACCT,  CMD_CWD,  CMD_CDUP,  CMD_SMNT,  CMD_QUIT,  CMD_REIN,  CMD_PORT,  CMD_PASV,  CMD_TYPE,  CMD_STRU,  CMD_MODE,  CMD_RETR,  CMD_STOR,  CMD_STOU,  CMD_APPE,  CMD_ALLO,  CMD_REST,  CMD_RNFR,  CMD_RNTO,  CMD_ABOR,  CMD_DELE,  CMD_RMD,  CMD_MKD,  CMD_PWD,  CMD_LIST,  CMD_NLST,  CMD_SITE,  CMD_SYST,  CMD_STAT,  CMD_HELP,  CMD_NOOP,      // 2228 commands  CMD_AUTH,  CMD_ADAT,  CMD_PROT,  CMD_PBSZ,  CMD_CCC,  CMD_MIC,  CMD_CONF,  CMD_ENC,  // old commands  CMD_XCUP,  CMD_XCWD,  CMD_XMKD,  CMD_XPWD,  CMD_XRMD,  CMD_SIZE,   // can't find the RFC for this one...  // nonstandard, but commonly implemented  CMD_MDTM,  // new commands defined by Dan and me  CMD_DIGT,  // # of defined commands  NUM_COMMAND_REQUESTS,};        // utilitiesRequestCommand textToRequestCommand(char const *command);  // map the textual command to one of the RequestCommands, or to  // CMD_UNKNOWN if it doesn't match any of themchar const *requestCommandToText(RequestCommand c);  // map the easy direction; returned strings are in all capsbool validRequestCommand(RequestCommand cmd);  // true if CMD_UNKNOWN <= cmd < NUM_COMMAND_REQUESTS// represents a single requestclass Request {  string text;        // request text (whole thing, no CRLF)  string command;     // the command string (e.g., "USER");  char const *data;   // pointer into text, where data begins (after command)  RequestCommand c;   // integer code representing the commandprivate:  void parse();    // extract command and data from 'text'  void composeText(char const *dat);    // set 'text' and 'data' from 'dat' and 'command'public:  Request(Request const &obj);  // composing ctors  Request(char const *cmd, char const *data);    // compose as textual command and data, which should already be    // properly ws-stripped  Request(RequestCommand cmd, char const *data);    // compose as separate cmd, data    // data can be NULL, meaning no arguments  Request(char const *src);    // parse a given request line, which does NOT contain a trailing CRLF pair  // parsing ctors  Request(SOCKET s);    // collect next request#ifndef SAFETPC  Request(StreamLineReader &reader);    // parse general stream#endif  void send(SOCKET s) const;    // send request to named socket  string const &getText() const    { return text; }    // null terminated, contains text as user sent it (command + data),    // but *no* CRLF  string getTextNoPassword() const;    // return same string as 'getText()', but if this happens to be a    // PASS request, then remove the password itself  char const *getCommand() const    { return command; }    // null terminated, is just the command string, stripped of ws      RequestCommand getCmd() const    { return c; }    // the easy-to-compare command code      bool isCommand(char const *cmd) const;    // see if this request has command 'cmd' (uses case-insensitive comparison,    // as per RFC 959)      bool isCmd(RequestCommand cmd) const    { return c == cmd; }    // fast integer comparison      char const *getData() const    { return data; }    // null terminated, just the data, with no leading ws (can be "",    // but never NULL)};        #endif // __REQUEST_H

⌨️ 快捷键说明

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