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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Xun Zhang
comp30023-2019-project-1
Commits
f9b5d043
Commit
f9b5d043
authored
6 years ago
by
ChouTatsumi
Browse files
Options
Downloads
Patches
Plain Diff
test 20:36
parent
942cb5c2
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
+7
-8
7 additions, 8 deletions
server.c
with
7 additions
and
8 deletions
server.c
+
7
−
8
View file @
f9b5d043
...
@@ -64,7 +64,7 @@ bool show_modified_page(int sockfd, const char* htmldir, char* added,
...
@@ -64,7 +64,7 @@ bool show_modified_page(int sockfd, const char* htmldir, char* added,
int
inset_index
);
int
inset_index
);
bool
show_start_page
(
int
sockfd
,
char
*
username
);
bool
show_start_page
(
int
sockfd
,
char
*
username
);
bool
show_accepted_page
(
int
sockfd
);
bool
show_accepted_page
(
int
sockfd
);
void
print_
html_request
(
char
*
request
,
int
sockfd
);
void
print_
buff
(
char
*
request
);
bool
keyword_check
(
int
sockfd
,
char
*
keyword
);
bool
keyword_check
(
int
sockfd
,
char
*
keyword
);
void
player_init
();
void
player_init
();
...
@@ -367,6 +367,8 @@ bool show_modified_page(int sockfd, const char* htmldir, char* added,
...
@@ -367,6 +367,8 @@ 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
;
...
@@ -376,7 +378,9 @@ bool show_modified_page(int sockfd, const char* htmldir, char* added,
...
@@ -376,7 +378,9 @@ bool show_modified_page(int sockfd, const char* htmldir, char* added,
}
}
bool
show_start_page
(
int
sockfd
,
char
*
username
)
{
bool
show_start_page
(
int
sockfd
,
char
*
username
)
{
printf
(
"user=%s
\r\n
"
,
username
);
int
username_length
=
strlen
(
username
);
int
username_length
=
strlen
(
username
);
printf
(
"user_len = %d
\r\n
"
,
username_length
);
char
*
added_prefix
=
"<p>"
;
char
*
added_prefix
=
"<p>"
;
int
added_prefix_length
=
strlen
(
added_prefix
);
int
added_prefix_length
=
strlen
(
added_prefix
);
char
*
added_suffix
=
"</p>
\n\n
"
;
char
*
added_suffix
=
"</p>
\n\n
"
;
...
@@ -384,7 +388,7 @@ bool show_start_page(int sockfd, char* username) {
...
@@ -384,7 +388,7 @@ bool show_start_page(int sockfd, char* username) {
// the length needs to include the html tags for the username
// the length needs to include the html tags for the username
long
added_length
=
username_length
+
9
;
long
added_length
=
username_length
+
9
;
char
added
[
added_length
];
char
added
[
added_length
+
2
];
// create added string
// create added string
strncpy
(
added
,
added_prefix
,
added_prefix_length
);
strncpy
(
added
,
added_prefix
,
added_prefix_length
);
...
@@ -402,15 +406,10 @@ bool show_accepted_page(int sockfd) {
...
@@ -402,15 +406,10 @@ bool show_accepted_page(int sockfd) {
return
true
;
return
true
;
}
}
void
print_html_request
(
char
*
request
,
int
sockfd
)
{
void
print_buff
(
char
*
request
)
{
if
(
sockfd
==
p1_sockfd
)
printf
(
"NEW request from %s
\r\n
"
,
"p1"
);
else
if
(
sockfd
==
p2_sockfd
)
printf
(
"NEW request from %s
\r\n
"
,
"p2"
);
for
(
int
i
=
0
;
i
<
strlen
(
request
);
i
++
)
{
for
(
int
i
=
0
;
i
<
strlen
(
request
);
i
++
)
{
printf
(
"%c"
,
request
[
i
]);
printf
(
"%c"
,
request
[
i
]);
}
}
printf
(
"END of request
\r\n
"
);
}
}
bool
keyword_check
(
int
sockfd
,
char
*
keyword
)
{
bool
keyword_check
(
int
sockfd
,
char
*
keyword
)
{
...
...
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