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