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
ea7d6906
Commit
ea7d6906
authored
8 years ago
by
Alexander Alashkin
Committed by
Cesanta Bot
8 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace fopen with mg_fopen
PUBLISHED_FROM=764ea806a5d31bd545a5d99de80e2ee0234ebcab
parent
6e5e2eb6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
13 deletions
+13
-13
mongoose.c
mongoose.c
+13
-13
No files found.
mongoose.c
View file @
ea7d6906
...
@@ -6009,7 +6009,7 @@ void mg_file_upload_handler(struct mg_connection *nc, int ev, void *ev_data,
...
@@ -6009,7 +6009,7 @@ void mg_file_upload_handler(struct mg_connection *nc, int ev, void *ev_data,
if
(
lfn
.
p
!=
mp
->
file_name
)
free
((
char
*
)
lfn
.
p
);
if
(
lfn
.
p
!=
mp
->
file_name
)
free
((
char
*
)
lfn
.
p
);
LOG
(
LL_DEBUG
,
LOG
(
LL_DEBUG
,
(
"%p Receiving file %s -> %s"
,
nc
,
mp
->
file_name
,
fus
->
lfn
));
(
"%p Receiving file %s -> %s"
,
nc
,
mp
->
file_name
,
fus
->
lfn
));
fus
->
fp
=
fopen
(
fus
->
lfn
,
"w"
);
fus
->
fp
=
mg_
fopen
(
fus
->
lfn
,
"w"
);
if
(
fus
->
fp
==
NULL
)
{
if
(
fus
->
fp
==
NULL
)
{
mg_printf
(
nc
,
mg_printf
(
nc
,
"HTTP/1.1 500 Internal Server Error
\r\n
"
"HTTP/1.1 500 Internal Server Error
\r\n
"
...
@@ -6329,7 +6329,7 @@ void mg_http_serve_file(struct mg_connection *nc, struct http_message *hm,
...
@@ -6329,7 +6329,7 @@ void mg_http_serve_file(struct mg_connection *nc, struct http_message *hm,
struct
mg_http_proto_data
*
pd
=
mg_http_get_proto_data
(
nc
);
struct
mg_http_proto_data
*
pd
=
mg_http_get_proto_data
(
nc
);
cs_stat_t
st
;
cs_stat_t
st
;
DBG
((
"%p [%s] %.*s"
,
nc
,
path
,
(
int
)
mime_type
.
len
,
mime_type
.
p
));
DBG
((
"%p [%s] %.*s"
,
nc
,
path
,
(
int
)
mime_type
.
len
,
mime_type
.
p
));
if
(
mg_stat
(
path
,
&
st
)
!=
0
||
(
pd
->
file
.
fp
=
fopen
(
path
,
"rb"
))
==
NULL
)
{
if
(
mg_stat
(
path
,
&
st
)
!=
0
||
(
pd
->
file
.
fp
=
mg_
fopen
(
path
,
"rb"
))
==
NULL
)
{
int
code
,
err
=
mg_get_errno
();
int
code
,
err
=
mg_get_errno
();
switch
(
err
)
{
switch
(
err
)
{
case
EACCES
:
case
EACCES
:
...
@@ -6748,16 +6748,16 @@ static int mg_is_authorized(struct http_message *hm, const char *path,
...
@@ -6748,16 +6748,16 @@ static int mg_is_authorized(struct http_message *hm, const char *path,
if
(
domain
!=
NULL
&&
passwords_file
!=
NULL
)
{
if
(
domain
!=
NULL
&&
passwords_file
!=
NULL
)
{
if
(
is_global_pass_file
)
{
if
(
is_global_pass_file
)
{
fp
=
fopen
(
passwords_file
,
"r"
);
fp
=
mg_
fopen
(
passwords_file
,
"r"
);
}
else
if
(
is_directory
)
{
}
else
if
(
is_directory
)
{
snprintf
(
buf
,
sizeof
(
buf
),
"%s%c%s"
,
path
,
DIRSEP
,
passwords_file
);
snprintf
(
buf
,
sizeof
(
buf
),
"%s%c%s"
,
path
,
DIRSEP
,
passwords_file
);
fp
=
fopen
(
buf
,
"r"
);
fp
=
mg_
fopen
(
buf
,
"r"
);
}
else
{
}
else
{
p
=
strrchr
(
path
,
DIRSEP
);
p
=
strrchr
(
path
,
DIRSEP
);
if
(
p
==
NULL
)
p
=
path
;
if
(
p
==
NULL
)
p
=
path
;
snprintf
(
buf
,
sizeof
(
buf
),
"%.*s%c%s"
,
(
int
)
(
p
-
path
),
path
,
DIRSEP
,
snprintf
(
buf
,
sizeof
(
buf
),
"%.*s%c%s"
,
(
int
)
(
p
-
path
),
path
,
DIRSEP
,
passwords_file
);
passwords_file
);
fp
=
fopen
(
buf
,
"r"
);
fp
=
mg_
fopen
(
buf
,
"r"
);
}
}
if
(
fp
!=
NULL
)
{
if
(
fp
!=
NULL
)
{
...
@@ -7876,7 +7876,7 @@ static int mg_start_process(const char *interp, const char *cmd,
...
@@ -7876,7 +7876,7 @@ static int mg_start_process(const char *interp, const char *cmd,
DuplicateHandle
(
me
,
a
[
0
],
me
,
&
si
.
hStdInput
,
0
,
TRUE
,
flags
);
DuplicateHandle
(
me
,
a
[
0
],
me
,
&
si
.
hStdInput
,
0
,
TRUE
,
flags
);
DuplicateHandle
(
me
,
b
[
1
],
me
,
&
si
.
hStdOutput
,
0
,
TRUE
,
flags
);
DuplicateHandle
(
me
,
b
[
1
],
me
,
&
si
.
hStdOutput
,
0
,
TRUE
,
flags
);
if
(
interp
==
NULL
&&
(
fp
=
fopen
(
cmd
,
"r"
))
!=
NULL
)
{
if
(
interp
==
NULL
&&
(
fp
=
mg_
fopen
(
cmd
,
"r"
))
!=
NULL
)
{
buf
[
0
]
=
buf
[
1
]
=
'\0'
;
buf
[
0
]
=
buf
[
1
]
=
'\0'
;
fgets
(
buf
,
sizeof
(
buf
),
fp
);
fgets
(
buf
,
sizeof
(
buf
),
fp
);
buf
[
sizeof
(
buf
)
-
1
]
=
'\0'
;
buf
[
sizeof
(
buf
)
-
1
]
=
'\0'
;
...
@@ -8292,8 +8292,8 @@ static void mg_do_ssi_include(struct mg_connection *nc, struct http_message *hm,
...
@@ -8292,8 +8292,8 @@ static void mg_do_ssi_include(struct mg_connection *nc, struct http_message *hm,
return
;
return
;
}
}
if
((
fp
=
fopen
(
path
,
"rb"
))
==
NULL
)
{
if
((
fp
=
mg_
fopen
(
path
,
"rb"
))
==
NULL
)
{
mg_printf
(
nc
,
"SSI include error: fopen(%s): %s"
,
path
,
mg_printf
(
nc
,
"SSI include error:
mg_
fopen(%s): %s"
,
path
,
strerror
(
mg_get_errno
()));
strerror
(
mg_get_errno
()));
}
else
{
}
else
{
mg_set_close_on_exec
((
sock_t
)
fileno
(
fp
));
mg_set_close_on_exec
((
sock_t
)
fileno
(
fp
));
...
@@ -8416,7 +8416,7 @@ MG_INTERNAL void mg_handle_ssi_request(struct mg_connection *nc,
...
@@ -8416,7 +8416,7 @@ MG_INTERNAL void mg_handle_ssi_request(struct mg_connection *nc,
struct
mg_str
mime_type
;
struct
mg_str
mime_type
;
DBG
((
"%p %s"
,
nc
,
path
));
DBG
((
"%p %s"
,
nc
,
path
));
if
((
fp
=
fopen
(
path
,
"rb"
))
==
NULL
)
{
if
((
fp
=
mg_
fopen
(
path
,
"rb"
))
==
NULL
)
{
mg_http_send_error
(
nc
,
404
,
NULL
);
mg_http_send_error
(
nc
,
404
,
NULL
);
}
else
{
}
else
{
mg_set_close_on_exec
((
sock_t
)
fileno
(
fp
));
mg_set_close_on_exec
((
sock_t
)
fileno
(
fp
));
...
@@ -8683,7 +8683,7 @@ MG_INTERNAL void mg_handle_put(struct mg_connection *nc, const char *path,
...
@@ -8683,7 +8683,7 @@ MG_INTERNAL void mg_handle_put(struct mg_connection *nc, const char *path,
mg_http_send_error
(
nc
,
500
,
NULL
);
mg_http_send_error
(
nc
,
500
,
NULL
);
}
else
if
(
cl_hdr
==
NULL
)
{
}
else
if
(
cl_hdr
==
NULL
)
{
mg_http_send_error
(
nc
,
411
,
NULL
);
mg_http_send_error
(
nc
,
411
,
NULL
);
}
else
if
((
pd
->
file
.
fp
=
fopen
(
path
,
"w+b"
))
==
NULL
)
{
}
else
if
((
pd
->
file
.
fp
=
mg_
fopen
(
path
,
"w+b"
))
==
NULL
)
{
mg_http_send_error
(
nc
,
500
,
NULL
);
mg_http_send_error
(
nc
,
500
,
NULL
);
}
else
{
}
else
{
const
struct
mg_str
*
range_hdr
=
mg_get_http_header
(
hm
,
"Content-Range"
);
const
struct
mg_str
*
range_hdr
=
mg_get_http_header
(
hm
,
"Content-Range"
);
...
@@ -9306,7 +9306,7 @@ void mg_hexdump_connection(struct mg_connection *nc, const char *path,
...
@@ -9306,7 +9306,7 @@ void mg_hexdump_connection(struct mg_connection *nc, const char *path,
fp
=
stderr
;
fp
=
stderr
;
#if MG_ENABLE_FILESYSTEM
#if MG_ENABLE_FILESYSTEM
}
else
{
}
else
{
fp
=
fopen
(
path
,
"a"
);
fp
=
mg_
fopen
(
path
,
"a"
);
#endif
#endif
}
}
if
(
fp
==
NULL
)
return
;
if
(
fp
==
NULL
)
return
;
...
@@ -10538,7 +10538,7 @@ static int mg_get_ip_address_of_nameserver(char *name, size_t name_len) {
...
@@ -10538,7 +10538,7 @@ static int mg_get_ip_address_of_nameserver(char *name, size_t name_len) {
FILE
*
fp
;
FILE
*
fp
;
char
line
[
512
];
char
line
[
512
];
if
((
fp
=
fopen
(
"/etc/resolv.conf"
,
"r"
))
==
NULL
)
{
if
((
fp
=
mg_
fopen
(
"/etc/resolv.conf"
,
"r"
))
==
NULL
)
{
ret
=
-
1
;
ret
=
-
1
;
}
else
{
}
else
{
/* Try to figure out what nameserver to use */
/* Try to figure out what nameserver to use */
...
@@ -10569,7 +10569,7 @@ int mg_resolve_from_hosts_file(const char *name, union socket_address *usa) {
...
@@ -10569,7 +10569,7 @@ int mg_resolve_from_hosts_file(const char *name, union socket_address *usa) {
unsigned
int
a
,
b
,
c
,
d
;
unsigned
int
a
,
b
,
c
,
d
;
int
len
=
0
;
int
len
=
0
;
if
((
fp
=
fopen
(
"/etc/hosts"
,
"r"
))
==
NULL
)
{
if
((
fp
=
mg_
fopen
(
"/etc/hosts"
,
"r"
))
==
NULL
)
{
return
-
1
;
return
-
1
;
}
}
...
...
This diff is collapsed.
Click to expand it.
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