mirror of
https://github.com/apache/nuttx.git
synced 2026-05-23 14:58:13 +08:00
Add support for ferror(), feof(), and clearerr()
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5290 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
+10
-5
@@ -51,6 +51,10 @@
|
||||
/****************************************************************************
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
/* Stream flags for the fs_flags field of in struct file_struct */
|
||||
|
||||
#define __FS_FLAG_EOF (1 << 0) /* EOF detected by a read operation */
|
||||
#define __FS_FLAG_ERROR (1 << 1) /* Error detected by any operation */
|
||||
|
||||
/****************************************************************************
|
||||
* Type Definitions
|
||||
@@ -270,11 +274,6 @@ struct filelist
|
||||
struct file_struct
|
||||
{
|
||||
int fs_filedes; /* File descriptor associated with stream */
|
||||
uint16_t fs_oflags; /* Open mode flags */
|
||||
#if CONFIG_NUNGET_CHARS > 0
|
||||
uint8_t fs_nungotten; /* The number of characters buffered for ungetc */
|
||||
unsigned char fs_ungotten[CONFIG_NUNGET_CHARS];
|
||||
#endif
|
||||
#if CONFIG_STDIO_BUFFER_SIZE > 0
|
||||
sem_t fs_sem; /* For thread safety */
|
||||
pid_t fs_holder; /* Holder of sem */
|
||||
@@ -283,6 +282,12 @@ struct file_struct
|
||||
FAR unsigned char *fs_bufend; /* Pointer to 1 past end of buffer */
|
||||
FAR unsigned char *fs_bufpos; /* Current position in buffer */
|
||||
FAR unsigned char *fs_bufread; /* Pointer to 1 past last buffered read char. */
|
||||
#endif
|
||||
uint16_t fs_oflags; /* Open mode flags */
|
||||
uint8_t fs_flags; /* Stream flags */
|
||||
#if CONFIG_NUNGET_CHARS > 0
|
||||
uint8_t fs_nungotten; /* The number of characters buffered for ungetc */
|
||||
unsigned char fs_ungotten[CONFIG_NUNGET_CHARS];
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
+6
-1
@@ -102,6 +102,9 @@ extern "C" {
|
||||
|
||||
/* ANSI-like File System Interfaces */
|
||||
|
||||
/* Operations on streams (FILE) */
|
||||
|
||||
EXTERN void clearerr(register FILE *stream);
|
||||
EXTERN int fclose(FAR FILE *stream);
|
||||
EXTERN int fflush(FAR FILE *stream);
|
||||
EXTERN int feof(FAR FILE *stream);
|
||||
@@ -120,6 +123,9 @@ EXTERN int fsetpos(FAR FILE *stream, FAR fpos_t *pos);
|
||||
EXTERN long ftell(FAR FILE *stream);
|
||||
EXTERN size_t fwrite(FAR const void *ptr, size_t size, size_t n_items, FAR FILE *stream);
|
||||
EXTERN FAR char *gets(FAR char *s);
|
||||
EXTERN int ungetc(int c, FAR FILE *stream);
|
||||
|
||||
/* Operations on the stdout stream, buffers, paths, and the whole printf-family */
|
||||
|
||||
EXTERN int printf(const char *format, ...);
|
||||
EXTERN int puts(FAR const char *s);
|
||||
@@ -130,7 +136,6 @@ EXTERN int snprintf(FAR char *buf, size_t size, const char *format, ...);
|
||||
EXTERN int sscanf(const char *buf, const char *fmt, ...);
|
||||
EXTERN void perror(FAR const char *s);
|
||||
|
||||
EXTERN int ungetc(int c, FAR FILE *stream);
|
||||
EXTERN int vprintf(FAR const char *format, va_list ap);
|
||||
EXTERN int vfprintf(FAR FILE *stream, const char *format, va_list ap);
|
||||
EXTERN int vsprintf(FAR char *buf, const char *format, va_list ap);
|
||||
|
||||
Reference in New Issue
Block a user