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

📄 commonclass.h

📁 FTP服务器
💻 H
字号:
#ifndef COMMONCLASS_H_
#define COMMONCLASS_H_

#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <sys/msg.h>//消息
#include <sys/sem.h>//信号量
#include <sys/stat.h>//管道
#include <sys/shm.h>

#include <arpa/inet.h>
#include <netinet/in.h>

#include <fcntl.h>
#include <pwd.h>
#include <shadow.h>
#include <grp.h>
#include <crypt.h>
#include <glob.h>

#include <dirent.h>//目录
#include <netdb.h>//网络信息
#include <pthread.h>
#include <signal.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <grp.h>
#include <pwd.h>
#include <time.h>

/*----------------------------------------------函数声明区---------------------------------------------*/
/*主函数*/
int Main_Fun();
/*读取配置信息*/
void Read_Conf();
/*去除右空格*/
void RTrim(char *ch);
/*去除左空格*/
void LTrim(char *ch);
/*初始化套接字并设置其地址*/
int Init_Socket(int sin_port, char *address);
/*接受连接*/
int Accept_Connect(int sockfd, struct sockaddr_in *address);
/*发送信息SEND()*/
int Send_Message(int sockfd, char *buf, int len);
/*接受信息RECV()*/
int Recv_Message(int sockfd, char *buf, int len);
/*返回对应的字符串*/
void Ftp_State_Return(char *buf,int state);
/*获取文件目录详细信息*/
int List(char *buf, int len);
/*出错信息*/
int errlog(char *logfile,char *msg);
/*处理登录信息*/
void User_Login();
/*验证用户名和密码*/
int Check_User(char *name, char *password, int *uid, int *gid, char *dir, int state);
/*PORT模式,用户发IP和端口过来,进行相应的转换*/
int Get_Ip_Port(char *buf, char *ip, int *port);
/*FTP 控制*/
int Ftp_Ctrl(int argc, char **argv, int *startfun());
/*FTP 启动*/
int Ftp_Start(char *appname, int *startfun());
/*FTP 重启*/
int Ftp_Restart(char *appname, int *startfun());
/*FTP 停止*/
int Ftp_Stop(char *appname);
/*获取进程PID*/
int Get_Pid(char *appname,char *strpids,int bufflen);
/*转换IP*/
void Ip_Change(char *buf);
/*处理信号函数*/
void Handle_Signal(int sig_num);
/*信号处理的句柄注册*/
int Reg_Signal(void (*Handle_Signal)(int));
/*创建共享内存*/
void Init_Memory();


/*---------------------------------------------命令处理函数--------------------------------------------*/
int Cmd_USER(char *buf, char *send_msg);
int Cmd_PASS(char *passwd, char *send_msg);
int Cmd_SYST(char *buf, char *send_msg);
int Cmd_FEAT(char *buf, char *send_msg);
int Cmd_REST(char *buf, char *send_msg);
int Cmd_PWD(char *buf, char *send_msg);
int Cmd_TYPE(char *buf, char *send_msg);
int Cmd_PASV(char *buf, char *send_msg);
int Cmd_LIST(char *buf, char *send_msg);
int Cmd_QUIT(char *buf, char *send_msg);
int Cmd_MKD(char *buf, char *send_msg);
int Cmd_RMD(char *buf, char *send_msg);
int Cmd_CWD(char *buf, char *send_msg);
int Cmd_CDUP(char *buf, char *send_msg);
int Cmd_RNFR(char *buf, char *send_msg);
int Cmd_RNTO(char *buf, char *send_msg);
int Cmd_RETR(char *buf, char *send_msg);
int Cmd_STOR(char *buf, char *send_msg);
int Cmd_DELE(char *buf, char *send_msg);
int Cmd_APPE(char *buf, char *send_msg);
int Cmd_ABOR(char *buf, char *send_msg);
int Cmd_PORT(char *buf, char *send_msg);
int Cmd_NOOP(char *buf, char *send_msg);
int Cmd_HELP(char *buf, char *send_msg);
int Cmd_SIZE(char *buf, char *send_msg);
int Cmd_STAT(char *buf, char *send_msg);

/*----------------------------------------------全局变量区---------------------------------------------*/
int SOCKFD;//主套接字
int CMD_SOCKFD;//命令套接字
int LISTEN_SOCKFD;//监听套接字
int DATA_SOCKFD;//数据套接字

int UID;//用户ID
int GID;//组ID
long int OFFSET;//文件尾

char USER[20];//用户名
char PASSWORD[20];//密码
char USER_DIR[256];//没个用户登录时的绝对路径
char ABSOLUTE_PATH[100];//绝对路径
char REL_PATH[100];//相对路径
char FILE_NAME[100];//要重命名的文件夹名称

int ENBALE_ANONYMOUS;//允许匿名登录状态
int MAX_UPLOAD_SPEED;//最大上传速度(KB/S)
int MIN_DOWNLOAD_SPEED;//最大下载速度(KB/S)
int TIME_OUT;//连接服务器超时时间(秒)
int ENABLE_USERLIST;//用户列表里面的用户是否有效
int PORT;//端口号
char IP[100];//ip地址
int SHM_ID;//共享内存标识符
char ENABLE_LOGIN_USER[20][20];//保存可登录用户名2维数组


#endif

⌨️ 快捷键说明

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