stream/hexdump: add hexdump stream to dump binary to syslog

Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
chao an
2023-05-18 11:19:27 +08:00
committed by Xiang Xiao
parent 0203839fa1
commit e51ec54c02
4 changed files with 214 additions and 0 deletions
+27
View File
@@ -225,6 +225,14 @@ struct lib_bufferedoutstream_s
char buffer[CONFIG_STREAM_OUT_BUFFER_SIZE];
};
struct lib_hexdumpstream_s
{
struct lib_outstream_s public;
FAR struct lib_outstream_s *backend;
int pending;
char buffer[CONFIG_STREAM_HEXDUMP_BUFFER_SIZE + 1];
};
/* This is a special stream that does buffered character I/O. NOTE that is
* CONFIG_SYSLOG_BUFFER is not defined, it is the same as struct
* lib_outstream_s
@@ -413,6 +421,25 @@ void lib_rawsostream(FAR struct lib_rawsostream_s *outstream, int fd);
void lib_bufferedoutstream(FAR struct lib_bufferedoutstream_s *outstream,
FAR struct lib_outstream_s *backend);
/****************************************************************************
* Name: lib_hexdumpstream
*
* Description:
* Convert binary stream to hex and redirect to syslog
*
* Input Parameters:
* stream - User allocated, uninitialized instance of struct
* lib_bufferedoutstream_s to be initialized.
* backend - Stream backend port.
*
* Returned Value:
* None (User allocated instance initialized).
*
****************************************************************************/
void lib_hexdumpstream(FAR struct lib_hexdumpstream_s *stream,
FAR struct lib_outstream_s *backend);
/****************************************************************************
* Name: lib_lowoutstream
*