文件服务器——include文件夹

1.childthread.h

#ifndef __CHILDTHREAD_H__
#define __CHILDTHREAD_H__
#include "head.h"

int transFile(int clientfd);
void *threadFunc(void *p);
#endif

2.head.h

#ifndef __HEAD_H__
#define __HEAD_H__
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <dirent.h>
#include <pwd.h>
#include <grp.h>
#include <time.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/select.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <syslog.h>
#include <sys/sem.h>
#include <sys/msg.h>
#include <signal.h>
#include <pthread.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/epoll.h>
#include <sys/sendfile.h>
#include <crypt.h>
#include <mysql/mysql.h>
#define ARGS_CHECK(args,num)\
{if(args!=num)\
    {fprintf(stderr,"args error!\n");\
        return -1;}}
#define ERROR_CHECK(ret,num,msg)\
{if(ret==num)\
    {perror(msg);\
        return -1;}}
#define PTHREAD_ERROR_CHECK(ret,msg)\
do{\
    if(0!=ret)\
    printf("%s : %s\n",msg,strerror(ret));\
}while(0)

typedef struct{
    int len;
    char buf[1024];
}Train_t;
#endif

3.mainthread.h

#ifndef __MAINTHREAD_H__
#define __MAINTHREAD_H__
#include "head.h"

int tcpInit(char *ip,char *port,int *sockfd);
int epfdAddfd(int fd,int epfd);
#endif

4.queue.h

#ifndef __QUEUE_H__
#define __QUEUE_H__
#include "head.h"

typedef struct Note{
    int clientFd;
    struct Note*next;
}Note_t,*pNote_t;

typedef struct{
    int size;
    pNote_t pHead,pTail;
    pthread_mutex_t mutex;
    pthread_cond_t cond;
}Que_t,*pQue_t;

int queueInit(pQue_t pQueue);
int queueInsert(pQue_t pQueue,pNote_t pNote);
int queueGet(pQue_t pQueue,pNote_t *pGet);

#endif

5.register_login.h

#ifndef __REGISTER_LOGIN_H__
#define __REGISTER_LOGIN_H__
#include "head.h"
#define STR_LEN 10
#define CLIENT_NUM 10

typedef struct{
    int id;
    char nickName[20];
    char salt[14];
    char Passwd[128];
}clientInfo_t,*pclientInfo_t;

typedef struct{
    int sfd;
    int login_Flag;
}Login_Flag_t;

clientInfo_t clientInfo_List[CLIENT_NUM];
Login_Flag_t login_Flag_List[CLIENT_NUM];

int getSalt(char *nameStr,int sfd);
int queryByPasswd(char* nameStr);
int queryByName(char* nameStr);
int mysqlInsert(char *name,char *salt,char* passwd);
int GenerateStr(char *str);
int Register_Login_Screen(int sfd);
#endif

6.threadpool.h

#ifndef __PNOTE_H__
#define __PNOTE_H__
#include "head.h"
#include "queue.h"

typedef struct{
    int threadNum;
    pthread_t *pthid;
    Que_t Queue;
}ThreadPool_t,*pThreadPool_t;

int threadPoolInit(pThreadPool_t pPool,int threadNum);
int threadPoolStart(pThreadPool_t pPool);

#endif

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值