source: mainline/uspace/lib/c/include/stdio.h@ 163e34c

Last change on this file since 163e34c was 163e34c, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 3 months ago

Actually convert the printf outputs everywhere

  • Property mode set to 100644
File size: 5.6 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 <stdarg.h>
40#include <io/verify.h>
41#include <_bits/NULL.h>
42#include <_bits/size_t.h>
43#include <_bits/wchar_t.h>
44#include <_bits/uchar.h>
45#include <_bits/wint_t.h>
46#include <_bits/decls.h>
47
48#ifndef _HELENOS_SOURCE
49#define _IONBF 0
50#define _IOLBF 1
51#define _IOFBF 2
52#endif
53
54/** Default size for stream I/O buffers */
55#define BUFSIZ 4096
56
57#define EOF (-1)
58
59/** Max number of files that is guaranteed to be able to open at the same time */
60#define FOPEN_MAX 16
61
62/** Recommended size of fixed-size array for holding file names. */
63#define FILENAME_MAX 4096
64
65/** Length of "/tmp/tmp.XXXXXX" + 1 */
66#define L_tmpnam 16
67
68#ifndef SEEK_SET
69#define SEEK_SET 0
70#endif
71
72#ifndef SEEK_CUR
73#define SEEK_CUR 1
74#endif
75
76#ifndef SEEK_END
77#define SEEK_END 2
78#endif
79
80/** Minimum number of unique temporary file names */
81#define TMP_MAX 1000000
82
83__C_DECLS_BEGIN;
84
85/** Forward declaration */
86struct _IO_FILE;
87typedef struct _IO_FILE FILE;
88
89/** File position */
90typedef struct {
91 long long pos;
92} fpos_t;
93
94extern FILE *stdin;
95extern FILE *stdout;
96extern FILE *stderr;
97
98/* Character and string input functions */
99extern int fgetc(FILE *);
100extern char *fgets(char *, int, FILE *);
101extern char *gets(char *, size_t) __attribute__((deprecated));
102
103static inline int getc(FILE *f)
104{
105 return fgetc(f);
106}
107
108extern int getchar(void);
109
110/* Character and string output functions */
111extern int fputc(int, FILE *);
112extern int fputs(const char *, FILE *);
113
114static inline int putc(int i, FILE *f)
115{
116 return fputc(i, f);
117}
118
119extern int putchar(int);
120extern int puts(const char *);
121
122extern int ungetc(int, FILE *);
123
124extern wint_t fputwc(wchar_t, FILE *);
125extern wint_t putwchar(wchar_t);
126
127extern wint_t fputuc(char32_t, FILE *);
128extern wint_t putuchar(char32_t);
129
130/* Formatted string output functions */
131extern int fprintf(FILE *, const char *, ...)
132 _HELENOS_PRINTF_ATTRIBUTE(2, 3);
133extern int vfprintf(FILE *, const char *, va_list);
134
135extern int printf(const char *, ...)
136 _HELENOS_PRINTF_ATTRIBUTE(1, 2);
137extern int vprintf(const char *, va_list);
138
139extern int snprintf(char *, size_t, const char *, ...)
140 _HELENOS_PRINTF_ATTRIBUTE(3, 4);
141#if defined(_HELENOS_SOURCE) || defined(_GNU_SOURCE)
142extern int vasprintf(char **, const char *, va_list);
143extern int asprintf(char **, const char *, ...)
144 _HELENOS_PRINTF_ATTRIBUTE(2, 3);
145#endif
146extern int vsnprintf(char *, size_t, const char *, va_list);
147
148extern int sprintf(char *, const char *, ...)
149 __attribute__((deprecated)) _HELENOS_PRINTF_ATTRIBUTE(2, 3);
150extern int vsprintf(char *, const char *, va_list) __attribute__((deprecated));
151
152/* Formatted input */
153extern int scanf(const char *, ...);
154extern int vscanf(const char *, va_list);
155extern int fscanf(FILE *, const char *, ...);
156extern int vfscanf(FILE *, const char *, va_list);
157extern int sscanf(const char *, const char *, ...);
158extern int vsscanf(const char *, const char *, va_list);
159
160/* File stream functions */
161extern FILE *fopen(const char *, const char *);
162extern FILE *freopen(const char *, const char *, FILE *);
163extern int fclose(FILE *);
164
165extern size_t fread(void *, size_t, size_t, FILE *);
166extern size_t fwrite(const void *, size_t, size_t, FILE *);
167
168extern int fgetpos(FILE *, fpos_t *);
169extern int fsetpos(FILE *, const fpos_t *);
170
171extern int fseek(FILE *, long, int);
172extern void rewind(FILE *);
173extern long ftell(FILE *);
174extern int feof(FILE *);
175
176extern int fflush(FILE *);
177extern int ferror(FILE *);
178extern void clearerr(FILE *);
179
180extern void perror(const char *);
181
182extern int setvbuf(FILE *, void *, int, size_t);
183extern void setbuf(FILE *, void *);
184
185/* Misc file functions */
186extern int remove(const char *);
187extern int rename(const char *, const char *);
188
189extern FILE *tmpfile(void);
190extern char *tmpnam(char *s);
191
192__C_DECLS_END;
193
194#ifdef _HELENOS_SOURCE
195
196#include <_bits/off64_t.h>
197
198__HELENOS_DECLS_BEGIN;
199
200/* Nonstandard extensions. */
201
202enum __buffer_type {
203 /** No buffering */
204 _IONBF,
205 /** Line buffering */
206 _IOLBF,
207 /** Full buffering */
208 _IOFBF
209};
210
211extern FILE *fdopen(int, const char *);
212extern int fileno(FILE *);
213
214extern int fseek64(FILE *, off64_t, int);
215extern off64_t ftell64(FILE *);
216
217__HELENOS_DECLS_END;
218#endif
219
220#endif
221
222/** @}
223 */
Note: See TracBrowser for help on using the repository browser.