Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
comp30023-2019-project-1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Xun Zhang
comp30023-2019-project-1
Commits
8dfb2060
Commit
8dfb2060
authored
Apr 29, 2019
by
ChouTatsumi
Browse files
Options
Downloads
Patches
Plain Diff
accepted page test
parent
8b54abdb
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
server.c
+22
-10
22 additions, 10 deletions
server.c
with
22 additions
and
10 deletions
server.c
+
22
−
10
View file @
8dfb2060
...
...
@@ -64,7 +64,7 @@ bool show_modified_page(int sockfd, const char* htmldir, char* added,
int
inset_index
);
bool
show_start_page
(
int
sockfd
,
char
*
username
);
bool
show_accepted_page
(
int
sockfd
);
void
print_buff
(
char
*
request
);
void
print_buff
(
char
*
request
);
// test method
bool
keyword_check
(
int
sockfd
,
char
*
keyword
);
void
player_init
();
...
...
@@ -276,7 +276,7 @@ static bool handle_http_request(int sockfd) {
is_end_game
=
true
;
return
show_page
(
sockfd
,
ENDGAME_PAGE
);
}
else
return
show_page
(
sockfd
,
ACCEPTED_PAGE
);
return
show_
accepted_
page
(
sockfd
);
}
else
if
(
is_end_game
)
{
is_end_game
=
false
;
return
show_page
(
sockfd
,
ENDGAME_PAGE
);
...
...
@@ -394,20 +394,32 @@ bool show_start_page(int sockfd, char* username) {
}
bool
show_accepted_page
(
int
sockfd
)
{
int
list_len
=
0
;
if
(
sockfd
==
p1_sockfd
)
list_len
=
p1_guess_len
;
else
if
(
sockfd
==
p2_sockfd
)
list_len
=
p2_guess_len
;
char
*
added_prefix
=
"<p>"
;
char
*
added_suffix
=
"</p>
\n\n
"
;
char
*
split
=
", "
;
char
added
[
2049
];
for
(
int
i
=
0
;
i
<
list_len
;
i
++
)
{
strcat
(
added
,
added_prefix
);
if
(
sockfd
==
p1_sockfd
)
{
for
(
int
i
=
0
;
i
<
p1_guess_len
-
1
;
i
++
)
{
strcat
(
added
,
p1_guess
[
i
]);
strcat
(
added
,
split
);
}
strcat
(
added
,
p1_guess
[
i
]);
}
else
if
(
sockfd
==
p2_sockfd
)
{
for
(
int
i
=
0
;
i
<
p2_guess_len
-
1
;
i
++
)
{
strcat
(
added
,
p2_guess
[
i
]);
strcat
(
added
,
split
);
}
strcat
(
added
,
p2_guess
[
i
]);
}
// return show_modified_page(sockfd, ACCEPTED_PAGE, added, 212);
return
true
;
strcat
(
added
,
added_suffix
);
return
show_modified_page
(
sockfd
,
ACCEPTED_PAGE
,
added
,
212
);
}
void
print_buff
(
char
*
request
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment