Tizen RT Libs&Environment  v1.0 D5
stdio.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright 2016 Samsung Electronics All Rights Reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing,
12  * software distributed under the License is distributed on an
13  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14  * either express or implied. See the License for the specific
15  * language governing permissions and limitations under the License.
16  *
17  ****************************************************************************/
18 /****************************************************************************
19  * include/stdio.h
20  *
21  * Copyright (C) 2007-2009, 2011, 2013-2014 Gregory Nutt. All rights reserved.
22  * Author: Gregory Nutt <gnutt@nuttx.org>
23  *
24  * Redistribution and use in source and binary forms, with or without
25  * modification, are permitted provided that the following conditions
26  * are met:
27  *
28  * 1. Redistributions of source code must retain the above copyright
29  * notice, this list of conditions and the following disclaimer.
30  * 2. Redistributions in binary form must reproduce the above copyright
31  * notice, this list of conditions and the following disclaimer in
32  * the documentation and/or other materials provided with the
33  * distribution.
34  * 3. Neither the name NuttX nor the names of its contributors may be
35  * used to endorse or promote products derived from this software
36  * without specific prior written permission.
37  *
38  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
39  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
40  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
41  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
42  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
43  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
44  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
45  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
46  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
47  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
48  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
49  * POSSIBILITY OF SUCH DAMAGE.
50  *
51  ****************************************************************************/
64 
67 #ifndef __INCLUDE_STDIO_H
68 #define __INCLUDE_STDIO_H
69 
70 /****************************************************************************
71  * Included Files
72  ****************************************************************************/
73 
74 #include <tinyara/config.h>
75 
76 #include <sys/types.h>
77 #include <stdarg.h>
78 #include <sched.h>
79 #include <semaphore.h>
80 #include <time.h>
81 
82 #include <tinyara/fs/fs.h>
83 
84 /****************************************************************************
85  * Pre-processor Definitions
86  ****************************************************************************/
87 
88 /* File System Definitions **************************************************/
89 
90 #define FILENAME_MAX _POSIX_NAME_MAX
91 
92 /* File system error values *************************************************/
93 
94 #define EOF (-1)
95 
96 /* The first three _iob entries are reserved for standard I/O */
97 
98 #define stdin (&sched_getstreams()->sl_streams[0])
99 #define stdout (&sched_getstreams()->sl_streams[1])
100 #define stderr (&sched_getstreams()->sl_streams[2])
101 
102 /* These APIs are not implemented and/or can be synthesized from
103  * supported APIs.
104  */
105 
110 #define putc(c, s) fputc((c), (s))
111 
115 #define putchar(c) fputc(c, stdout)
116 
120 #define getc(s) fgetc(s)
121 
125 #define getchar() fgetc(stdin)
126 
130 #define rewind(s) ((void)fseek((s), 0, SEEK_SET))
131 
135 /* Path to the directory where temporary files can be created */
136 
137 #ifndef CONFIG_LIBC_TMPDIR
138 #define CONFIG_LIBC_TMPDIR "/tmp"
139 #endif
140 
141 #define P_tmpdir CONFIG_LIBC_TMPDIR
142 
143 /* Maximum size of character array to hold tmpnam() output. */
144 
145 #ifndef CONFIG_LIBC_MAX_TMPFILE
146 #define CONFIG_LIBC_MAX_TMPFILE 32
147 #endif
148 
149 #define L_tmpnam CONFIG_LIBC_MAX_TMPFILE
150 
151 /* the maximum number of unique temporary file names that can be generated */
152 
153 #define TMP_MAX 56800235584ull
154 
155 /****************************************************************************
156  * Public Type Definitions
157  ****************************************************************************/
158 
159 /* Streams */
160 
161 typedef struct file_struct FILE;
162 
163 /****************************************************************************
164  * Public Variables
165  ****************************************************************************/
166 
167 #undef EXTERN
168 #if defined(__cplusplus)
169 #define EXTERN extern "C"
170 extern "C" {
171 #else
172 #define EXTERN extern
173 #endif
174 
175 /****************************************************************************
176  * Public Function Prototypes
177  ****************************************************************************/
178 
179 /* ANSI-like File System Interfaces */
180 
181 /* Operations on streams (FILE) */
186 void clearerr(register FILE *stream);
194 int fclose(FAR FILE *stream);
199 int fflush(FAR FILE *stream);
204 int feof(FAR FILE *stream);
209 int ferror(FAR FILE *stream);
214 int fileno(FAR FILE *stream);
219 int fgetc(FAR FILE *stream);
224 int fgetpos(FAR FILE *stream, FAR fpos_t *pos);
229 char *fgets(FAR char *s, int n, FAR FILE *stream);
234 FAR FILE *fopen(FAR const char *path, FAR const char *type);
239 int fprintf(FAR FILE *stream, FAR const char *format, ...);
244 int fputc(int c, FAR FILE *stream);
249 int fputs(FAR const char *s, FAR FILE *stream);
254 size_t fread(FAR void *ptr, size_t size, size_t n_items, FAR FILE *stream);
259 int fseek(FAR FILE *stream, long int offset, int whence);
264 int fsetpos(FAR FILE *stream, FAR fpos_t *pos);
269 long ftell(FAR FILE *stream);
274 size_t fwrite(FAR const void *ptr, size_t size, size_t n_items, FAR FILE *stream);
279 FAR char *gets(FAR char *s);
304 FAR char *gets_s(FAR char *s, rsize_t n);
309 int ungetc(int c, FAR FILE *stream);
310 
311 /* Operations on the stdout stream, buffers, paths, and the whole printf-family */
312 
317 int printf(FAR const char *format, ...);
322 int puts(FAR const char *s);
327 int rename(FAR const char *oldpath, FAR const char *newpath);
335 int sprintf(FAR char *buf, FAR const char *format, ...);
340 int asprintf(FAR char **ptr, FAR const char *fmt, ...);
345 int snprintf(FAR char *buf, size_t size, FAR const char *format, ...);
350 int sscanf(FAR const char *buf, FAR const char *fmt, ...);
355 void perror(FAR const char *s);
356 
361 int vprintf(FAR const char *format, va_list ap);
366 int vfprintf(FAR FILE *stream, const char *format, va_list ap);
371 int vsprintf(FAR char *buf, const char *format, va_list ap);
376 int avsprintf(FAR char **ptr, const char *fmt, va_list ap);
384 int vsnprintf(FAR char *buf, size_t size, const char *format, va_list ap);
389 int vsscanf(FAR const char *buf, FAR const char *s, va_list ap);
390 
391 /* Operations on file descriptors including:
392  *
393  * POSIX-like File System Interfaces (fdopen), and
394  * Extensions from the Open Group Technical Standard, 2006, Extended API Set
395  * Part 1 (dprintf and vdprintf)
396  */
401 FAR FILE *fdopen(int fd, FAR const char *type);
406 int dprintf(int fd, FAR const char *fmt, ...);
410 int vdprintf(int fd, FAR const char *fmt, va_list ap);
411 
412 /* Operations on paths */
416 int statfs(FAR const char *path, FAR struct statfs *buf);
420 FAR char *tmpnam(FAR char *s);
424 FAR char *tempnam(FAR const char *dir, FAR const char *pfx);
429 #undef EXTERN
430 #if defined(__cplusplus)
431 }
432 #endif
433 
434 #endif /* __INCLUDE_STDIO_H */
435 // end of STDIO_LIBC
size_t fread(FAR void *ptr, size_t size, size_t n_items, FAR FILE *stream)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
int ungetc(int c, FAR FILE *stream)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
int sscanf(FAR const char *buf, FAR const char *fmt,...)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
FAR char * gets_s(FAR char *s, rsize_t n)
reads a line from stdin into the buffer
int vprintf(FAR const char *format, va_list ap)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
int fflush(FAR FILE *stream)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
int ferror(FAR FILE *stream)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
int fclose(FAR FILE *stream)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
int fseek(FAR FILE *stream, long int offset, int whence)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
int vsnprintf(FAR char *buf, size_t size, const char *format, va_list ap)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
void perror(FAR const char *s)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
int puts(FAR const char *s)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
int fprintf(FAR FILE *stream, FAR const char *format,...)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
int asprintf(FAR char **ptr, FAR const char *fmt,...)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
int printf(FAR const char *format,...)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
int fgetc(FAR FILE *stream)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
FAR FILE * fdopen(int fd, FAR const char *type)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
int fputc(int c, FAR FILE *stream)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
int vfprintf(FAR FILE *stream, const char *format, va_list ap)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
long ftell(FAR FILE *stream)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
int vsscanf(FAR const char *buf, FAR const char *s, va_list ap)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
int snprintf(FAR char *buf, size_t size, FAR const char *format,...)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
FAR FILE * fopen(FAR const char *path, FAR const char *type)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
struct file_struct FILE
Definition: stdio.h:161
Semaphore APIs.
int fsetpos(FAR FILE *stream, FAR fpos_t *pos)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
int fileno(FAR FILE *stream)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
FAR char * gets(FAR char *s)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
int fgetpos(FAR FILE *stream, FAR fpos_t *pos)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
int sprintf(FAR char *buf, FAR const char *format,...)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
size_t fwrite(FAR const void *ptr, size_t size, size_t n_items, FAR FILE *stream)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
char * fgets(FAR char *s, int n, FAR FILE *stream)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
int feof(FAR FILE *stream)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
int fputs(FAR const char *s, FAR FILE *stream)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
int vsprintf(FAR char *buf, const char *format, va_list ap)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)