Skip to content
Snippets Groups Projects
Commit bcd487e1 authored by ChouTatsumi's avatar ChouTatsumi
Browse files

keyword input test

parent 1a04e922
Branches
No related tags found
No related merge requests found
...@@ -269,6 +269,10 @@ static bool handle_http_request(int sockfd) { ...@@ -269,6 +269,10 @@ static bool handle_http_request(int sockfd) {
return show_page(sockfd, GAMEOVER_PAGE); return show_page(sockfd, GAMEOVER_PAGE);
} else if (strstr(buff, "keyword=") != NULL) { } else if (strstr(buff, "keyword=") != NULL) {
char* keyword = strstr(buff, "keyword=") + 8; char* keyword = strstr(buff, "keyword=") + 8;
printf("keyword = %s", keyword);
int keyword_len = strlen(keyword);
keyword[keyword_len - 12] = '\0';
printf("keyword = %s", keyword);
if (p1_is_ready && p2_is_ready) { if (p1_is_ready && p2_is_ready) {
if (keyword_check(sockfd, keyword)) { if (keyword_check(sockfd, keyword)) {
// initial players setting // initial players setting
...@@ -358,8 +362,6 @@ bool show_modified_page(int sockfd, const char* htmldir, char* added, ...@@ -358,8 +362,6 @@ bool show_modified_page(int sockfd, const char* htmldir, char* added,
} }
close(filefd); close(filefd);
print_buff(buff);
// move the trailing part backward // move the trailing part backward
int p1, p2; int p1, p2;
for (p1 = size - 1, p2 = p1 - added_length; p1 >= size - inset_index; for (p1 = size - 1, p2 = p1 - added_length; p1 >= size - inset_index;
...@@ -370,8 +372,6 @@ bool show_modified_page(int sockfd, const char* htmldir, char* added, ...@@ -370,8 +372,6 @@ bool show_modified_page(int sockfd, const char* htmldir, char* added,
// copy the username // copy the username
strncpy(buff + p2, added, added_length); strncpy(buff + p2, added, added_length);
print_buff(buff);
if (write(sockfd, buff, size) < 0) { if (write(sockfd, buff, size) < 0) {
perror("write"); perror("write");
return false; return false;
...@@ -406,10 +406,10 @@ bool show_accepted_page(int sockfd) { ...@@ -406,10 +406,10 @@ bool show_accepted_page(int sockfd) {
char added[2049]; char added[2049];
// avoid pointer reference error
memset(added, 0, sizeof(added)); memset(added, 0, sizeof(added));
strcat(added, added_prefix); strcat(added, added_prefix);
printf("added is now %s", added);
if (sockfd == p1_sockfd) { if (sockfd == p1_sockfd) {
for (int i = 0; i < p1_guess_len - 1; i++) { for (int i = 0; i < p1_guess_len - 1; i++) {
...@@ -426,12 +426,8 @@ bool show_accepted_page(int sockfd) { ...@@ -426,12 +426,8 @@ bool show_accepted_page(int sockfd) {
strcat(added, p2_guess[p2_guess_len - 1]); strcat(added, p2_guess[p2_guess_len - 1]);
} }
printf("added is now %s", added);
strcat(added, added_suffix); strcat(added, added_suffix);
printf("added is now %s", added);
return show_modified_page(sockfd, ACCEPTED_PAGE, added, 264); return show_modified_page(sockfd, ACCEPTED_PAGE, added, 264);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment