Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
mongoose
Commits
199e0a33
Commit
199e0a33
authored
Sep 30, 2013
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved options handling to src/options.c
parent
a8da1b33
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
86 additions
and
82 deletions
+86
-82
Makefile
build/Makefile
+2
-1
mongoose.c
build/src/mongoose.c
+0
-55
options.c
build/src/options.c
+57
-0
mongoose.c
mongoose.c
+27
-26
No files found.
build/Makefile
View file @
199e0a33
...
...
@@ -26,7 +26,8 @@ VERSION = $(shell perl -lne \
'print $$1 if /define\s+MONGOOSE_VERSION\s+"(\S+
)
"/'
../mongoose.c
)
# The order in which files are listed is important
SOURCES
=
src/internal.h src/string.c src/parse_date.c src/mongoose.c
SOURCES
=
src/internal.h src/string.c src/parse_date.c src/options.c
\
src/mongoose.c
TINY_SOURCES
=
../mongoose.c main.c
LUA_SOURCES
=
$(TINY_SOURCES)
sqlite3.c lsqlite3.c lua_5.2.1.c
...
...
build/src/mongoose.c
View file @
199e0a33
#include "internal.h"
static
const
char
*
config_options
[]
=
{
"cgi_pattern"
,
"**.cgi$|**.pl$|**.php$"
,
"cgi_environment"
,
NULL
,
"put_delete_auth_file"
,
NULL
,
"cgi_interpreter"
,
NULL
,
"protect_uri"
,
NULL
,
"authentication_domain"
,
"mydomain.com"
,
"ssi_pattern"
,
"**.shtml$|**.shtm$"
,
"throttle"
,
NULL
,
"access_log_file"
,
NULL
,
"enable_directory_listing"
,
"yes"
,
"error_log_file"
,
NULL
,
"global_auth_file"
,
NULL
,
"index_files"
,
"index.html,index.htm,index.cgi,index.shtml,index.php,index.lp"
,
"enable_keep_alive"
,
"no"
,
"access_control_list"
,
NULL
,
"extra_mime_types"
,
NULL
,
"listening_ports"
,
"8080"
,
"document_root"
,
NULL
,
"ssl_certificate"
,
NULL
,
"num_threads"
,
"50"
,
"run_as_user"
,
NULL
,
"url_rewrite_patterns"
,
NULL
,
"hide_files_patterns"
,
NULL
,
"request_timeout_ms"
,
"30000"
,
NULL
};
// Return number of bytes left to read for this connection
static
int64_t
left_to_read
(
const
struct
mg_connection
*
conn
)
{
return
conn
->
content_len
+
conn
->
request_len
-
conn
->
num_bytes_read
;
}
const
char
**
mg_get_valid_option_names
(
void
)
{
return
config_options
;
}
static
int
call_user
(
int
type
,
struct
mg_connection
*
conn
,
void
*
p
)
{
if
(
conn
!=
NULL
&&
conn
->
ctx
!=
NULL
)
{
conn
->
event
.
user_data
=
conn
->
ctx
->
user_data
;
...
...
@@ -61,28 +28,6 @@ static FILE *mg_fopen(const char *path, const char *mode) {
#endif
}
static
int
get_option_index
(
const
char
*
name
)
{
int
i
;
for
(
i
=
0
;
config_options
[
i
*
2
]
!=
NULL
;
i
++
)
{
if
(
strcmp
(
config_options
[
i
*
2
],
name
)
==
0
)
{
return
i
;
}
}
return
-
1
;
}
const
char
*
mg_get_option
(
const
struct
mg_context
*
ctx
,
const
char
*
name
)
{
int
i
;
if
((
i
=
get_option_index
(
name
))
==
-
1
)
{
return
NULL
;
}
else
if
(
ctx
->
config
[
i
]
==
NULL
)
{
return
""
;
}
else
{
return
ctx
->
config
[
i
];
}
}
static
void
sockaddr_to_string
(
char
*
buf
,
size_t
len
,
const
union
usa
*
usa
)
{
buf
[
0
]
=
'\0'
;
...
...
build/src/options.c
0 → 100644
View file @
199e0a33
#include "internal.h"
// This array must be in sync with enum in internal.h
static
const
char
*
config_options
[]
=
{
"cgi_pattern"
,
"**.cgi$|**.pl$|**.php$"
,
"cgi_environment"
,
NULL
,
"put_delete_auth_file"
,
NULL
,
"cgi_interpreter"
,
NULL
,
"protect_uri"
,
NULL
,
"authentication_domain"
,
"mydomain.com"
,
"ssi_pattern"
,
"**.shtml$|**.shtm$"
,
"throttle"
,
NULL
,
"access_log_file"
,
NULL
,
"enable_directory_listing"
,
"yes"
,
"error_log_file"
,
NULL
,
"global_auth_file"
,
NULL
,
"index_files"
,
"index.html,index.htm,index.cgi,index.shtml,index.php,index.lp"
,
"enable_keep_alive"
,
"no"
,
"access_control_list"
,
NULL
,
"extra_mime_types"
,
NULL
,
"listening_ports"
,
"8080"
,
"document_root"
,
NULL
,
"ssl_certificate"
,
NULL
,
"num_threads"
,
"50"
,
"run_as_user"
,
NULL
,
"url_rewrite_patterns"
,
NULL
,
"hide_files_patterns"
,
NULL
,
"request_timeout_ms"
,
"30000"
,
NULL
};
const
char
**
mg_get_valid_option_names
(
void
)
{
return
config_options
;
}
static
int
get_option_index
(
const
char
*
name
)
{
int
i
;
for
(
i
=
0
;
config_options
[
i
*
2
]
!=
NULL
;
i
++
)
{
if
(
strcmp
(
config_options
[
i
*
2
],
name
)
==
0
)
{
return
i
;
}
}
return
-
1
;
}
const
char
*
mg_get_option
(
const
struct
mg_context
*
ctx
,
const
char
*
name
)
{
int
i
;
if
((
i
=
get_option_index
(
name
))
==
-
1
)
{
return
NULL
;
}
else
if
(
ctx
->
config
[
i
]
==
NULL
)
{
return
""
;
}
else
{
return
ctx
->
config
[
i
];
}
}
mongoose.c
View file @
199e0a33
...
...
@@ -751,6 +751,7 @@ static time_t parse_date_string(const char *datetime) {
return
result
;
}
// This array must be in sync with enum in internal.h
static
const
char
*
config_options
[]
=
{
"cgi_pattern"
,
"**.cgi$|**.pl$|**.php$"
,
"cgi_environment"
,
NULL
,
...
...
@@ -780,15 +781,37 @@ static const char *config_options[] = {
NULL
};
const
char
**
mg_get_valid_option_names
(
void
)
{
return
config_options
;
}
static
int
get_option_index
(
const
char
*
name
)
{
int
i
;
for
(
i
=
0
;
config_options
[
i
*
2
]
!=
NULL
;
i
++
)
{
if
(
strcmp
(
config_options
[
i
*
2
],
name
)
==
0
)
{
return
i
;
}
}
return
-
1
;
}
const
char
*
mg_get_option
(
const
struct
mg_context
*
ctx
,
const
char
*
name
)
{
int
i
;
if
((
i
=
get_option_index
(
name
))
==
-
1
)
{
return
NULL
;
}
else
if
(
ctx
->
config
[
i
]
==
NULL
)
{
return
""
;
}
else
{
return
ctx
->
config
[
i
];
}
}
// Return number of bytes left to read for this connection
static
int64_t
left_to_read
(
const
struct
mg_connection
*
conn
)
{
return
conn
->
content_len
+
conn
->
request_len
-
conn
->
num_bytes_read
;
}
const
char
**
mg_get_valid_option_names
(
void
)
{
return
config_options
;
}
static
int
call_user
(
int
type
,
struct
mg_connection
*
conn
,
void
*
p
)
{
if
(
conn
!=
NULL
&&
conn
->
ctx
!=
NULL
)
{
conn
->
event
.
user_data
=
conn
->
ctx
->
user_data
;
...
...
@@ -812,28 +835,6 @@ static FILE *mg_fopen(const char *path, const char *mode) {
#endif
}
static
int
get_option_index
(
const
char
*
name
)
{
int
i
;
for
(
i
=
0
;
config_options
[
i
*
2
]
!=
NULL
;
i
++
)
{
if
(
strcmp
(
config_options
[
i
*
2
],
name
)
==
0
)
{
return
i
;
}
}
return
-
1
;
}
const
char
*
mg_get_option
(
const
struct
mg_context
*
ctx
,
const
char
*
name
)
{
int
i
;
if
((
i
=
get_option_index
(
name
))
==
-
1
)
{
return
NULL
;
}
else
if
(
ctx
->
config
[
i
]
==
NULL
)
{
return
""
;
}
else
{
return
ctx
->
config
[
i
];
}
}
static
void
sockaddr_to_string
(
char
*
buf
,
size_t
len
,
const
union
usa
*
usa
)
{
buf
[
0
]
=
'\0'
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment