summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-10-08 17:16:41 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-10-08 17:16:41 -0600
commitbfc59b202544b8824f72f7a21563663a43f16fda (patch)
treeb5743f75e74aa1733f2c3442c2661d1f616c7108
parentc271a9977ee1798762c72a4c11daa51556616114 (diff)
downloadnuttx-bfc59b202544b8824f72f7a21563663a43f16fda.tar.gz
nuttx-bfc59b202544b8824f72f7a21563663a43f16fda.tar.bz2
nuttx-bfc59b202544b8824f72f7a21563663a43f16fda.zip
Move syslog logic from libc/misc and libc/stdio to libc/syslog
-rw-r--r--nuttx/include/syslog.h7
-rw-r--r--nuttx/libc/Makefile1
-rw-r--r--nuttx/libc/lib_internal.h6
-rw-r--r--nuttx/libc/misc/Make.defs8
-rw-r--r--nuttx/libc/misc/lib_dbg.c74
-rw-r--r--nuttx/libc/stdio/Make.defs11
-rw-r--r--nuttx/libc/syslog/Make.defs51
-rw-r--r--nuttx/libc/syslog/lib_lowsyslog.c (renamed from nuttx/libc/stdio/lib_lowsyslog.c)2
-rw-r--r--nuttx/libc/syslog/lib_syslog.c (renamed from nuttx/libc/stdio/lib_syslog.c)3
-rw-r--r--nuttx/libc/syslog/lib_syslogenable.c73
-rw-r--r--nuttx/libc/syslog/lib_syslogstream.c (renamed from nuttx/libc/stdio/lib_syslogstream.c)3
-rw-r--r--nuttx/libc/syslog/syslog.h81
12 files changed, 240 insertions, 80 deletions
diff --git a/nuttx/include/syslog.h b/nuttx/include/syslog.h
index c71d95176..e57595fe1 100644
--- a/nuttx/include/syslog.h
+++ b/nuttx/include/syslog.h
@@ -124,7 +124,6 @@ extern "C"
#if 0 /* Not supported */
void openlog(FAR const char *ident, int option, int facility);
void closelog(void);
-int setlogmask(int mask);
#endif
/* These low-level debug APIs are provided by the NuttX library. These are
@@ -162,6 +161,12 @@ int lowvsyslog(int priority, FAR const char *format, va_list ap);
# define lowvsyslog(p,f,a) vsyslog(p,f,a)
#endif
+/* The setlogmask() function sets the logmask and returns the previous
+ * mask. If the mask argument is 0, the current logmask is not modified.
+ */
+
+int setlogmask(int mask);
+
/* Enable or disable syslog output */
#ifdef CONFIG_SYSLOG_ENABLE /* Non-standard */
diff --git a/nuttx/libc/Makefile b/nuttx/libc/Makefile
index 8412f8d88..b1082dd51 100644
--- a/nuttx/libc/Makefile
+++ b/nuttx/libc/Makefile
@@ -65,6 +65,7 @@ include stdio/Make.defs
include stdlib/Make.defs
include unistd/Make.defs
include sched/Make.defs
+include syslog/Make.defs
include string/Make.defs
include aio/Make.defs
include pthread/Make.defs
diff --git a/nuttx/libc/lib_internal.h b/nuttx/libc/lib_internal.h
index d5d1700ed..b6518da6d 100644
--- a/nuttx/libc/lib_internal.h
+++ b/nuttx/libc/lib_internal.h
@@ -137,12 +137,6 @@ extern "C"
#define EXTERN extern
#endif
-/* Debug output is initially disabled */
-
-#ifdef CONFIG_SYSLOG_ENABLE
-EXTERN bool g_syslogenable;
-#endif
-
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
diff --git a/nuttx/libc/misc/Make.defs b/nuttx/libc/misc/Make.defs
index 6a2bd63e4..c09e78331 100644
--- a/nuttx/libc/misc/Make.defs
+++ b/nuttx/libc/misc/Make.defs
@@ -59,9 +59,11 @@ endif
# Add the miscellaneous C files to the build
-CSRCS += lib_match.c
-CSRCS += lib_crc32.c lib_crc16.c
-CSRCS += lib_dbg.c lib_dumpbuffer.c
+CSRCS += lib_match.c lib_crc32.c lib_crc16.c lib_dumpbuffer.c
+
+ifeq ($(CONFIG_DEBUG),y)
+CSRCS += lib_dbg.c
+endif
# Keyboard driver encoder/decoder
diff --git a/nuttx/libc/misc/lib_dbg.c b/nuttx/libc/misc/lib_dbg.c
index 41d68ef8c..aa0b857bb 100644
--- a/nuttx/libc/misc/lib_dbg.c
+++ b/nuttx/libc/misc/lib_dbg.c
@@ -44,35 +44,16 @@
#include "lib_internal.h"
-/****************************************************************************
- * Global Variables
- ****************************************************************************/
-
-/* Debug output is initially disabled */
-
-#ifdef CONFIG_SYSLOG_ENABLE
-bool g_syslogenable;
-#endif
+#ifndef CONFIG_CPP_HAVE_VARARGS
/****************************************************************************
- * Global Functions
+ * Public Data
****************************************************************************/
/****************************************************************************
- * Name: syslog_enable
- *
- * Description:
- * Enable or disable debug output.
- *
+ * Public Functions
****************************************************************************/
-#ifdef CONFIG_SYSLOG_ENABLE
-void syslog_enable(bool enable)
-{
- g_syslogenable = enable;
-}
-#endif
-
/****************************************************************************
* Name: dbg, lldbg, vdbg
*
@@ -82,22 +63,15 @@ void syslog_enable(bool enable)
*
****************************************************************************/
-#ifndef CONFIG_CPP_HAVE_VARARGS
#ifdef CONFIG_DEBUG
int dbg(const char *format, ...)
{
va_list ap;
int ret;
-#ifdef CONFIG_SYSLOG_ENABLE
- ret = 0;
- if (g_syslogenable)
-#endif
- {
- va_start(ap, format);
- ret = vsyslog(LOG_DEBUG, format, ap);
- va_end(ap);
- }
+ va_start(ap, format);
+ ret = vsyslog(LOG_DEBUG, format, ap);
+ va_end(ap);
return ret;
}
@@ -108,15 +82,9 @@ int lldbg(const char *format, ...)
va_list ap;
int ret;
-#ifdef CONFIG_SYSLOG_ENABLE
- ret = 0;
- if (g_syslogenable)
-#endif
- {
- va_start(ap, format);
- ret = lowvsyslog(LOG_DEBUG, format, ap);
- va_end(ap);
- }
+ va_start(ap, format);
+ ret = lowvsyslog(LOG_DEBUG, format, ap);
+ va_end(ap);
return ret;
}
@@ -128,15 +96,9 @@ int vdbg(const char *format, ...)
va_list ap;
int ret;
-#ifdef CONFIG_SYSLOG_ENABLE
- ret = 0;
- if (g_syslogenable)
-#endif
- {
- va_start(ap, format);
- ret = vsyslog(LOG_DEBUG, format, ap);
- va_end(ap);
- }
+ va_start(ap, format);
+ ret = vsyslog(LOG_DEBUG, format, ap);
+ va_end(ap);
return ret;
}
@@ -147,15 +109,9 @@ int llvdbg(const char *format, ...)
va_list ap;
int ret;
-#ifdef CONFIG_SYSLOG_ENABLE
- ret = 0;
- if (g_syslogenable)
-#endif
- {
- va_start(ap, format);
- ret = lowvsyslog(LOG_DEBUG, format, ap);
- va_end(ap);
- }
+ va_start(ap, format);
+ ret = lowvsyslog(LOG_DEBUG, format, ap);
+ va_end(ap);
return ret;
}
diff --git a/nuttx/libc/stdio/Make.defs b/nuttx/libc/stdio/Make.defs
index 484b969ce..284c725c4 100644
--- a/nuttx/libc/stdio/Make.defs
+++ b/nuttx/libc/stdio/Make.defs
@@ -37,10 +37,9 @@
# This first group of C files do not depend on having file descriptors or
# C streams.
-CSRCS += lib_fileno.c lib_printf.c lib_syslog.c lib_lowsyslog.c
-CSRCS += lib_sprintf.c lib_asprintf.c lib_snprintf.c lib_libsprintf.c
-CSRCS += lib_vsprintf.c lib_avsprintf.c lib_vsnprintf.c lib_libvsprintf.c
-CSRCS += lib_dprintf.c lib_vdprintf.c
+CSRCS += lib_fileno.c lib_printf.c lib_sprintf.c lib_asprintf.c
+CSRCS += lib_snprintf.c lib_libsprintf.c lib_vsprintf.c lib_avsprintf.c
+CSRCS += lib_vsnprintf.c lib_libvsprintf.c lib_dprintf.c lib_vdprintf.c
CSRCS += lib_meminstream.c lib_memoutstream.c lib_memsistream.c
CSRCS += lib_memsostream.c lib_lowinstream.c lib_lowoutstream.c
CSRCS += lib_zeroinstream.c lib_nullinstream.c lib_nulloutstream.c
@@ -71,10 +70,6 @@ endif
# Other support that depends on specific, configured features.
-ifeq ($(CONFIG_SYSLOG),y)
-CSRCS += lib_syslogstream.c
-endif
-
ifeq ($(CONFIG_LIBC_FLOATINGPOINT),y)
CSRCS += lib_dtoa.c
endif
diff --git a/nuttx/libc/syslog/Make.defs b/nuttx/libc/syslog/Make.defs
new file mode 100644
index 000000000..fe6e620ed
--- /dev/null
+++ b/nuttx/libc/syslog/Make.defs
@@ -0,0 +1,51 @@
+############################################################################
+# libc/syslog/Make.defs
+#
+# Copyright (C) 2014 Gregory Nutt. All rights reserved.
+# Author: Gregory Nutt <gnutt@nuttx.org>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# 3. Neither the name NuttX nor the names of its contributors may be
+# used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+############################################################################
+
+# Add the internal C files to the build
+
+CSRCS += lib_syslog.c lib_lowsyslog.c
+
+ifeq ($(CONFIG_SYSLOG),y)
+CSRCS += lib_syslogstream.c
+endif
+
+ifeq ($(CONFIG_SYSLOG_ENABLE),y)
+CSRCS += lib_syslogenable.c
+endif
+
+# Add the syslog directory to the build
+
+DEPPATH += --dep-path syslog
+VPATH += :syslog
diff --git a/nuttx/libc/stdio/lib_lowsyslog.c b/nuttx/libc/syslog/lib_lowsyslog.c
index 6b6919122..f7287c517 100644
--- a/nuttx/libc/stdio/lib_lowsyslog.c
+++ b/nuttx/libc/syslog/lib_lowsyslog.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * libc/stdio/lib_lowsyslog.c
+ * libc/syslog/lib_lowsyslog.c
*
* Copyright (C) 2007-2009, 2011-2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
diff --git a/nuttx/libc/stdio/lib_syslog.c b/nuttx/libc/syslog/lib_syslog.c
index 06c4637c3..21993ecc4 100644
--- a/nuttx/libc/stdio/lib_syslog.c
+++ b/nuttx/libc/syslog/lib_syslog.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * libc/stdio/lib_syslog.c
+ * libc/syslog/lib_syslog.c
*
* Copyright (C) 2007-2009, 2011-2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@@ -43,6 +43,7 @@
#include <syslog.h>
#include "lib_internal.h"
+#include "syslog/syslog.h"
/****************************************************************************
* Pre-processor Definitions
diff --git a/nuttx/libc/syslog/lib_syslogenable.c b/nuttx/libc/syslog/lib_syslogenable.c
new file mode 100644
index 000000000..adba5b708
--- /dev/null
+++ b/nuttx/libc/syslog/lib_syslogenable.c
@@ -0,0 +1,73 @@
+/****************************************************************************
+ * libc/syslog/lib_syslogenable.c
+ *
+ * Copyright (C) 2007-2009, 2011-2012 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdbool.h>
+
+#include "lib_internal.h"
+
+#ifdef CONFIG_SYSLOG_ENABLE
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/* Debug output is initially disabled */
+
+bool g_syslogenable;
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: syslog_enable
+ *
+ * Description:
+ * Enable or disable debug output.
+ *
+ ****************************************************************************/
+
+void syslog_enable(bool enable)
+{
+ g_syslogenable = enable;
+}
+
+#endif /* CONFIG_SYSLOG_ENABLE */
diff --git a/nuttx/libc/stdio/lib_syslogstream.c b/nuttx/libc/syslog/lib_syslogstream.c
index 59f79f3f8..7d485e74c 100644
--- a/nuttx/libc/stdio/lib_syslogstream.c
+++ b/nuttx/libc/syslog/lib_syslogstream.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * libc/stdio/lib_syslogstream.c
+ * libc/syslog/lib_syslogstream.c
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@@ -46,6 +46,7 @@
#include <nuttx/syslog/syslog.h>
#include "lib_internal.h"
+#include "syslog/syslog.h"
#ifdef CONFIG_SYSLOG
diff --git a/nuttx/libc/syslog/syslog.h b/nuttx/libc/syslog/syslog.h
new file mode 100644
index 000000000..6f9cb5ffa
--- /dev/null
+++ b/nuttx/libc/syslog/syslog.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+ * libc/syslog/syslog.h
+ *
+ * Copyright (C) 2014 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gnutt@nuttx.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+#ifndef __LIBC_SYSLOG_SYSLOG_H
+#define __LIBC_SYSLOG_SYSLOG_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+#undef EXTERN
+#if defined(__cplusplus)
+#define EXTERN extern "C"
+extern "C"
+{
+#else
+#define EXTERN extern
+#endif
+
+/* Debug output is initially disabled */
+
+#ifdef CONFIG_SYSLOG_ENABLE
+EXTERN bool g_syslogenable;
+#endif
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+#undef EXTERN
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* __LIBC_SYSLOG_SYSLOG_H */