source: mainline/uspace/lib/posix/stdio.h@ c196671

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since c196671 was af42a2b, checked in by Vojtech Horky <vojtechhorky@…>, 13 years ago

Put back includes in libposix (unbreak binutils build)

Apparently, POSIX programs expects that errno.h includes unistd.h and
that stdio.h defines NULL.

  • Property mode set to 100644
File size: 6.1 KB
Line 
1/*
2 * Copyright (c) 2011 Jiri Zarevucky
3 * Copyright (c) 2011 Petr Koupy
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * - Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * - Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * - The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30/** @addtogroup libposix
31 * @{
32 */
33/** @file Standard buffered input/output.
34 */
35
36#ifndef POSIX_STDIO_H_
37#define POSIX_STDIO_H_
38
39#include "stddef.h"
40#include "unistd.h"
41#include "libc/stdio.h"
42#include "sys/types.h"
43#include "libc/stdarg.h"
44#include "limits.h"
45
46/* Identifying the Terminal */
47#undef L_ctermid
48#define L_ctermid PATH_MAX
49extern char *posix_ctermid(char *s);
50
51/* Error Recovery */
52extern void posix_clearerr(FILE *stream);
53
54/* Input/Output */
55#undef putc
56#define putc fputc
57extern int posix_fputs(const char *restrict s, FILE *restrict stream);
58#undef getc
59#define getc fgetc
60extern int posix_ungetc(int c, FILE *stream);
61extern ssize_t posix_getdelim(char **restrict lineptr, size_t *restrict n,
62 int delimiter, FILE *restrict stream);
63extern ssize_t posix_getline(char **restrict lineptr, size_t *restrict n,
64 FILE *restrict stream);
65
66/* Opening Streams */
67extern FILE *posix_freopen(const char *restrict filename,
68 const char *restrict mode, FILE *restrict stream);
69
70/* Error Messages */
71extern void posix_perror(const char *s);
72
73/* File Positioning */
74typedef struct _posix_fpos posix_fpos_t;
75extern int posix_fsetpos(FILE *stream, const posix_fpos_t *pos);
76extern int posix_fgetpos(FILE *restrict stream, posix_fpos_t *restrict pos);
77extern int posix_fseek(FILE *stream, long offset, int whence);
78extern int posix_fseeko(FILE *stream, posix_off_t offset, int whence);
79extern long posix_ftell(FILE *stream);
80extern posix_off_t posix_ftello(FILE *stream);
81
82/* Flushing Buffers */
83extern int posix_fflush(FILE *stream);
84
85/* Formatted Output */
86extern int posix_dprintf(int fildes, const char *restrict format, ...)
87 PRINTF_ATTRIBUTE(2, 3);
88extern int posix_vdprintf(int fildes, const char *restrict format, va_list ap);
89extern int posix_sprintf(char *restrict s, const char *restrict format, ...)
90 PRINTF_ATTRIBUTE(2, 3);
91extern int posix_vsprintf(char *restrict s, const char *restrict format, va_list ap);
92
93/* Formatted Input */
94extern int posix_fscanf(
95 FILE *restrict stream, const char *restrict format, ...);
96extern int posix_vfscanf(
97 FILE *restrict stream, const char *restrict format, va_list arg);
98extern int posix_scanf(const char *restrict format, ...);
99extern int posix_vscanf(const char *restrict format, va_list arg);
100extern int posix_sscanf(
101 const char *restrict s, const char *restrict format, ...);
102extern int posix_vsscanf(
103 const char *restrict s, const char *restrict format, va_list arg);
104
105/* File Locking */
106extern void posix_flockfile(FILE *file);
107extern int posix_ftrylockfile(FILE *file);
108extern void posix_funlockfile(FILE *file);
109extern int posix_getc_unlocked(FILE *stream);
110extern int posix_getchar_unlocked(void);
111extern int posix_putc_unlocked(int c, FILE *stream);
112extern int posix_putchar_unlocked(int c);
113
114/* Deleting Files */
115extern int posix_remove(const char *path);
116
117/* Renaming Files */
118extern int posix_rename(const char *old, const char *new);
119
120/* Temporary Files */
121#undef L_tmpnam
122#define L_tmpnam PATH_MAX
123extern char *posix_tmpnam(char *s);
124extern char *posix_tempnam(const char *dir, const char *pfx);
125extern FILE *posix_tmpfile(void);
126
127#ifndef LIBPOSIX_INTERNAL
128 /* DEBUG macro does not belong to POSIX stdio.h. Its unconditional
129 * definition in the native stdio.h causes unexpected behaviour of
130 * applications which uses their own DEBUG macro (e.g. debugging
131 * output is printed even if not desirable). */
132 #undef DEBUG
133
134 #define ctermid posix_ctermid
135
136 #define clearerr posix_clearerr
137
138 #define fputs posix_fputs
139 #define ungetc posix_ungetc
140 #define getdelim posix_getdelim
141 #define getline posix_getline
142
143 #define freopen posix_freopen
144
145 #define perror posix_perror
146
147 #define fpos_t posix_fpos_t
148 #define fsetpos posix_fsetpos
149 #define fgetpos posix_fgetpos
150 #define fseek posix_fseek
151 #define fseeko posix_fseeko
152 #define ftell posix_ftell
153 #define ftello posix_ftello
154
155 #define fflush posix_fflush
156
157 #define dprintf posix_dprintf
158 #define vdprintf posix_vdprintf
159 #define sprintf posix_sprintf
160 #define vsprintf posix_vsprintf
161
162 #define fscanf posix_fscanf
163 #define vfscanf posix_vfscanf
164 #define vscanf posix_vscanf
165 #define scanf posix_scanf
166 #define sscanf posix_sscanf
167 #define vsscanf posix_vsscanf
168
169 #define flockfile posix_flockfile
170 #define ftrylockfile posix_ftrylockfile
171 #define funlockfile posix_funlockfile
172
173 #define getc_unlocked posix_getc_unlocked
174 #define getchar_unlocked posix_getchar_unlocked
175 #define putc_unlocked posix_putc_unlocked
176 #define putchar_unlocked posix_putchar_unlocked
177
178 #define remove posix_remove
179
180 #define rename posix_rename
181
182 #define tmpnam posix_tmpnam
183 #define tempnam posix_tempnam
184 #define tmpfile posix_tmpfile
185#endif
186
187#endif /* POSIX_STDIO_H_ */
188
189/** @}
190 */
Note: See TracBrowser for help on using the repository browser.