Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
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
Container 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
Main
Synchronet
Commits
eba3ee14
Commit
eba3ee14
authored
20 years ago
by
rswindell
Browse files
Options
Downloads
Patches
Plain Diff
Converted 3 linked-lists of strings to string lists (str_list_t).
String lists are simplier, faster, and require less memory.
parent
21136117
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/sbbs3/websrvr.c
+27
-27
27 additions, 27 deletions
src/sbbs3/websrvr.c
with
27 additions
and
27 deletions
src/sbbs3/websrvr.c
+
27
−
27
View file @
eba3ee14
...
@@ -184,7 +184,7 @@ typedef struct {
...
@@ -184,7 +184,7 @@ typedef struct {
char
vhost
[
128
];
/* The requested host. (virtual host) */
char
vhost
[
128
];
/* The requested host. (virtual host) */
int
send_location
;
int
send_location
;
const
char
*
mime_type
;
const
char
*
mime_type
;
link
_list_t
headers
;
str
_list_t
headers
;
char
status
[
MAX_REQUEST_LINE
+
1
];
char
status
[
MAX_REQUEST_LINE
+
1
];
char
*
post_data
;
char
*
post_data
;
size_t
post_len
;
size_t
post_len
;
...
@@ -195,8 +195,8 @@ typedef struct {
...
@@ -195,8 +195,8 @@ typedef struct {
/* CGI parameters */
/* CGI parameters */
char
query_str
[
MAX_REQUEST_LINE
+
1
];
char
query_str
[
MAX_REQUEST_LINE
+
1
];
char
extra_path_info
[
MAX_REQUEST_LINE
+
1
];
char
extra_path_info
[
MAX_REQUEST_LINE
+
1
];
link
_list_t
cgi_env
;
str
_list_t
cgi_env
;
link
_list_t
dynamic_heads
;
str
_list_t
dynamic_heads
;
/* Dynamically (sever-side JS) generated HTML parameters */
/* Dynamically (sever-side JS) generated HTML parameters */
FILE
*
fp
;
FILE
*
fp
;
...
@@ -533,7 +533,7 @@ static void add_env(http_session_t *session, const char *name,const char *value)
...
@@ -533,7 +533,7 @@ static void add_env(http_session_t *session, const char *name,const char *value)
return
;
return
;
}
}
sprintf
(
p
,
"%s=%s"
,
newname
,
value
);
sprintf
(
p
,
"%s=%s"
,
newname
,
value
);
l
istPush
NodeString
(
&
session
->
req
.
cgi_env
,
p
);
strL
istPush
(
&
session
->
req
.
cgi_env
,
p
);
free
(
p
);
free
(
p
);
}
}
...
@@ -750,9 +750,9 @@ static void close_request(http_session_t * session)
...
@@ -750,9 +750,9 @@ static void close_request(http_session_t * session)
session
->
req
.
ld
=
NULL
;
session
->
req
.
ld
=
NULL
;
}
}
l
istFree
(
&
session
->
req
.
headers
);
strL
istFree
(
&
session
->
req
.
headers
);
l
istFree
(
&
session
->
req
.
dynamic_heads
);
strL
istFree
(
&
session
->
req
.
dynamic_heads
);
l
istFree
(
&
session
->
req
.
cgi_env
);
strL
istFree
(
&
session
->
req
.
cgi_env
);
FREE_AND_NULL
(
session
->
req
.
post_data
);
FREE_AND_NULL
(
session
->
req
.
post_data
);
if
(
!
session
->
req
.
keep_alive
)
{
if
(
!
session
->
req
.
keep_alive
)
{
close_socket
(
session
->
socket
);
close_socket
(
session
->
socket
);
...
@@ -843,12 +843,12 @@ static BOOL send_headers(http_session_t *session, const char *status)
...
@@ -843,12 +843,12 @@ static BOOL send_headers(http_session_t *session, const char *status)
int
ret
;
int
ret
;
BOOL
send_file
=
TRUE
;
BOOL
send_file
=
TRUE
;
time_t
ti
;
time_t
ti
;
size_t
idx
;
const
char
*
status_line
;
const
char
*
status_line
;
struct
stat
stats
;
struct
stat
stats
;
struct
tm
tm
;
struct
tm
tm
;
char
*
headers
;
char
*
headers
;
char
header
[
MAX_REQUEST_LINE
+
1
];
char
header
[
MAX_REQUEST_LINE
+
1
];
list_node_t
*
node
;
if
(
session
->
socket
==
INVALID_SOCKET
)
if
(
session
->
socket
==
INVALID_SOCKET
)
return
(
FALSE
);
return
(
FALSE
);
...
@@ -955,8 +955,8 @@ static BOOL send_headers(http_session_t *session, const char *status)
...
@@ -955,8 +955,8 @@ static BOOL send_headers(http_session_t *session, const char *status)
if
(
session
->
req
.
dynamic
)
{
if
(
session
->
req
.
dynamic
)
{
/* Dynamic headers */
/* Dynamic headers */
/* Set up environment */
/* Set up environment */
for
(
node
=
listFirstNode
(
&
session
->
req
.
dynamic_heads
);
node
!=
NULL
;
node
=
listNextNode
(
node
)
)
for
(
idx
=
0
;
session
->
req
.
dynamic_heads
[
idx
]
!=
NULL
;
idx
++
)
safecat
(
headers
,
listNodeData
(
node
)
,
MAX_HEADERS_SIZE
);
safecat
(
headers
,
session
->
req
.
dynamic_heads
[
idx
]
,
MAX_HEADERS_SIZE
);
}
}
safecat
(
headers
,
""
,
MAX_HEADERS_SIZE
);
safecat
(
headers
,
""
,
MAX_HEADERS_SIZE
);
...
@@ -1523,12 +1523,12 @@ static BOOL parse_headers(http_session_t * session)
...
@@ -1523,12 +1523,12 @@ static BOOL parse_headers(http_session_t * session)
char
*
value
;
char
*
value
;
char
*
p
;
char
*
p
;
int
i
;
int
i
;
size_t
idx
;
size_t
content_len
=
0
;
size_t
content_len
=
0
;
char
env_name
[
128
];
char
env_name
[
128
];
list_node_t
*
node
;
for
(
node
=
listFirstNode
(
&
session
->
req
.
headers
);
node
!=
NULL
;
node
=
listNextNode
(
node
)
)
{
for
(
idx
=
0
;
session
->
req
.
headers
[
idx
]
!=
NULL
;
idx
++
)
{
head_line
=
listNodeData
(
node
)
;
head_line
=
session
->
req
.
headers
[
idx
]
;
if
((
strtok
(
head_line
,
":"
))
!=
NULL
&&
(
value
=
strtok
(
NULL
,
""
))
!=
NULL
)
{
if
((
strtok
(
head_line
,
":"
))
!=
NULL
&&
(
value
=
strtok
(
NULL
,
""
))
!=
NULL
)
{
i
=
get_header_type
(
head_line
);
i
=
get_header_type
(
head_line
);
while
(
*
value
&&
*
value
<=
' '
)
value
++
;
while
(
*
value
&&
*
value
<=
' '
)
value
++
;
...
@@ -1746,7 +1746,7 @@ static BOOL get_request_headers(http_session_t * session)
...
@@ -1746,7 +1746,7 @@ static BOOL get_request_headers(http_session_t * session)
}
}
sockreadline
(
session
,
head_line
+
i
,
sizeof
(
head_line
)
-
i
-
1
);
sockreadline
(
session
,
head_line
+
i
,
sizeof
(
head_line
)
-
i
-
1
);
}
}
l
istPush
NodeString
(
&
session
->
req
.
headers
,
head_line
);
strL
istPush
(
&
session
->
req
.
headers
,
head_line
);
if
((
strtok
(
head_line
,
":"
))
!=
NULL
&&
(
value
=
strtok
(
NULL
,
""
))
!=
NULL
)
{
if
((
strtok
(
head_line
,
":"
))
!=
NULL
&&
(
value
=
strtok
(
NULL
,
""
))
!=
NULL
)
{
i
=
get_header_type
(
head_line
);
i
=
get_header_type
(
head_line
);
...
@@ -2096,8 +2096,8 @@ static BOOL exec_cgi(http_session_t *session)
...
@@ -2096,8 +2096,8 @@ static BOOL exec_cgi(http_session_t *session)
char
cgipath
[
MAX_PATH
+
1
];
char
cgipath
[
MAX_PATH
+
1
];
char
*
p
;
char
*
p
;
char
ch
;
char
ch
;
list_node_t
*
node
;
BOOL
orig_keep
=
FALSE
;
BOOL
orig_keep
=
FALSE
;
size_t
idx
;
SAFECOPY
(
cmdline
,
session
->
req
.
physical_path
);
SAFECOPY
(
cmdline
,
session
->
req
.
physical_path
);
...
@@ -2124,8 +2124,8 @@ static BOOL exec_cgi(http_session_t *session)
...
@@ -2124,8 +2124,8 @@ static BOOL exec_cgi(http_session_t *session)
startup
->
setuid
(
TRUE
);
startup
->
setuid
(
TRUE
);
/* Set up environment */
/* Set up environment */
for
(
node
=
listFirstNode
(
&
session
->
req
.
cgi_env
);
node
!=
NULL
;
node
=
listNextNode
(
node
)
)
for
(
idx
=
0
;
session
->
req
.
cgi_env
[
idx
]
!=
NULL
;
idx
++
)
putenv
(
listNodeData
(
node
)
);
putenv
(
session
->
req
.
cgi_env
[
idx
]
);
/* Set up STDIO */
/* Set up STDIO */
dup2
(
session
->
socket
,
0
);
/* redirect stdin */
dup2
(
session
->
socket
,
0
);
/* redirect stdin */
...
@@ -2232,14 +2232,14 @@ static BOOL exec_cgi(http_session_t *session)
...
@@ -2232,14 +2232,14 @@ static BOOL exec_cgi(http_session_t *session)
break
;
break
;
case
HEAD_LENGTH
:
case
HEAD_LENGTH
:
session
->
req
.
keep_alive
=
orig_keep
;
session
->
req
.
keep_alive
=
orig_keep
;
l
istPush
NodeString
(
&
session
->
req
.
dynamic_heads
,
buf
);
strL
istPush
(
&
session
->
req
.
dynamic_heads
,
buf
);
break
;
break
;
case
HEAD_TYPE
:
case
HEAD_TYPE
:
got_valid_headers
=
TRUE
;
got_valid_headers
=
TRUE
;
l
istPush
NodeString
(
&
session
->
req
.
dynamic_heads
,
buf
);
strL
istPush
(
&
session
->
req
.
dynamic_heads
,
buf
);
break
;
break
;
default:
default:
l
istPush
NodeString
(
&
session
->
req
.
dynamic_heads
,
buf
);
strL
istPush
(
&
session
->
req
.
dynamic_heads
,
buf
);
}
}
}
}
}
}
...
@@ -2475,21 +2475,21 @@ static BOOL exec_cgi(http_session_t *session)
...
@@ -2475,21 +2475,21 @@ static BOOL exec_cgi(http_session_t *session)
break
;
break
;
case
HEAD_LENGTH
:
case
HEAD_LENGTH
:
session
->
req
.
keep_alive
=
orig_keep
;
session
->
req
.
keep_alive
=
orig_keep
;
l
istPush
NodeString
(
&
session
->
req
.
dynamic_heads
,
buf
);
strL
istPush
(
&
session
->
req
.
dynamic_heads
,
buf
);
break
;
break
;
case
HEAD_TYPE
:
case
HEAD_TYPE
:
got_valid_headers
=
TRUE
;
got_valid_headers
=
TRUE
;
SAFECOPY
(
content_type
,
buf
);
SAFECOPY
(
content_type
,
buf
);
break
;
break
;
default:
default:
l
istPush
NodeString
(
&
session
->
req
.
dynamic_heads
,
buf
);
strL
istPush
(
&
session
->
req
.
dynamic_heads
,
buf
);
}
}
continue
;
continue
;
}
}
msglen
=
i
;
/* we may send this text later */
msglen
=
i
;
/* we may send this text later */
done_parsing_headers
=
TRUE
;
/* invalid header */
done_parsing_headers
=
TRUE
;
/* invalid header */
session
->
req
.
dynamic
=
IS_CGI
;
session
->
req
.
dynamic
=
IS_CGI
;
l
istPush
NodeString
(
&
session
->
req
.
dynamic_heads
,
content_type
);
strL
istPush
(
&
session
->
req
.
dynamic_heads
,
content_type
);
send_headers
(
session
,
cgi_status
);
send_headers
(
session
,
cgi_status
);
}
}
if
(
msglen
)
{
if
(
msglen
)
{
...
@@ -2969,7 +2969,7 @@ static BOOL ssjs_send_headers(http_session_t* session)
...
@@ -2969,7 +2969,7 @@ static BOOL ssjs_send_headers(http_session_t* session)
JS_GetProperty
(
session
->
js_cx
,
headers
,
JS_GetStringBytes
(
js_str
),
&
val
);
JS_GetProperty
(
session
->
js_cx
,
headers
,
JS_GetStringBytes
(
js_str
),
&
val
);
safe_snprintf
(
str
,
sizeof
(
str
),
"%s: %s"
safe_snprintf
(
str
,
sizeof
(
str
),
"%s: %s"
,
JS_GetStringBytes
(
js_str
),
JS_GetStringBytes
(
JSVAL_TO_STRING
(
val
)));
,
JS_GetStringBytes
(
js_str
),
JS_GetStringBytes
(
JSVAL_TO_STRING
(
val
)));
l
istPush
NodeString
(
&
session
->
req
.
dynamic_heads
,
str
);
strL
istPush
(
&
session
->
req
.
dynamic_heads
,
str
);
}
}
JS_DestroyIdArray
(
session
->
js_cx
,
heads
);
JS_DestroyIdArray
(
session
->
js_cx
,
heads
);
session
->
req
.
sent_headers
=
TRUE
;
session
->
req
.
sent_headers
=
TRUE
;
...
@@ -3175,9 +3175,9 @@ void http_session_thread(void* arg)
...
@@ -3175,9 +3175,9 @@ void http_session_thread(void* arg)
memset
(
session
.
req
.
ld
,
0
,
sizeof
(
struct
log_data
));
memset
(
session
.
req
.
ld
,
0
,
sizeof
(
struct
log_data
));
session
.
req
.
ld
->
hostname
=
strdup
(
session
.
host_name
);
session
.
req
.
ld
->
hostname
=
strdup
(
session
.
host_name
);
}
}
listInit
(
&
session
.
req
.
headers
,
0
);
session
.
req
.
headers
=
strListInit
(
);
listInit
(
&
session
.
req
.
cgi_env
,
0
);
session
.
req
.
cgi_env
=
strListInit
(
);
listInit
(
&
session
.
req
.
dynamic_heads
,
0
);
session
.
req
.
dynamic_heads
=
strListInit
(
);
if
(
get_req
(
&
session
,
redirp
))
{
if
(
get_req
(
&
session
,
redirp
))
{
/* At this point, if redirp is non-NULL then the headers have already been parsed */
/* At this point, if redirp is non-NULL then the headers have already been parsed */
if
((
session
.
http_ver
<
HTTP_1_0
)
||
redirp
!=
NULL
||
parse_headers
(
&
session
))
{
if
((
session
.
http_ver
<
HTTP_1_0
)
||
redirp
!=
NULL
||
parse_headers
(
&
session
))
{
...
...
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