summaryrefslogtreecommitdiff
path: root/nuttx
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2009-05-31 13:56:24 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2009-05-31 13:56:24 +0000
commit5ba94a97648150ab48ab40d443527706303b9519 (patch)
treec047e90bb8f47c4370d5dcfe8a2092e41925fc36 /nuttx
parent089fb0b4963141512ef007d6a00b76d4f190c28d (diff)
downloadpx4-nuttx-5ba94a97648150ab48ab40d443527706303b9519.tar.gz
px4-nuttx-5ba94a97648150ab48ab40d443527706303b9519.tar.bz2
px4-nuttx-5ba94a97648150ab48ab40d443527706303b9519.zip
Make lib/ stream implementation visible outside of lib/
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1841 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx')
-rw-r--r--nuttx/include/nuttx/streams.h192
-rw-r--r--nuttx/lib/lib_internal.h115
-rw-r--r--nuttx/lib/lib_meminstream.c2
3 files changed, 195 insertions, 114 deletions
diff --git a/nuttx/include/nuttx/streams.h b/nuttx/include/nuttx/streams.h
new file mode 100644
index 000000000..a55e15c66
--- /dev/null
+++ b/nuttx/include/nuttx/streams.h
@@ -0,0 +1,192 @@
+/****************************************************************************
+ * include/nuttx/streams.h
+ *
+ * Copyright (C) 2009 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * 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 _INCLUDE_NUTTX_STREAMS_H
+#define _INCLUDE_NUTTX_STREAMS_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <stdio.h>
+
+/****************************************************************************
+ * Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+/* These are the generic representations of a streams used by the NuttX */
+
+struct lib_instream_s;
+struct lib_outstream_s;
+
+typedef int (*lib_getc_t)(FAR struct lib_instream_s *this);
+typedef void (*lib_putc_t)(FAR struct lib_outstream_s *this, int ch);
+
+struct lib_instream_s
+{
+ lib_getc_t get; /* Pointer to function to get one character */
+ int nget; /* Total number of characters gotten. Written
+ * by get method, readable by user */
+};
+
+struct lib_outstream_s
+{
+ lib_putc_t put; /* Pointer to function to put one character */
+ int nput; /* Total number of characters put. Written
+ * by put method, readable by user */
+};
+
+/* These are streams that operate on a fixed-sized block of memory */
+
+struct lib_meminstream_s
+{
+ struct lib_instream_s public;
+ FAR const char *buffer; /* Address of first byte in the buffer */
+ int buflen; /* Size of the buffer in bytes */
+};
+
+struct lib_memoutstream_s
+{
+ struct lib_outstream_s public;
+ FAR char *buffer; /* Address of first byte in the buffer */
+ int buflen; /* Size of the buffer in bytes */
+};
+
+/* These are streams that operate on a FILE */
+
+struct lib_stdinstream_s
+{
+ struct lib_instream_s public;
+ FAR FILE *stream;
+};
+
+struct lib_stdoutstream_s
+{
+ struct lib_outstream_s public;
+ FAR FILE *stream;
+};
+
+/* These are streams that operate on a file descriptor */
+
+struct lib_rawoutstream_s
+{
+ struct lib_outstream_s public;
+ int fd;
+};
+
+struct lib_rawinstream_s
+{
+ struct lib_instream_s public;
+ int fd;
+};
+
+/****************************************************************************
+ * Public Variables
+ ****************************************************************************/
+
+#undef EXTERN
+#if defined(__cplusplus)
+# define EXTERN extern "C"
+extern "C"
+{
+#else
+# define EXTERN extern
+#endif
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+/* Defined in lib/lib_meminstream.c */
+
+EXTERN void lib_meminstream(FAR struct lib_meminstream_s *meminstream,
+ FAR const char *bufstart, int buflen);
+
+/* Defined in lib/lib_memoutstream.c */
+
+EXTERN void lib_memoutstream(FAR struct lib_memoutstream_s *memoutstream,
+ FAR char *bufstart, int buflen);
+
+/* Defined in lib/lib_stdinstream.c */
+
+EXTERN void lib_stdinstream(FAR struct lib_stdinstream_s *stdinstream,
+ FAR FILE *stream);
+
+/* Defined in lib/lib_stdoutstream.c */
+
+EXTERN void lib_stdoutstream(FAR struct lib_stdoutstream_s *stdoutstream,
+ FAR FILE *stream);
+
+/* Defined in lib/lib_rawinstream.c */
+
+EXTERN void lib_rawinstream(FAR struct lib_rawinstream_s *rawinstream,
+ int fd);
+
+/* Defined in lib/lib_rawoutstream.c */
+
+EXTERN void lib_rawoutstream(FAR struct lib_rawoutstream_s *rawoutstream,
+ int fd);
+
+/* Defined in lib/lib_lowinstream.c */
+
+#ifdef CONFIG_ARCH_LOWGETC
+EXTERN void lib_lowinstream(FAR struct lib_instream_s *lowinstream);
+#endif
+
+/* Defined in lib/lib_lowoutstream.c */
+
+#ifdef CONFIG_ARCH_LOWPUTC
+EXTERN void lib_lowoutstream(FAR struct lib_outstream_s *lowoutstream);
+#endif
+
+/* Defined in lib/lib_nullinstream.c */
+
+EXTERN void lib_nullinstream(FAR struct lib_instream_s *nullinstream);
+
+/* Defined in lib/lib_nulloutstream.c */
+
+EXTERN void lib_nulloutstream(FAR struct lib_outstream_s *nulloutstream);
+
+#undef EXTERN
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* _INCLUDE_NUTTX_STREAMS_H */
diff --git a/nuttx/lib/lib_internal.h b/nuttx/lib/lib_internal.h
index d19812475..f6eabe6bc 100644
--- a/nuttx/lib/lib_internal.h
+++ b/nuttx/lib/lib_internal.h
@@ -44,6 +44,7 @@
#include <stdio.h>
#include <limits.h>
#include <semaphore.h>
+#include <nuttx/streams.h>
/****************************************************************************
* Definitions
@@ -65,72 +66,10 @@
* Public Types
****************************************************************************/
-/* This is the generic for of a stream used by the library
- * to manage variable sized output.
- */
-
-struct lib_instream_s;
-struct lib_outstream_s;
-
-typedef int (*lib_getc_t)(FAR struct lib_instream_s *this);
-typedef void (*lib_putc_t)(FAR struct lib_outstream_s *this, int ch);
-
-struct lib_instream_s
-{
- lib_getc_t get; /* Pointer to function to get one character */
- int nget; /* Total number of characters gotten. Written
- * by get method, readable by user */
-};
-
-struct lib_outstream_s
-{
- lib_putc_t put; /* Pointer to function to put one character */
- int nput; /* Total number of characters put. Written
- * by put method, readable by user */
-};
-
-struct lib_meminstream_s
-{
- struct lib_instream_s public;
- FAR char *buffer; /* Address of first byte in the buffer */
- int buflen; /* Size of the buffer in bytes */
-};
-
-struct lib_memoutstream_s
-{
- struct lib_outstream_s public;
- FAR char *buffer; /* Address of first byte in the buffer */
- int buflen; /* Size of the buffer in bytes */
-};
-
-struct lib_stdinstream_s
-{
- struct lib_instream_s public;
- FAR FILE *stream;
-};
-
-struct lib_stdoutstream_s
-{
- struct lib_outstream_s public;
- FAR FILE *stream;
-};
-
-struct lib_rawoutstream_s
-{
- struct lib_outstream_s public;
- int fd;
-};
-
-struct lib_rawinstream_s
-{
- struct lib_instream_s public;
- int fd;
-};
-
/****************************************************************************
* Public Variables
****************************************************************************/
-
+
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
@@ -142,56 +81,6 @@ extern void stream_semtake(FAR struct streamlist *list);
extern void stream_semgive(FAR struct streamlist *list);
#endif
-/* Defined in lib_memoutstream.c */
-
-extern void lib_memoutstream(FAR struct lib_memoutstream_s *memoutstream,
- FAR char *bufstart, int buflen);
-
-/* Defined in lib_meminstream.c */
-
-extern void lib_meminstream(FAR struct lib_meminstream_s *meminstream,
- FAR char *bufstart, int buflen);
-
-/* Defined in lib_stdinstream.c */
-
-extern void lib_stdinstream(FAR struct lib_stdinstream_s *stdinstream,
- FAR FILE *stream);
-
-/* Defined in lib_stdoutstream.c */
-
-extern void lib_stdoutstream(FAR struct lib_stdoutstream_s *stdoutstream,
- FAR FILE *stream);
-
-/* Defined in lib_rawinstream.c */
-
-extern void lib_rawinstream(FAR struct lib_rawinstream_s *rawinstream,
- int fd);
-
-/* Defined in lib_rawoutstream.c */
-
-extern void lib_rawoutstream(FAR struct lib_rawoutstream_s *rawoutstream,
- int fd);
-
-/* Defined in lib_lowinstream.c */
-
-#ifdef CONFIG_ARCH_LOWGETC
-extern void lib_lowinstream(FAR struct lib_instream_s *lowinstream);
-#endif
-
-/* Defined in lib_lowoutstream.c */
-
-#ifdef CONFIG_ARCH_LOWPUTC
-extern void lib_lowoutstream(FAR struct lib_outstream_s *lowoutstream);
-#endif
-
-/* Defined in lib_nullinstream.c */
-
-extern void lib_nullinstream(FAR struct lib_instream_s *nullinstream);
-
-/* Defined in lib_nulloutstream.c */
-
-extern void lib_nulloutstream(FAR struct lib_outstream_s *nulloutstream);
-
/* Defined in lib_libsprintf.c */
extern int lib_sprintf (FAR struct lib_outstream_s *obj,
diff --git a/nuttx/lib/lib_meminstream.c b/nuttx/lib/lib_meminstream.c
index ccbf1cec4..5453d2775 100644
--- a/nuttx/lib/lib_meminstream.c
+++ b/nuttx/lib/lib_meminstream.c
@@ -73,7 +73,7 @@ static int meminstream_getc(FAR struct lib_instream_s *this)
****************************************************************************/
void lib_meminstream(FAR struct lib_meminstream_s *meminstream,
- FAR char *bufstart, int buflen)
+ FAR const char *bufstart, int buflen)
{
meminstream->public.get = meminstream_getc;
meminstream->public.nget = 0; /* Will be buffer index */