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

📄 sftp.h

📁 伯克利做的SFTP安全文件传输协议
💻 H
字号:
// sftp.h// common declarations for SafeTP// copyright SafeTP Development Group, Inc., 2000  Terms of use are as specified in license.txt    #ifndef __SFTP_H#define __SFTP_H#include "lineread.h"     // StreamLineReader#include "socksrc.h"      // SocketInputSource#include "usercfg.h"      // userConfigDir#ifdef _MSC_VER  #pragma warning(disable: 4355) // dob: I'm sick of seeing this warning#endifclass DataBlock;enum {  // this is the port we will listen to for incoming connections; there are  // two relevant points: (1) <49152 is in the "registered" range, meaning long  // term use requires IANA approval.  (2) eventually we want to live at  // port 21, where clients look for ftp, and do so via getservbyname("sftp")  //  conflict: HP DCE uses 2121.. moving to 2123  SFTPD_PORT = 2123,  // this is the port for the real ftpd.  it should be retrieved via  // getservbyname("ftp"), the same way ftpd decides what to listen to  // (then root can change ftp's port to something other than 21)  FTPD_PORT = 21,};// define convenient package for socket line readersclass SocketLineReader  : public SocketInputSource,    public StreamLineReader {public:  SocketLineReader(SOCKET s)    : SocketInputSource(s),      StreamLineReader((SocketInputSource&)*this)        // cast needed because g++ *sucks*  {}    virtual ~SocketLineReader() {}    // shut the *hell* up, g++};// some shared utility functionsvoid parsePasvArgument(char const *text,                       IPAddress &addr, int &port);  // given text of the form of a reply to PASV (without the reply code),  // return in addr and port the encoded address and port; throws x_assert  // if the input is malformedstring constructPortArg(IPAddress addr, int port);  // construct a string of the form "a,a,a,a,p,p" for PORT or PASVbool parsePortArgument(char const *p,                       IPAddress &clientAddress, int &clientPort,                       string &whyFail);  // given text of the form of a PORT request (without the "PORT "),  // return addr and port encoded; returns false and sets 'whyFail' if  // the input is malformedvoid testPortParsing();  // test routine to validate parsePortArgument() (throws x_assert on failure)// as a programming convenience, and also to strengthen belief that no// buffer overrun errors are possible, we will try to do all// variable-length reads via these fnsvoid recvAllBlock(SOCKET s, DataBlock &block, int lenToRead);  // like recvAll(); the block must *already* have enough space allocated  // (and this is checked)int recvAllToEOFBlock(SOCKET s, DataBlock &block, int lenToRead);  // like recvAllToEOF(); block must be big enough; returns # of bytes read#endif // __SFTP_H

⌨️ 快捷键说明

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