2008-09-01 22:35:41 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* include/stdio.h
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
2021-02-03 11:33:49 +01:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
2021-02-03 11:33:49 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
2021-02-03 11:33:49 +01:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
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 <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 */
|
|
|
|
|
2020-11-09 06:32:59 +01:00
|
|
|
#define stdin (&nxsched_get_streams()->sl_std[0])
|
|
|
|
#define stdout (&nxsched_get_streams()->sl_std[1])
|
|
|
|
#define stderr (&nxsched_get_streams()->sl_std[2])
|
2007-02-18 00:21:28 +01:00
|
|
|
|
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) */
|
|
|
|
|
2020-05-06 11:24:42 +02:00
|
|
|
void clearerr(FAR FILE *stream);
|
2013-03-09 22:12:20 +01:00
|
|
|
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);
|
2020-05-06 11:24:42 +02:00
|
|
|
FAR char *fgets(FAR char *s, int n, FAR FILE *stream);
|
2013-03-09 22:12:20 +01:00
|
|
|
FAR FILE *fopen(FAR const char *path, FAR const char *type);
|
2020-11-05 09:07:40 +01:00
|
|
|
int fprintf(FAR FILE *stream, FAR const IPTR char *format, ...)
|
|
|
|
printflike(2, 3);
|
2013-03-09 22:12:20 +01:00
|
|
|
int fputc(int c, FAR FILE *stream);
|
2020-06-02 20:57:39 +02:00
|
|
|
int fputs(FAR const IPTR char *s, FAR FILE *stream);
|
2013-03-09 22:12:20 +01:00
|
|
|
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);
|
2020-11-17 07:46:24 +01:00
|
|
|
int fscanf(FAR FILE *stream, FAR const IPTR char *fmt, ...)
|
|
|
|
scanflike(2, 3);
|
2013-03-09 22:12:20 +01:00
|
|
|
int fseek(FAR FILE *stream, long int offset, int whence);
|
2020-06-26 08:40:13 +02:00
|
|
|
int fseeko(FAR FILE *stream, off_t offset, int whence);
|
2013-03-09 22:12:20 +01:00
|
|
|
int fsetpos(FAR FILE *stream, FAR fpos_t *pos);
|
|
|
|
long ftell(FAR FILE *stream);
|
2020-06-26 08:40:13 +02:00
|
|
|
off_t ftello(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);
|
2020-06-26 08:40:13 +02:00
|
|
|
int getc(FAR FILE *stream);
|
|
|
|
int getchar(void);
|
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);
|
2020-06-24 06:54:30 +02:00
|
|
|
void rewind(FAR FILE *stream);
|
2020-07-19 17:23:26 +02:00
|
|
|
|
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);
|
2020-07-19 17:23:26 +02:00
|
|
|
|
2013-03-09 22:12:20 +01:00
|
|
|
int ungetc(int c, FAR FILE *stream);
|
2012-11-01 16:00:26 +01:00
|
|
|
|
2020-04-30 20:43:08 +02: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);
|
2020-11-05 09:07:40 +01:00
|
|
|
int printf(FAR const IPTR char *fmt, ...) printflike(1, 2);
|
2020-06-26 08:40:13 +02:00
|
|
|
int putc(int c, FAR FILE *stream);
|
|
|
|
int putchar(int c);
|
2020-06-02 20:57:39 +02:00
|
|
|
int puts(FAR const IPTR char *s);
|
2013-03-09 22:12:20 +01:00
|
|
|
int rename(FAR const char *oldpath, FAR const char *newpath);
|
2020-11-05 09:07:40 +01:00
|
|
|
int sprintf(FAR char *buf, FAR const IPTR char *fmt, ...)
|
|
|
|
printflike(2, 3);
|
|
|
|
int asprintf(FAR char **ptr, FAR const IPTR char *fmt, ...)
|
|
|
|
printflike(2, 3);
|
2016-01-05 17:29:29 +01:00
|
|
|
int snprintf(FAR char *buf, size_t size,
|
2020-11-05 09:07:40 +01:00
|
|
|
FAR const IPTR char *fmt, ...) printflike(3, 4);
|
2020-11-17 07:46:24 +01:00
|
|
|
int sscanf(FAR const char *buf, FAR const IPTR char *fmt, ...)
|
|
|
|
scanflike(2, 3);
|
2013-03-09 22:12:20 +01:00
|
|
|
|
2020-11-17 07:46:24 +01:00
|
|
|
int scanf(FAR const IPTR char *fmt, ...) scanflike(1, 2);
|
2020-11-05 09:07:40 +01:00
|
|
|
int vasprintf(FAR char **ptr, FAR const IPTR char *fmt, va_list ap)
|
|
|
|
printflike(2, 0);
|
2019-02-16 00:31:58 +01:00
|
|
|
int vfprintf(FAR FILE *stream, FAR const IPTR char *fmt,
|
2020-11-05 09:07:40 +01:00
|
|
|
va_list ap) printflike(2, 0);
|
2020-11-17 07:46:24 +01:00
|
|
|
int vfscanf(FAR FILE *stream, FAR const IPTR char *fmt, va_list ap)
|
|
|
|
scanflike(2, 0);
|
2020-11-05 09:07:40 +01:00
|
|
|
int vprintf(FAR const IPTR char *fmt, va_list ap) printflike(1, 0);
|
2020-11-17 07:46:24 +01:00
|
|
|
int vscanf(FAR const IPTR char *fmt, va_list ap) scanflike(1, 0);
|
2019-02-16 00:31:58 +01:00
|
|
|
int vsnprintf(FAR char *buf, size_t size, FAR const IPTR char *fmt,
|
2020-11-05 09:07:40 +01:00
|
|
|
va_list ap) printflike(3, 0);
|
|
|
|
int vsprintf(FAR char *buf, FAR const IPTR char *fmt, va_list ap)
|
|
|
|
printflike(2, 0);
|
2020-11-17 07:46:24 +01:00
|
|
|
int vsscanf(FAR const char *buf, FAR const IPTR char *fmt, va_list ap)
|
|
|
|
scanflike(2, 0);
|
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);
|
2020-11-05 09:07:40 +01:00
|
|
|
int dprintf(int fd, FAR const IPTR char *fmt, ...) printflike(2, 3);
|
|
|
|
int vdprintf(int fd, FAR const IPTR char *fmt, va_list ap)
|
|
|
|
printflike(2, 0);
|
2013-06-02 23:49:52 +02:00
|
|
|
|
|
|
|
/* Operations on paths */
|
|
|
|
|
2020-06-02 16:53:45 +02:00
|
|
|
FAR FILE *tmpfile(void);
|
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
|
2020-04-29 21:21:23 +02:00
|
|
|
* apps/system/popen for implementation.
|
2018-08-17 18:40:59 +02:00
|
|
|
*/
|
|
|
|
|
2020-04-29 21:21:23 +02:00
|
|
|
#ifndef __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 */
|