-
Notifications
You must be signed in to change notification settings - Fork 0
/
Client.h
72 lines (55 loc) · 1.34 KB
/
Client.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef __CLIENT_H__
#define __CLIENT_H__
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <netdb.h>
#include <signal.h>
#include <pthread.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include "Constant.h"
#include "Wrapper.h"
#include "sfwrite.h"
#include "User.h"
int clientfd;
int auditfd;
extern pthread_rwlock_t RW_lock;
extern pthread_mutex_t Q_lock;
char auditFileName[MAX_FILE_LEN] = AUDIT_FILE_NAME;
char name[MAX_NAME_LEN];
char hostname[MAX_HOSTNAME_LEN];
char port[MAX_PORT_LEN];
UserList userList;
int runFlag;
extern int verboseFlag;
int createUserFlag;
typedef struct communicationThreadParam {
int *connfd;
char userName[MAX_NAME_LEN];
} CommunicationThreadParam;
void parseOption(int argc, char **argv);
int openClientFd();
int login();
void executeCommand();
void receiveMessage();
int authenticateUser();
int promptPassword();
void receiveChatMessage(char *line);
void processChatMessage(char *to, char *from, char *msg);
int timeCommand();
int logoutCommand();
int listuCommand();
int chatCommand(char *line);
int auditCommand();
int verifyChatCommand(char *line, char *to, char *msg);
void printUsage();
void sigintHandler(int signum);
void * communicationThread(void *argv);
#endif