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
bcd487e1
Commit
bcd487e1
authored
Apr 29, 2019
by
ChouTatsumi
Browse files
Options
Downloads
Patches
Plain Diff
keyword input test
parent
1a04e922
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
+5
-9
5 additions, 9 deletions
server.c
with
5 additions
and
9 deletions
server.c
+
5
−
9
View file @
bcd487e1
...
@@ -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
);
}
}
...
...
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