*
****************************************************************************/
/****************************************************************************
- * libc/stdio/lib_rawsistream.c
+ * libc/stdio/lib_rawinstream.c
*
- * Copyright (C) 2014 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2009, 2011-2012, 2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
****************************************************************************/
/****************************************************************************
- * Name: rawsistream_getc
+ * Name: rawinstream_getc
****************************************************************************/
-static int rawsistream_getc(FAR struct lib_sistream_s *this)
+static int rawinstream_getc(FAR struct lib_instream_s *this)
{
- FAR struct lib_rawsistream_s *rthis = (FAR struct lib_rawsistream_s *)this;
+ FAR struct lib_rawinstream_s *rthis = (FAR struct lib_rawinstream_s *)this;
int nwritten;
char ch;
}
/****************************************************************************
- * Name: rawsistream_seek
- ****************************************************************************/
-
-static off_t rawsistream_seek(FAR struct lib_sistream_s *this, off_t offset, int whence)
-{
- FAR struct lib_rawsistream_s *mthis = (FAR struct lib_rawsistream_s *)this;
-
- DEBUGASSERT(this);
- return lseek(mthis->fd, offset, whence);
-}
-
-/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
- * Name: lib_rawsistream
+ * Name: lib_rawinstream
*
* Description:
* Initializes a stream for use with a file descriptor.
*
* Input parameters:
* instream - User allocated, uninitialized instance of struct
- * lib_rawsistream_s to be initialized.
+ * lib_rawinstream_s to be initialized.
* fd - User provided file/socket descriptor (must have been opened
* for the correct access).
*
*
****************************************************************************/
-void lib_rawsistream(FAR struct lib_rawsistream_s *instream, int fd)
+void lib_rawinstream(FAR struct lib_rawinstream_s *instream, int fd)
{
- instream->public.get = rawsistream_getc;
- instream->public.seek = rawsistream_seek;
+ instream->public.get = rawinstream_getc;
instream->public.nget = 0;
instream->fd = fd;
}
*
****************************************************************************/
/****************************************************************************
- * libc/stdio/lib_rawsostream.c
+ * libc/stdio/lib_rawoutstream.c
*
- * Copyright (C) 2014 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2009, 2011-2012, 2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
****************************************************************************/
/****************************************************************************
- * Name: rawsostream_putc
+ * Name: rawoutstream_putc
****************************************************************************/
-static void rawsostream_putc(FAR struct lib_sostream_s *this, int ch)
+static void rawoutstream_putc(FAR struct lib_outstream_s *this, int ch)
{
- FAR struct lib_rawsostream_s *rthis = (FAR struct lib_rawsostream_s *)this;
- int nwritten;
+ FAR struct lib_rawoutstream_s *rthis = (FAR struct lib_rawoutstream_s *)this;
char buffer = ch;
+ int nwritten;
+ int errcode;
DEBUGASSERT(this && rthis->fd >= 0);
}
/* The only expected error is EINTR, meaning that the write operation
- * was awakened by a signal. Zero would not be a valid return value
- * from write().
+ * was awakened by a signal. Zero or values > 1 would not be valid
+ * return values from write().
*/
+ errcode = get_errno();
DEBUGASSERT(nwritten < 0);
- } while (get_errno() == EINTR);
-}
-
-/****************************************************************************
- * Name: rawsostream_seek
- ****************************************************************************/
-
-static off_t rawsostream_seek(FAR struct lib_sostream_s *this, off_t offset, int whence)
-{
- FAR struct lib_rawsostream_s *mthis = (FAR struct lib_rawsostream_s *)this;
-
- DEBUGASSERT(this);
- return lseek(mthis->fd, offset, whence);
+ } while (errcode == EINTR);
}
/****************************************************************************
****************************************************************************/
/****************************************************************************
- * Name: lib_rawsostream
+ * Name: lib_rawoutstream
*
* Description:
* Initializes a stream for use with a file descriptor.
*
* Input parameters:
* outstream - User allocated, uninitialized instance of struct
- * lib_rawsostream_s to be initialized.
+ * lib_rawoutstream_s to be initialized.
* fd - User provided file/socket descriptor (must have been opened
* for write access).
*
*
****************************************************************************/
-void lib_rawsostream(FAR struct lib_rawsostream_s *outstream, int fd)
+void lib_rawoutstream(FAR struct lib_rawoutstream_s *outstream, int fd)
{
- outstream->public.put = rawsostream_putc;
+ outstream->public.put = rawoutstream_putc;
#ifdef CONFIG_STDIO_LINEBUFFER
- outstream->public.flush = lib_snoflush;
+ outstream->public.flush = lib_noflush;
#endif
- outstream->public.seek = rawsostream_seek;
outstream->public.nput = 0;
outstream->fd = fd;
}
*
****************************************************************************/
/****************************************************************************
- * libc/stdio/lib_rawinstream.c
+ * libc/stdio/lib_rawsistream.c
*
- * Copyright (C) 2007-2009, 2011-2012, 2014 Gregory Nutt. All rights reserved.
+ * 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
****************************************************************************/
/****************************************************************************
- * Name: rawinstream_getc
+ * Name: rawsistream_getc
****************************************************************************/
-static int rawinstream_getc(FAR struct lib_instream_s *this)
+static int rawsistream_getc(FAR struct lib_sistream_s *this)
{
- FAR struct lib_rawinstream_s *rthis = (FAR struct lib_rawinstream_s *)this;
+ FAR struct lib_rawsistream_s *rthis = (FAR struct lib_rawsistream_s *)this;
int nwritten;
char ch;
}
/****************************************************************************
+ * Name: rawsistream_seek
+ ****************************************************************************/
+
+static off_t rawsistream_seek(FAR struct lib_sistream_s *this, off_t offset, int whence)
+{
+ FAR struct lib_rawsistream_s *mthis = (FAR struct lib_rawsistream_s *)this;
+
+ DEBUGASSERT(this);
+ return lseek(mthis->fd, offset, whence);
+}
+
+/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
- * Name: lib_rawinstream
+ * Name: lib_rawsistream
*
* Description:
* Initializes a stream for use with a file descriptor.
*
* Input parameters:
* instream - User allocated, uninitialized instance of struct
- * lib_rawinstream_s to be initialized.
+ * lib_rawsistream_s to be initialized.
* fd - User provided file/socket descriptor (must have been opened
* for the correct access).
*
*
****************************************************************************/
-void lib_rawinstream(FAR struct lib_rawinstream_s *instream, int fd)
+void lib_rawsistream(FAR struct lib_rawsistream_s *instream, int fd)
{
- instream->public.get = rawinstream_getc;
+ instream->public.get = rawsistream_getc;
+ instream->public.seek = rawsistream_seek;
instream->public.nget = 0;
instream->fd = fd;
}
*
****************************************************************************/
/****************************************************************************
- * libc/stdio/lib_rawoutstream.c
+ * libc/stdio/lib_rawsostream.c
*
- * Copyright (C) 2007-2009, 2011-2012, 2014 Gregory Nutt. All rights reserved.
+ * 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
****************************************************************************/
/****************************************************************************
- * Name: rawoutstream_putc
+ * Name: rawsostream_putc
****************************************************************************/
-static void rawoutstream_putc(FAR struct lib_outstream_s *this, int ch)
+static void rawsostream_putc(FAR struct lib_sostream_s *this, int ch)
{
- FAR struct lib_rawoutstream_s *rthis = (FAR struct lib_rawoutstream_s *)this;
- char buffer = ch;
+ FAR struct lib_rawsostream_s *rthis = (FAR struct lib_rawsostream_s *)this;
int nwritten;
- int errcode;
+ char buffer = ch;
DEBUGASSERT(this && rthis->fd >= 0);
}
/* The only expected error is EINTR, meaning that the write operation
- * was awakened by a signal. Zero or values > 1 would not be valid
- * return values from write().
+ * was awakened by a signal. Zero would not be a valid return value
+ * from write().
*/
- errcode = get_errno();
DEBUGASSERT(nwritten < 0);
- } while (errcode == EINTR);
+ } while (get_errno() == EINTR);
+}
+
+/****************************************************************************
+ * Name: rawsostream_seek
+ ****************************************************************************/
+
+static off_t rawsostream_seek(FAR struct lib_sostream_s *this, off_t offset, int whence)
+{
+ FAR struct lib_rawsostream_s *mthis = (FAR struct lib_rawsostream_s *)this;
+
+ DEBUGASSERT(this);
+ return lseek(mthis->fd, offset, whence);
}
/****************************************************************************
****************************************************************************/
/****************************************************************************
- * Name: lib_rawoutstream
+ * Name: lib_rawsostream
*
* Description:
* Initializes a stream for use with a file descriptor.
*
* Input parameters:
* outstream - User allocated, uninitialized instance of struct
- * lib_rawoutstream_s to be initialized.
+ * lib_rawsostream_s to be initialized.
* fd - User provided file/socket descriptor (must have been opened
* for write access).
*
*
****************************************************************************/
-void lib_rawoutstream(FAR struct lib_rawoutstream_s *outstream, int fd)
+void lib_rawsostream(FAR struct lib_rawsostream_s *outstream, int fd)
{
- outstream->public.put = rawoutstream_putc;
+ outstream->public.put = rawsostream_putc;
#ifdef CONFIG_STDIO_LINEBUFFER
- outstream->public.flush = lib_noflush;
+ outstream->public.flush = lib_snoflush;
#endif
+ outstream->public.seek = rawsostream_seek;
outstream->public.nput = 0;
outstream->fd = fd;
}