📄 ctrlsocket.h
字号:
/****************************************************
* 控制通道类
* 作者 gotter@163.com 2006-04-19
****************************************************/
#ifndef _CTRL_SOCKET_H_
#define _CTRL_SOCKET_H_
#include "Public.h"
#include "DataSocket.h"
#include "FtpUser.h"
class CCtrlSocket:public CMySocket
{
public:
enum RPS_NO
{
WELCOME, CONN_OK, ASC_OK, BIN_OK,
PORT_OK, CMD_OK, TRAN_OK, ABOR_OK,
LOGIN_OK, FILE_OK, DIR_OK, USER_OK,
RNFR_OK, RNTO_OK, CONN_ERR, INTER_ERR,
ARG_ERR, CMD_ERR, IMPL_ERR, SEQ_ERR,
LOGIN_ERR, RIGHT_ERR, FILE_ERR, DIR_ERR,
SYST_OK, QUIT_OK
};
public:
CCtrlSocket();
virtual ~CCtrlSocket();
int Start();
//线程互斥地向响应队列里面追加数据
void Response(RPS_NO iRpsNo);
//线程互斥地向响应队列里面追加数据
void Response(const char *pszFormat,...);
int m_iTimeout;
protected:
//定义成员指针类型
typedef int (CCtrlSocket::*FN_DO)(const char *);
//解析出来的命令信息
struct CMD_INFO
{//
char *pszCmd;
FN_DO pfnDo;
char *pszInfo;
};
struct RPS_INFO
{//固定响应串
RPS_NO iRpsNo;
char *pszInfo;
};
//命令信息数组,每个命令的处理成员函数指针、
//帮助信息都从这里提取
static CMD_INFO m_arrCmd[];
//控制通道主线程和数据通道子线程之间的互斥量
pthread_mutex_t m_mutex;
//发送和接收缓冲区,其中发送缓冲区是多线程共享资源
//每个线程使用时需要通过函数AppendResponse和CommitResponse访问
string m_sRecv,m_sSend;
//数据通道套接字
CDataSocket m_sockData;
//用户管理对象,所有与文件访问、权限检查的操作都包含在
//此对象里面
CFtpUser m_user;
protected:
/*
从接收缓冲区中提取一个命令信息,如果成功,
返回命令信息索引号
pszArg[out] --命令参数
iArgSize --pszArg缓冲区大小
*/
int GetCmd(char *pszArg,int iArgSize);
/*
根据命令匹配,返回命令信息数组索引号
*/
int FindCmdInfo(const char *pszCmd);
/*
根据命令信息索引号,处理该命令
iCmdIndex --命令数组索引
pszArg --该命令的参数字符串
*/
int ReplyCmd(int iCmdIndex,const char *pszArg);
/*
向响应队列里面追加新数据
*/
void AppendResponse(const char *pszResponse);
/*
将响应队列里面的数据发回给客户端
*/
int CommitResponse();
//各个命令的处理程序
int DoUser(const char *pszArg);
int DoPass(const char *pszArg);
int DoSyst(const char *pszArg);
int DoPwd(const char *pszArg);
int DoCwd(const char *pszArg);
int DoType(const char *pszArg);
int DoCdup(const char *pszArg);
int DoNoop(const char *pszArg);
int DoRetr(const char *pszArg);
int DoStor(const char *pszArg);
int DoList(const char *pszArg);
int DoPasv(const char *pszArg);
int DoPort(const char *pszArg);
int DoMkd(const char *pszArg);
int DoRmd(const char *pszArg);
int DoQuit(const char *pszArg);
int DoAbor(const char *pszArg);
int DoDele(const char *pszArg);
int DoSize(const char *pszArg);
int DoRefr(const char *pszArg);
int DoReto(const char *pszArg);
int DoHelp(const char *pszArg);
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -