2008-09-01 22:35:41 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* include/stdio.h
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
2019-02-16 00:31:58 +01:00
|
|
|
* Copyright (C) 2007-2009, 2011, 2013-2015, 2018-2019 Gregory Nutt. All
|
|
|
|
* rights reserved.
|
2012-07-17 05:58:11 +02:00
|
|
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
|
|
|
* 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.
|
2008-09-01 22:35:41 +02:00
|
|
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
2007-02-18 00:21:28 +01:00
|
|
|
* 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.
|
|
|
|
*
|
2008-09-01 22:35:41 +02:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2009-07-12 22:48:44 +02:00
|
|
|
#ifndef __INCLUDE_STDIO_H
|
|
|
|
#define __INCLUDE_STDIO_H
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2008-09-01 22:35:41 +02:00
|
|
|
/****************************************************************************
|
2007-02-18 00:21:28 +01:00
|
|
|
* Included Files
|
2008-09-01 22:35:41 +02:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
2007-12-31 00:34:20 +01:00
|
|
|
|
2007-02-18 00:21:28 +01:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <sched.h>
|
|
|
|
#include <semaphore.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
2012-03-21 19:01:07 +01:00
|
|
|
#include <nuttx/fs/fs.h>
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2008-09-01 22:35:41 +02:00
|
|
|
/****************************************************************************
|
2009-12-15 00:32:23 +01:00
|
|
|
* Pre-processor Definitions
|
2008-09-01 22:35:41 +02:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2008-09-01 22:35:41 +02:00
|
|
|
/* File System Definitions **************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2014-08-12 14:18:22 +02:00
|
|
|
#define FILENAME_MAX _POSIX_NAME_MAX
|
|
|
|
|
2017-02-09 16:24:44 +01:00
|
|
|
/* The (default) size of the I/O buffers */
|
2015-11-18 21:09:43 +01:00
|
|
|
|
2017-02-09 16:24:44 +01:00
|
|
|
#if defined(CONFIG_STDIO_BUFFER_SIZE) && CONFIG_STDIO_BUFFER_SIZE > 0
|
|
|
|
# define BUFSIZ CONFIG_STDIO_BUFFER_SIZE
|
|
|
|
#else
|
|
|
|
# define BUFSIZ 64
|
2015-11-18 21:09:43 +01:00
|
|
|
#endif
|
|
|
|
|
2017-02-08 17:33:18 +01:00
|
|
|
/* The following three definitions are for ANSI C, used by setvbuf */
|
|
|
|
|
|
|
|
#define _IOFBF 0 /* Fully buffered */
|
|
|
|
#define _IOLBF 1 /* Line buffered */
|
|
|
|
#define _IONBF 2 /* Unbuffered */
|
|
|
|
|
2015-11-18 21:09:43 +01:00
|
|
|
/* File system error values */
|
2007-02-18 00:21:28 +01:00
|
|
|
|
|
|
|
#define EOF (-1)
|
|
|
|
|
|
|
|
/* The first three _iob entries are reserved for standard I/O */
|
|
|
|
|
2017-02-08 17:33:18 +01:00
|
|
|
#define stdin (&sched_getstreams()->sl_streams[0])
|
|
|
|
#define stdout (&sched_getstreams()->sl_streams[1])
|
|
|
|
#define stderr (&sched_getstreams()->sl_streams[2])
|
2007-02-18 00:21:28 +01:00
|
|
|
|
|
|
|
/* These APIs are not implemented and/or can be synthesized from
|
|
|
|
* supported APIs.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define putc(c,s) fputc((c),(s))
|
|
|
|
#define putchar(c) fputc(c, stdout)
|
|
|
|
#define getc(s) fgetc(s)
|
|
|
|
#define getchar() fgetc(stdin)
|
|
|
|
#define rewind(s) ((void)fseek((s),0,SEEK_SET))
|
|
|
|
|
2014-11-05 17:43:17 +01:00
|
|
|
/* Path to the directory where temporary files can be created */
|
|
|
|
|
|
|
|
#ifndef CONFIG_LIBC_TMPDIR
|
|
|
|
# define CONFIG_LIBC_TMPDIR "/tmp"
|
|
|
|
#endif
|
|
|
|
|
2017-02-08 17:33:18 +01:00
|
|
|
#define P_tmpdir CONFIG_LIBC_TMPDIR
|
2014-11-05 17:43:17 +01:00
|
|
|
|
|
|
|
/* Maximum size of character array to hold tmpnam() output. */
|
|
|
|
|
|
|
|
#ifndef CONFIG_LIBC_MAX_TMPFILE
|
|
|
|
# define CONFIG_LIBC_MAX_TMPFILE 32
|
|
|
|
#endif
|
|
|
|
|
2017-02-08 17:33:18 +01:00
|
|
|
#define L_tmpnam CONFIG_LIBC_MAX_TMPFILE
|
2014-11-05 17:43:17 +01:00
|
|
|
|
2015-11-18 21:09:43 +01:00
|
|
|
/* The maximum number of unique temporary file names that can be generated */
|
2014-11-05 17:43:17 +01:00
|
|
|
|
|
|
|
#define TMP_MAX 56800235584ull
|
|
|
|
|
2008-09-01 22:35:41 +02:00
|
|
|
/****************************************************************************
|
2007-02-18 00:21:28 +01:00
|
|
|
* Public Type Definitions
|
2008-09-01 22:35:41 +02:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
|
|
|
/* Streams */
|
|
|
|
|
2008-11-07 19:16:01 +01:00
|
|
|
typedef struct file_struct FILE;
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2008-09-01 22:35:41 +02:00
|
|
|
/****************************************************************************
|
2015-10-03 00:30:35 +02:00
|
|
|
* Public Data
|
2008-09-01 22:35:41 +02:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
|
|
|
#undef EXTERN
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
#define EXTERN extern "C"
|
2013-03-09 22:12:20 +01:00
|
|
|
extern "C"
|
|
|
|
{
|
2007-02-18 00:21:28 +01:00
|
|
|
#else
|
|
|
|
#define EXTERN extern
|
|
|
|
#endif
|
|
|
|
|
2013-03-09 22:12:20 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Function Prototypes
|
|
|
|
****************************************************************************/
|
|
|
|
|
2007-02-18 00:21:28 +01:00
|
|
|
/* ANSI-like File System Interfaces */
|
|
|
|
|
2012-11-01 16:00:26 +01:00
|
|
|
/* Operations on streams (FILE) */
|
|
|
|
|
2013-03-09 22:12:20 +01:00
|
|
|
void clearerr(register FILE *stream);
|
|
|
|
int fclose(FAR FILE *stream);
|
|
|
|
int fflush(FAR FILE *stream);
|
|
|
|
int feof(FAR FILE *stream);
|
|
|
|
int ferror(FAR FILE *stream);
|
|
|
|
int fileno(FAR FILE *stream);
|
|
|
|
int fgetc(FAR FILE *stream);
|
|
|
|
int fgetpos(FAR FILE *stream, FAR fpos_t *pos);
|
|
|
|
char *fgets(FAR char *s, int n, FAR FILE *stream);
|
|
|
|
FAR FILE *fopen(FAR const char *path, FAR const char *type);
|
2016-01-05 17:29:29 +01:00
|
|
|
int fprintf(FAR FILE *stream, FAR const IPTR char *format, ...);
|
2013-03-09 22:12:20 +01:00
|
|
|
int fputc(int c, FAR FILE *stream);
|
|
|
|
int fputs(FAR const char *s, FAR FILE *stream);
|
|
|
|
size_t fread(FAR void *ptr, size_t size, size_t n_items, FAR FILE *stream);
|
2016-01-05 17:29:29 +01:00
|
|
|
FAR FILE *freopen(FAR const char *path, FAR const char *mode,
|
|
|
|
FAR FILE *stream);
|
2019-02-16 00:31:58 +01:00
|
|
|
int fscanf(FAR FILE *stream, FAR const IPTR char *fmt, ...);
|
2013-03-09 22:12:20 +01:00
|
|
|
int fseek(FAR FILE *stream, long int offset, int whence);
|
|
|
|
int fsetpos(FAR FILE *stream, FAR fpos_t *pos);
|
|
|
|
long ftell(FAR FILE *stream);
|
2016-01-05 17:29:29 +01:00
|
|
|
size_t fwrite(FAR const void *ptr, size_t size, size_t n_items,
|
|
|
|
FAR FILE *stream);
|
2019-11-13 01:58:50 +01:00
|
|
|
ssize_t getdelim(FAR char **lineptr, size_t *n, int delimiter,
|
|
|
|
FAR FILE *stream);
|
|
|
|
ssize_t getline(FAR char **lineptr, size_t *n, FAR FILE *stream);
|
2013-03-09 22:12:20 +01:00
|
|
|
FAR char *gets(FAR char *s);
|
2014-01-07 23:27:45 +01:00
|
|
|
FAR char *gets_s(FAR char *s, rsize_t n);
|
2017-02-09 22:04:17 +01:00
|
|
|
void setbuf(FAR FILE *stream, FAR char *buf);
|
2017-02-08 17:33:18 +01:00
|
|
|
int setvbuf(FAR FILE *stream, FAR char *buffer, int mode, size_t size);
|
2013-03-09 22:12:20 +01:00
|
|
|
int ungetc(int c, FAR FILE *stream);
|
2012-11-01 16:00:26 +01:00
|
|
|
|
|
|
|
/* Operations on the stdout stream, buffers, paths, and the whole printf-family */
|
2007-03-10 01:17:29 +01:00
|
|
|
|
2019-02-16 00:31:58 +01:00
|
|
|
void perror(FAR const char *s);
|
|
|
|
int printf(FAR const IPTR char *fmt, ...);
|
2013-03-09 22:12:20 +01:00
|
|
|
int puts(FAR const char *s);
|
|
|
|
int rename(FAR const char *oldpath, FAR const char *newpath);
|
2019-02-16 00:31:58 +01:00
|
|
|
int sprintf(FAR char *buf, FAR const IPTR char *fmt, ...);
|
2016-01-05 17:29:29 +01:00
|
|
|
int asprintf (FAR char **ptr, FAR const IPTR char *fmt, ...);
|
|
|
|
int snprintf(FAR char *buf, size_t size,
|
2019-02-16 00:31:58 +01:00
|
|
|
FAR const IPTR char *fmt, ...);
|
Squashed commit of the following:
Author: Gregory Nutt <gnutt@nuttx.org>
TODO: Remove 'Missing fscanf()' bug
Clean up remaining complaints for tools/nxstyle
Apply tools/detab, rmcr, convert-comments, lowhex, and indent.sh to the new and highly modified files.
Author: Johannes <nivus.entwicklung@gmail.com>
- Move vscanf logic to lib_sscanf.c Switched to stream interface (tricky, because the old implementation used massive read ahead, which isn't suitable for streams, chars already read are gone).
- Added scanf and fscanf
- Added hh, h, and ll modifiers
- Fixes for standard compliance in scanf
- Fixes for standard compliance in strto... function family (don't consume single '-' or '+', allow sign in strotul(l))
2019-02-14 14:03:02 +01:00
|
|
|
int sscanf(FAR const char *buf, FAR const IPTR char *fmt, ...);
|
2013-03-09 22:12:20 +01:00
|
|
|
|
2019-02-16 00:31:58 +01:00
|
|
|
int scanf(FAR const IPTR char *fmt, ...);
|
2016-01-05 17:29:29 +01:00
|
|
|
int vasprintf(FAR char **ptr, FAR const IPTR char *fmt, va_list ap);
|
2019-02-16 00:31:58 +01:00
|
|
|
int vfprintf(FAR FILE *stream, FAR const IPTR char *fmt,
|
2016-01-05 17:29:29 +01:00
|
|
|
va_list ap);
|
2019-02-16 00:31:58 +01:00
|
|
|
int vfscanf(FAR FILE *stream, FAR const IPTR char *fmt, va_list ap);
|
2019-06-03 21:28:39 +02:00
|
|
|
int vprintf(FAR const IPTR char *fmt, va_list ap);
|
2019-02-16 00:31:58 +01:00
|
|
|
int vsnprintf(FAR char *buf, size_t size, FAR const IPTR char *fmt,
|
Squashed commit of the following:
Author: Gregory Nutt <gnutt@nuttx.org>
TODO: Remove 'Missing fscanf()' bug
Clean up remaining complaints for tools/nxstyle
Apply tools/detab, rmcr, convert-comments, lowhex, and indent.sh to the new and highly modified files.
Author: Johannes <nivus.entwicklung@gmail.com>
- Move vscanf logic to lib_sscanf.c Switched to stream interface (tricky, because the old implementation used massive read ahead, which isn't suitable for streams, chars already read are gone).
- Added scanf and fscanf
- Added hh, h, and ll modifiers
- Fixes for standard compliance in scanf
- Fixes for standard compliance in strto... function family (don't consume single '-' or '+', allow sign in strotul(l))
2019-02-14 14:03:02 +01:00
|
|
|
va_list ap);
|
2019-02-16 00:31:58 +01:00
|
|
|
int vsprintf(FAR char *buf, FAR const IPTR char *fmt, va_list ap);
|
|
|
|
int vsscanf(FAR const char *buf, FAR const char *fmt, va_list ap);
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2013-06-02 23:49:52 +02:00
|
|
|
/* Operations on file descriptors including:
|
|
|
|
*
|
|
|
|
* POSIX-like File System Interfaces (fdopen), and
|
|
|
|
* Extensions from the Open Group Technical Standard, 2006, Extended API Set
|
|
|
|
* Part 1 (dprintf and vdprintf)
|
|
|
|
*/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2013-03-09 22:12:20 +01:00
|
|
|
FAR FILE *fdopen(int fd, FAR const char *type);
|
2016-01-05 17:29:29 +01:00
|
|
|
int dprintf(int fd, FAR const IPTR char *fmt, ...);
|
|
|
|
int vdprintf(int fd, FAR const IPTR char *fmt, va_list ap);
|
2013-06-02 23:49:52 +02:00
|
|
|
|
|
|
|
/* Operations on paths */
|
|
|
|
|
2014-11-05 17:43:17 +01:00
|
|
|
FAR char *tmpnam(FAR char *s);
|
|
|
|
FAR char *tempnam(FAR const char *dir, FAR const char *pfx);
|
2016-08-25 16:40:34 +02:00
|
|
|
int remove(FAR const char *path);
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2018-08-17 18:40:59 +02:00
|
|
|
/* Shell operations. These are not actually implemented in the OS. See
|
|
|
|
* apps/system/open for implementation.
|
|
|
|
*/
|
|
|
|
|
2018-08-18 00:06:01 +02:00
|
|
|
#if !defined(CONFIG_BUILD_KERNEL) && !defined(__KERNEL__)
|
2018-08-17 18:40:59 +02:00
|
|
|
FILE *popen(FAR const char *command, FAR const char *mode);
|
|
|
|
int pclose(FILE *stream);
|
|
|
|
#endif
|
|
|
|
|
2007-02-18 00:21:28 +01:00
|
|
|
#undef EXTERN
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-07-12 22:48:44 +02:00
|
|
|
#endif /* __INCLUDE_STDIO_H */
|