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
e0214af4
Commit
e0214af4
authored
Mar 02, 2014
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Using private ns_avprintf() in mg_printf_data()
parent
df5e997e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
20 deletions
+9
-20
mongoose.c
mongoose.c
+9
-20
No files found.
mongoose.c
View file @
e0214af4
...
...
@@ -2282,33 +2282,22 @@ void mg_send_data(struct mg_connection *c, const void *data, int data_len) {
void
mg_printf_data
(
struct
mg_connection
*
c
,
const
char
*
fmt
,
...)
{
struct
connection
*
conn
=
MG_CONN_2_CONN
(
c
);
struct
iobuf
*
io
=
&
conn
->
ns_conn
->
send_iobuf
;
va_list
ap
;
int
len
,
n
,
iolen
;
char
*
p
;
int
len
;
char
mem
[
IOBUF_SIZE
],
*
buf
=
mem
;
terminate_headers
(
c
);
// Remember original io->len
iolen
=
io
->
len
;
// Write the placeholder for the chunk size
p
=
io
->
buf
+
io
->
len
;
iobuf_append
(
io
,
"
\r\n
"
,
10
);
// Write chunk itself
va_start
(
ap
,
fmt
);
len
=
ns_
vprintf
(
conn
->
ns_conn
,
fmt
,
ap
);
len
=
ns_
avprintf
(
&
buf
,
sizeof
(
mem
)
,
fmt
,
ap
);
va_end
(
ap
);
// Recalculate pointer p because of potential realloc within iobuf_append
p
=
io
->
buf
+
iolen
;
// Record size
n
=
mg_snprintf
(
p
,
7
,
"%X"
,
len
);
p
[
n
]
=
' '
;
// Write terminating new line
mg_write
(
c
,
"
\r\n
"
,
2
);
if
(
len
>
0
)
{
write_chunk
((
struct
connection
*
)
conn
,
buf
,
len
);
}
if
(
buf
!=
mem
&&
buf
!=
NULL
)
{
free
(
buf
);
}
}
#if !defined(MONGOOSE_NO_WEBSOCKET) || !defined(MONGOOSE_NO_AUTH)
...
...
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