-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame.h
58 lines (52 loc) · 1.42 KB
/
game.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
#ifndef GAME_HEAD
#define GAME_HEAD
#include <sys/socket.h>
#include <arpa/inet.h>
#include <pthread.h>
#include <time.h>
#include <stdlib.h> /* General Utilities */
#include <string.h> /* String handling */
#include <stdio.h> /* Input/Output */
#include <unistd.h> /* Symbolic Constants */
typedef struct game_request {
int connfd;
struct sockaddr_in cli_addr;
socklen_t cli_len;
struct game_request *next;
}request;
typedef struct game_session{
char *user;
char *password;
}session_info;
typedef struct leaderboard_entry{
char *user;
float won;
float played;
}lb;
extern int sockfd;
extern int user_count;
extern int comb_count;
extern pthread_mutex_t request_mutex;
extern char **user_names;
extern char **passwords;
extern char **combinations;
extern lb *leaderboard;
void* play_game(void *);
int authenticate(int *, session_info *);
int options(int*);
char* read_segment(int *);
int send_segment(int *connfd, char *msg, int msg_len);
int start_playing(int *, session_info *);
int show_leaderboard(int *);
int quit(int *);
long random_at_most(long);
int game_ui(int *, char *, int *, char *, int);
int min(int, int);
char* form_got_right(char *);
void match_guess_pair(char *, char *, char *);
int game_over(int *, int, session_info *);
void update_session_info(session_info *, char *, char *);
int update_leaderboard(session_info *, int);
int sort_leaderboard();
int swap_lb(int, int);
#endif