From 69468b700d53dcdcdc0ae4cc3d92a15694b3f7a5 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Tue, 14 Dec 2021 01:33:49 +0800 Subject: [PATCH] libc: Move syslog_stream from nuttx/streams.h to drivers/syslog/syslog.h Signed-off-by: Xiang Xiao --- drivers/syslog/syslog.h | 59 ++++++++++++++++++++++++++++++++++ drivers/syslog/syslog_stream.c | 3 -- drivers/syslog/vsyslog.c | 4 +-- include/nuttx/streams.h | 54 ------------------------------- 4 files changed, 61 insertions(+), 59 deletions(-) diff --git a/drivers/syslog/syslog.h b/drivers/syslog/syslog.h index 5e32dd26a1..6552518a29 100644 --- a/drivers/syslog/syslog.h +++ b/drivers/syslog/syslog.h @@ -26,9 +26,29 @@ ****************************************************************************/ #include +#include #include +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/* 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 + */ + +struct iob_s; /* Forward reference */ + +struct lib_syslogstream_s +{ + struct lib_outstream_s public; +#ifdef CONFIG_SYSLOG_BUFFER + FAR struct iob_s *iob; +#endif +}; + /**************************************************************************** * Public Data ****************************************************************************/ @@ -278,6 +298,45 @@ ssize_t syslog_write(FAR const char *buffer, size_t buflen); int syslog_force(int ch); +/**************************************************************************** + * Name: syslogstream_create + * + * Description: + * Initializes a stream for use with the configured syslog interface. + * Only accessible from with the OS SYSLOG logic. + * + * Input Parameters: + * stream - User allocated, uninitialized instance of struct + * lib_syslogstream_s to be initialized. + * + * Returned Value: + * None (User allocated instance initialized). + * + ****************************************************************************/ + +void syslogstream_create(FAR struct lib_syslogstream_s *stream); + +/**************************************************************************** + * Name: syslogstream_destroy + * + * Description: + * Free resources held by the syslog stream. + * + * Input Parameters: + * stream - User allocated, uninitialized instance of struct + * lib_syslogstream_s to be initialized. + * + * Returned Value: + * None (Resources freed). + * + ****************************************************************************/ + +#ifdef CONFIG_SYSLOG_BUFFER +void syslogstream_destroy(FAR struct lib_syslogstream_s *stream); +#else +# define syslogstream_destroy(s) +#endif + #undef EXTERN #ifdef __cplusplus } diff --git a/drivers/syslog/syslog_stream.c b/drivers/syslog/syslog_stream.c index a44bd5b947..64619431fb 100644 --- a/drivers/syslog/syslog_stream.c +++ b/drivers/syslog/syslog_stream.c @@ -24,12 +24,9 @@ #include -#include -#include #include #include -#include #include #include diff --git a/drivers/syslog/vsyslog.c b/drivers/syslog/vsyslog.c index 3b23a1ce8c..050b9483a1 100644 --- a/drivers/syslog/vsyslog.c +++ b/drivers/syslog/vsyslog.c @@ -32,8 +32,8 @@ #include #include #include -#include -#include + +#include "syslog.h" /**************************************************************************** * Private Data diff --git a/include/nuttx/streams.h b/include/nuttx/streams.h index d10ad46400..f4c2e55529 100644 --- a/include/nuttx/streams.h +++ b/include/nuttx/streams.h @@ -173,21 +173,6 @@ struct lib_rawsostream_s int fd; }; -/* 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 - */ - -struct iob_s; /* Forward reference */ - -struct lib_syslogstream_s -{ - struct lib_outstream_s public; -#ifdef CONFIG_SYSLOG_BUFFER - FAR struct iob_s *iob; -#endif -}; - /**************************************************************************** * Public Data ****************************************************************************/ @@ -344,45 +329,6 @@ void lib_zeroinstream(FAR struct lib_instream_s *zeroinstream); void lib_nullinstream(FAR struct lib_instream_s *nullinstream); void lib_nulloutstream(FAR struct lib_outstream_s *nulloutstream); -/**************************************************************************** - * Name: syslogstream_create - * - * Description: - * Initializes a stream for use with the configured syslog interface. - * Only accessible from with the OS SYSLOG logic. - * - * Input Parameters: - * stream - User allocated, uninitialized instance of struct - * lib_syslogstream_s to be initialized. - * - * Returned Value: - * None (User allocated instance initialized). - * - ****************************************************************************/ - -void syslogstream_create(FAR struct lib_syslogstream_s *stream); - -/**************************************************************************** - * Name: syslogstream_destroy - * - * Description: - * Free resources held by the syslog stream. - * - * Input Parameters: - * stream - User allocated, uninitialized instance of struct - * lib_syslogstream_s to be initialized. - * - * Returned Value: - * None (Resources freed). - * - ****************************************************************************/ - -#ifdef CONFIG_SYSLOG_BUFFER -void syslogstream_destroy(FAR struct lib_syslogstream_s *stream); -#else -# define syslogstream_destroy(s) -#endif - /**************************************************************************** * Name: lib_noflush *