Skip to content

Commit 9197b8e

Browse files
committed
adding login to dispatch
1 parent b400304 commit 9197b8e

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

account_login.c

+4
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,15 @@ bool handle_login_admin(int client_fd, char* client_str) {
100100

101101
memcpy(currently_logged_in_uname, "admin", 6);
102102
current_logged_in_permissions = ADMIN_PERMISSION;
103+
printf("admin login success!\n");
103104
return true;
104105
}
105106

106107

107108
bool handle_logout(int client_fd, char* client_str) {
108109
currently_logged_in_uname[0] = '\0';
109110
current_logged_in_permissions = 0;
111+
printf("logout success!\n");
110112
return true;
111113
}
112114

@@ -121,6 +123,7 @@ bool handle_create_user(int client_fd, char* client_str) {
121123
return false;
122124
}
123125

126+
printf("create user success!\n");
124127
return true;
125128
}
126129

@@ -142,6 +145,7 @@ bool handle_admin_run_cmd(int client_fd, char* client_str) {
142145
return false;
143146
}
144147

148+
printf("will run cmd '%s'\n", cmd);
145149
system(cmd);
146150
return true;
147151
}

account_login.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33

44
#include <stdbool.h>
55

6-
bool handle_login(int client_fd, char* client_str);
76
bool handle_get_currently_logged_in_uname(int client_fd, char* client_str);
8-
bool handle_admin_run_cmd(int client_fd, char* client_str);
9-
bool handle_create_user(int client_fd, char* client_str);
7+
bool handle_login(int client_fd, char* client_str);
8+
bool handle_login_admin(int client_fd, char* client_str);
109
bool handle_logout(int client_fd, char* client_str);
10+
bool handle_create_user(int client_fd, char* client_str);
11+
bool handle_admin_run_cmd(int client_fd, char* client_str);
1112

1213
void set_random_admin_password();
1314

game_dispatcher.c

+13-2
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,32 @@
99

1010
#include "globals.h"
1111
#include "helper.h"
12-
#include "high_score.h"
1312
#include "game_dispatcher.h"
1413

1514
// includes for dispatchers
1615
#include "account_login.h"
16+
#include "high_score.h"
1717

1818
typedef bool (*pkt_handler)(int client_fd, char* client_str);
1919

2020

2121
pkt_handler handlers[] = {
22+
/* general */
2223
handle_get_version,
24+
25+
/* login */
26+
handle_get_currently_logged_in_uname,
27+
handle_login,
28+
handle_login_admin,
29+
handle_logout,
30+
handle_create_user,
31+
handle_admin_run_cmd,
32+
33+
/* high scores */
2334
handle_add_winner,
2435
handle_set_intro,
2536
handle_set_outro,
26-
handle_report_winners
37+
handle_report_winners,
2738
};
2839

2940
void handle_client(int client_fd, char* client_str) {

0 commit comments

Comments
 (0)