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
ed74cd82
Commit
ed74cd82
authored
Sep 23, 2012
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added declarations for printf like functions
parent
d2be5942
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
5 deletions
+12
-5
mongoose.c
mongoose.c
+12
-5
No files found.
mongoose.c
View file @
ed74cd82
...
@@ -564,6 +564,9 @@ static void sockaddr_to_string(char *buf, size_t len,
...
@@ -564,6 +564,9 @@ static void sockaddr_to_string(char *buf, size_t len,
#endif
#endif
}
}
static
void
cry
(
struct
mg_connection
*
conn
,
PRINTF_FORMAT_STRING
(
const
char
*
fmt
),
...)
PRINTF_ARGS
(
2
,
3
);
// Print error message to the opened error log stream.
// Print error message to the opened error log stream.
static
void
cry
(
struct
mg_connection
*
conn
,
const
char
*
fmt
,
...)
{
static
void
cry
(
struct
mg_connection
*
conn
,
const
char
*
fmt
,
...)
{
char
buf
[
MG_BUF_LEN
],
src_addr
[
20
];
char
buf
[
MG_BUF_LEN
],
src_addr
[
20
];
...
@@ -696,6 +699,10 @@ static int mg_vsnprintf(struct mg_connection *conn, char *buf, size_t buflen,
...
@@ -696,6 +699,10 @@ static int mg_vsnprintf(struct mg_connection *conn, char *buf, size_t buflen,
return
n
;
return
n
;
}
}
static
int
mg_snprintf
(
struct
mg_connection
*
conn
,
char
*
buf
,
size_t
buflen
,
PRINTF_FORMAT_STRING
(
const
char
*
fmt
),
...)
PRINTF_ARGS
(
4
,
5
);
static
int
mg_snprintf
(
struct
mg_connection
*
conn
,
char
*
buf
,
size_t
buflen
,
static
int
mg_snprintf
(
struct
mg_connection
*
conn
,
char
*
buf
,
size_t
buflen
,
const
char
*
fmt
,
...)
{
const
char
*
fmt
,
...)
{
va_list
ap
;
va_list
ap
;
...
@@ -887,7 +894,6 @@ static void send_http_error(struct mg_connection *conn, int status,
...
@@ -887,7 +894,6 @@ static void send_http_error(struct mg_connection *conn, int status,
int
len
;
int
len
;
conn
->
status_code
=
status
;
conn
->
status_code
=
status
;
if
(
call_user
(
conn
,
MG_HTTP_ERROR
)
==
NULL
)
{
if
(
call_user
(
conn
,
MG_HTTP_ERROR
)
==
NULL
)
{
buf
[
0
]
=
'\0'
;
buf
[
0
]
=
'\0'
;
len
=
0
;
len
=
0
;
...
@@ -1672,7 +1678,8 @@ static int convert_uri_to_file_name(struct mg_connection *conn, char *buf,
...
@@ -1672,7 +1678,8 @@ static int convert_uri_to_file_name(struct mg_connection *conn, char *buf,
rewrite
=
conn
->
ctx
->
config
[
REWRITE
];
rewrite
=
conn
->
ctx
->
config
[
REWRITE
];
while
((
rewrite
=
next_option
(
rewrite
,
&
a
,
&
b
))
!=
NULL
)
{
while
((
rewrite
=
next_option
(
rewrite
,
&
a
,
&
b
))
!=
NULL
)
{
if
((
match_len
=
match_prefix
(
a
.
ptr
,
a
.
len
,
uri
))
>
0
)
{
if
((
match_len
=
match_prefix
(
a
.
ptr
,
a
.
len
,
uri
))
>
0
)
{
mg_snprintf
(
conn
,
buf
,
buf_len
,
"%.*s%s"
,
b
.
len
,
b
.
ptr
,
uri
+
match_len
);
mg_snprintf
(
conn
,
buf
,
buf_len
,
"%.*s%s"
,
(
int
)
b
.
len
,
b
.
ptr
,
uri
+
match_len
);
break
;
break
;
}
}
}
}
...
@@ -2283,8 +2290,8 @@ static int check_authorization(struct mg_connection *conn, const char *path) {
...
@@ -2283,8 +2290,8 @@ static int check_authorization(struct mg_connection *conn, const char *path) {
list
=
conn
->
ctx
->
config
[
PROTECT_URI
];
list
=
conn
->
ctx
->
config
[
PROTECT_URI
];
while
((
list
=
next_option
(
list
,
&
uri_vec
,
&
filename_vec
))
!=
NULL
)
{
while
((
list
=
next_option
(
list
,
&
uri_vec
,
&
filename_vec
))
!=
NULL
)
{
if
(
!
memcmp
(
conn
->
request_info
.
uri
,
uri_vec
.
ptr
,
uri_vec
.
len
))
{
if
(
!
memcmp
(
conn
->
request_info
.
uri
,
uri_vec
.
ptr
,
uri_vec
.
len
))
{
(
void
)
mg_snprintf
(
conn
,
fname
,
sizeof
(
fname
),
"%.*s"
,
mg_snprintf
(
conn
,
fname
,
sizeof
(
fname
),
"%.*s"
,
filename_vec
.
len
,
filename_vec
.
ptr
);
(
int
)
filename_vec
.
len
,
filename_vec
.
ptr
);
if
((
fp
=
mg_fopen
(
fname
,
"r"
))
==
NULL
)
{
if
((
fp
=
mg_fopen
(
fname
,
"r"
))
==
NULL
)
{
cry
(
conn
,
"%s: cannot open %s: %s"
,
__func__
,
fname
,
strerror
(
errno
));
cry
(
conn
,
"%s: cannot open %s: %s"
,
__func__
,
fname
,
strerror
(
errno
));
}
}
...
@@ -3898,7 +3905,7 @@ static int set_ports_option(struct mg_context *ctx) {
...
@@ -3898,7 +3905,7 @@ static int set_ports_option(struct mg_context *ctx) {
listen
(
sock
,
SOMAXCONN
)
!=
0
)
{
listen
(
sock
,
SOMAXCONN
)
!=
0
)
{
closesocket
(
sock
);
closesocket
(
sock
);
cry
(
fc
(
ctx
),
"%s: cannot bind to %.*s: %s"
,
__func__
,
cry
(
fc
(
ctx
),
"%s: cannot bind to %.*s: %s"
,
__func__
,
vec
.
len
,
vec
.
ptr
,
strerror
(
ERRNO
));
(
int
)
vec
.
len
,
vec
.
ptr
,
strerror
(
ERRNO
));
success
=
0
;
success
=
0
;
}
else
if
((
listener
=
(
struct
socket
*
)
}
else
if
((
listener
=
(
struct
socket
*
)
calloc
(
1
,
sizeof
(
*
listener
)))
==
NULL
)
{
calloc
(
1
,
sizeof
(
*
listener
)))
==
NULL
)
{
...
...
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