diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-11-01 15:00:26 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-11-01 15:00:26 +0000 |
commit | a5b189950ec66b46f019fa3f3de54576f30e04d9 (patch) | |
tree | d9467a447f968359265794d97949c0edf7622b38 /nuttx/include | |
parent | 3ceeb8f9f0486bcebcdb8b6c008f8cfde5920354 (diff) | |
download | px4-firmware-a5b189950ec66b46f019fa3f3de54576f30e04d9.tar.gz px4-firmware-a5b189950ec66b46f019fa3f3de54576f30e04d9.tar.bz2 px4-firmware-a5b189950ec66b46f019fa3f3de54576f30e04d9.zip |
Add support for ferror(), feof(), and clearerr()
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5290 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/include')
-rw-r--r-- | nuttx/include/nuttx/fs/fs.h | 15 | ||||
-rw-r--r-- | nuttx/include/stdio.h | 7 |
2 files changed, 16 insertions, 6 deletions
diff --git a/nuttx/include/nuttx/fs/fs.h b/nuttx/include/nuttx/fs/fs.h index 81f81622f..aab4ae4be 100644 --- a/nuttx/include/nuttx/fs/fs.h +++ b/nuttx/include/nuttx/fs/fs.h @@ -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 */ @@ -284,6 +283,12 @@ struct file_struct 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 }; struct streamlist diff --git a/nuttx/include/stdio.h b/nuttx/include/stdio.h index e9218046c..8796861a4 100644 --- a/nuttx/include/stdio.h +++ b/nuttx/include/stdio.h @@ -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); |