source: mainline/uspace/lib/c/include/stdio.h@ 777832e

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 777832e was 777832e, checked in by Jiri Svoboda <jiri@…>, 7 years ago

fgetpos, fsetpos, perror.

  • Property mode set to 100644
File size: 5.2 KB
Line 
1/*
2 * Copyright (c) 2005 Martin Decky
3 * Copyright (c) 2018 Jiri Svoboda
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 libc
31 * @{
32 */
33/** @file
34 */
35
36#ifndef LIBC_STDIO_H_
37#define LIBC_STDIO_H_
38
39#include <offset.h>
40#include <stdarg.h>
41#include <io/verify.h>
42#include <_bits/size_t.h>
43#include <_bits/wchar_t.h>
44#include <_bits/wint_t.h>
45
46#define EOF (-1)
47
48#ifndef SEEK_SET
49#define SEEK_SET 0
50#endif
51
52#ifndef SEEK_CUR
53#define SEEK_CUR 1
54#endif
55
56#ifndef SEEK_END
57#define SEEK_END 2
58#endif
59
60/** Default size for stream I/O buffers */
61#define BUFSIZ 4096
62
63/** Max number of files that is guaranteed to be able to open at the same time */
64#define FOPEN_MAX VFS_MAX_OPEN_FILES
65
66/** Recommended size of fixed-size array for holding file names. */
67#define FILENAME_MAX 4096
68
69/** Forward declaration */
70struct _IO_FILE;
71typedef struct _IO_FILE FILE;
72
73/** File position */
74typedef struct {
75 off64_t pos;
76} fpos_t;
77
78extern FILE *stdin;
79extern FILE *stdout;
80extern FILE *stderr;
81
82/* Character and string input functions */
83#define getc fgetc
84extern int fgetc(FILE *);
85extern char *fgets(char *, int, FILE *);
86
87extern int getchar(void);
88
89/* Character and string output functions */
90#define putc fputc
91extern int fputc(int, FILE *);
92extern int fputs(const char *, FILE *);
93
94extern int putchar(int);
95extern int puts(const char *);
96
97extern int ungetc(int, FILE *);
98
99extern wint_t fputwc(wchar_t, FILE *);
100extern wint_t putwchar(wchar_t);
101
102/* Formatted string output functions */
103extern int fprintf(FILE *, const char *, ...)
104 _HELENOS_PRINTF_ATTRIBUTE(2, 3);
105extern int vfprintf(FILE *, const char *, va_list);
106
107extern int printf(const char *, ...)
108 _HELENOS_PRINTF_ATTRIBUTE(1, 2);
109extern int vprintf(const char *, va_list);
110
111extern int snprintf(char *, size_t, const char *, ...)
112 _HELENOS_PRINTF_ATTRIBUTE(3, 4);
113#if defined(_HELENOS_SOURCE) || defined(_GNU_SOURCE)
114extern int vasprintf(char **, const char *, va_list);
115extern int asprintf(char **, const char *, ...)
116#endif
117 _HELENOS_PRINTF_ATTRIBUTE(2, 3);
118extern int vsnprintf(char *, size_t, const char *, va_list);
119
120/* Formatted input */
121extern int scanf(const char *, ...);
122extern int vscanf(const char *, va_list);
123extern int fscanf(FILE *, const char *, ...);
124extern int vfscanf(FILE *, const char *, va_list);
125extern int sscanf(const char *, const char *, ...);
126extern int vsscanf(const char *, const char *, va_list);
127
128/* File stream functions */
129extern FILE *fopen(const char *, const char *);
130extern FILE *freopen(const char *, const char *, FILE *);
131extern int fclose(FILE *);
132
133extern size_t fread(void *, size_t, size_t, FILE *);
134extern size_t fwrite(const void *, size_t, size_t, FILE *);
135
136extern int fgetpos(FILE *, fpos_t *);
137extern int fsetpos(FILE *, const fpos_t *);
138
139extern int fseek(FILE *, long, int);
140extern void rewind(FILE *);
141extern long ftell(FILE *);
142extern int feof(FILE *);
143
144extern int fflush(FILE *);
145extern int ferror(FILE *);
146extern void clearerr(FILE *);
147
148extern void perror(const char *);
149
150extern void setvbuf(FILE *, void *, int, size_t);
151extern void setbuf(FILE *, void *);
152
153/* Misc file functions */
154extern int rename(const char *, const char *);
155extern int remove(const char *);
156
157#ifndef _HELENOS_SOURCE
158#define _IONBF 0
159#define _IOLBF 1
160#define _IOFBF 2
161
162extern char *gets(char *, size_t);
163
164#endif
165
166#ifdef _HELENOS_SOURCE
167
168/* Nonstandard extensions. */
169
170enum _buffer_type {
171 /** No buffering */
172 _IONBF,
173 /** Line buffering */
174 _IOLBF,
175 /** Full buffering */
176 _IOFBF
177};
178
179enum _buffer_state {
180 /** Buffer is empty */
181 _bs_empty,
182
183 /** Buffer contains data to be written */
184 _bs_write,
185
186 /** Buffer contains prefetched data for reading */
187 _bs_read
188};
189
190extern int vprintf_size(const char *, va_list);
191extern int printf_size(const char *, ...)
192 _HELENOS_PRINTF_ATTRIBUTE(1, 2);
193extern FILE *fdopen(int, const char *);
194extern int fileno(FILE *);
195
196#include <offset.h>
197
198extern int fseek64(FILE *, off64_t, int);
199extern off64_t ftell64(FILE *);
200
201#endif
202
203
204#endif
205
206/** @}
207 */
Note: See TracBrowser for help on using the repository browser.