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

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

Replace some license headers with SPDX identifier

Headers are replaced using tools/transorm-copyright.sh only
when it can be matched verbatim with the license header used
throughout most of the codebase.

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