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
fc113d64
Commit
fc113d64
authored
Feb 09, 2017
by
Deomid Ryabkov
Committed by
Cesanta Bot
Feb 09, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add mg_hexdumpf: mg_hexdump that outputs to a file
PUBLISHED_FROM=f0fe58c9f01ef0c7b491ed0e5f51b983e4119507
parent
6f6b12be
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
5 deletions
+36
-5
intro.md
docs/c-api/util.h/intro.md
+1
-0
mg_hexdumpf.md
docs/c-api/util.h/mg_hexdumpf.md
+10
-0
mongoose.c
mongoose.c
+22
-5
mongoose.h
mongoose.h
+3
-0
No files found.
docs/c-api/util.h/intro.md
View file @
fc113d64
...
...
@@ -10,6 +10,7 @@ items:
-
{
name
:
mg_fopen.md
}
-
{
name
:
mg_hexdump.md
}
-
{
name
:
mg_hexdump_connection.md
}
-
{
name
:
mg_hexdumpf.md
}
-
{
name
:
mg_is_big_endian.md
}
-
{
name
:
mg_match_prefix.md
}
-
{
name
:
mg_mbuf_append_base64.md
}
...
...
docs/c-api/util.h/mg_hexdumpf.md
0 → 100644
View file @
fc113d64
---
title
:
"
mg_hexdumpf()"
decl_name
:
"
mg_hexdumpf"
symbol_kind
:
"
func"
signature
:
|
void mg_hexdumpf(FILE *fp, const void *buf, int len);
---
Same as mg_hexdump, but with output going to file instead of a buffer.
mongoose.c
View file @
fc113d64
...
...
@@ -9207,7 +9207,8 @@ void mg_conn_addr_to_str(struct mg_connection *nc, char *buf, size_t len,
}
#if MG_ENABLE_HEXDUMP
int
mg_hexdump
(
const
void
*
buf
,
int
len
,
char
*
dst
,
int
dst_len
)
{
static
int
mg_hexdump_n
(
const
void
*
buf
,
int
len
,
char
*
dst
,
int
dst_len
,
int
offset
)
{
const
unsigned
char
*
p
=
(
const
unsigned
char
*
)
buf
;
char
ascii
[
17
]
=
""
;
int
i
,
idx
,
n
=
0
;
...
...
@@ -9216,7 +9217,7 @@ int mg_hexdump(const void *buf, int len, char *dst, int dst_len) {
idx
=
i
%
16
;
if
(
idx
==
0
)
{
if
(
i
>
0
)
n
+=
snprintf
(
dst
+
n
,
MAX
(
dst_len
-
n
,
0
),
" %s
\n
"
,
ascii
);
n
+=
snprintf
(
dst
+
n
,
MAX
(
dst_len
-
n
,
0
),
"%04x "
,
i
);
n
+=
snprintf
(
dst
+
n
,
MAX
(
dst_len
-
n
,
0
),
"%04x "
,
i
+
offset
);
}
if
(
dst_len
-
n
<
0
)
{
return
n
;
...
...
@@ -9227,11 +9228,27 @@ int mg_hexdump(const void *buf, int len, char *dst, int dst_len) {
}
while
(
i
++
%
16
)
n
+=
snprintf
(
dst
+
n
,
MAX
(
dst_len
-
n
,
0
),
"%s"
,
" "
);
n
+=
snprintf
(
dst
+
n
,
MAX
(
dst_len
-
n
,
0
),
" %s
\n
\n
"
,
ascii
);
n
+=
snprintf
(
dst
+
n
,
MAX
(
dst_len
-
n
,
0
),
" %s
\n
"
,
ascii
);
return
n
;
}
int
mg_hexdump
(
const
void
*
buf
,
int
len
,
char
*
dst
,
int
dst_len
)
{
return
mg_hexdump_n
(
buf
,
len
,
dst
,
dst_len
,
0
);
}
void
mg_hexdumpf
(
FILE
*
fp
,
const
void
*
buf
,
int
len
)
{
char
tmp
[
80
];
int
offset
=
0
,
n
;
while
(
len
>
0
)
{
n
=
(
len
<
16
?
len
:
16
);
mg_hexdump_n
(((
const
char
*
)
buf
)
+
offset
,
n
,
tmp
,
sizeof
(
tmp
),
offset
);
fputs
(
tmp
,
fp
);
offset
+=
n
;
len
-=
n
;
}
}
void
mg_hexdump_connection
(
struct
mg_connection
*
nc
,
const
char
*
path
,
const
void
*
buf
,
int
num_bytes
,
int
ev
)
{
FILE
*
fp
=
NULL
;
...
...
@@ -13535,8 +13552,8 @@ struct mg_lwip_conn_state {
size_t
rx_offset
;
/* Offset within the first pbuf (if partially consumed) */
/* Last SSL write size, for retries. */
int
last_ssl_write_size
;
int
recv_pending
;
/* Whether MG_SIG_RECV is already pending for this
connection */
/* Whether MG_SIG_RECV is already pending for this connection */
int
recv_pending
;
};
enum
mg_sig_type
{
...
...
mongoose.h
View file @
fc113d64
...
...
@@ -3938,6 +3938,9 @@ void mg_sock_addr_to_str(const union socket_address *sa, char *buf, size_t len,
*/
int
mg_hexdump
(
const
void
*
buf
,
int
len
,
char
*
dst
,
int
dst_len
);
/* Same as mg_hexdump, but with output going to file instead of a buffer. */
void
mg_hexdumpf
(
FILE
*
fp
,
const
void
*
buf
,
int
len
);
/*
* Generates human-readable hexdump of the data sent or received by the
* connection. `path` is a file name where hexdump should be written.
...
...
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