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

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

sprintf, vsprintf belong in libc (as deprecated).

  • Property mode set to 100644
File size: 5.4 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 *);
86extern char *gets(char *, size_t) __attribute__((deprecated));
87
88extern int getchar(void);
89
90/* Character and string output functions */
91#define putc fputc
92extern int fputc(int, FILE *);
93extern int fputs(const char *, FILE *);
94
95extern int putchar(int);
96extern int puts(const char *);
97
98extern int ungetc(int, FILE *);
99
100extern wint_t fputwc(wchar_t, FILE *);
101extern wint_t putwchar(wchar_t);
102
103/* Formatted string output functions */
104extern int fprintf(FILE *, const char *, ...)
105 _HELENOS_PRINTF_ATTRIBUTE(2, 3);
106extern int vfprintf(FILE *, const char *, va_list);
107
108extern int printf(const char *, ...)
109 _HELENOS_PRINTF_ATTRIBUTE(1, 2);
110extern int vprintf(const char *, va_list);
111
112extern int snprintf(char *, size_t, const char *, ...)
113 _HELENOS_PRINTF_ATTRIBUTE(3, 4);
114#if defined(_HELENOS_SOURCE) || defined(_GNU_SOURCE)
115extern int vasprintf(char **, const char *, va_list);
116extern int asprintf(char **, const char *, ...)
117 _HELENOS_PRINTF_ATTRIBUTE(2, 3);
118#endif
119extern int vsnprintf(char *, size_t, const char *, va_list);
120
121extern int sprintf(char *, const char *, ...)
122 __attribute__((deprecated)) _HELENOS_PRINTF_ATTRIBUTE(2, 3);
123extern int vsprintf(char *, const char *, va_list) __attribute__((deprecated));
124
125/* Formatted input */
126extern int scanf(const char *, ...);
127extern int vscanf(const char *, va_list);
128extern int fscanf(FILE *, const char *, ...);
129extern int vfscanf(FILE *, const char *, va_list);
130extern int sscanf(const char *, const char *, ...);
131extern int vsscanf(const char *, const char *, va_list);
132
133/* File stream functions */
134extern FILE *fopen(const char *, const char *);
135extern FILE *freopen(const char *, const char *, FILE *);
136extern int fclose(FILE *);
137
138extern size_t fread(void *, size_t, size_t, FILE *);
139extern size_t fwrite(const void *, size_t, size_t, FILE *);
140
141extern int fgetpos(FILE *, fpos_t *);
142extern int fsetpos(FILE *, const fpos_t *);
143
144extern int fseek(FILE *, long, int);
145extern void rewind(FILE *);
146extern long ftell(FILE *);
147extern int feof(FILE *);
148
149extern int fflush(FILE *);
150extern int ferror(FILE *);
151extern void clearerr(FILE *);
152
153extern void perror(const char *);
154
155extern void setvbuf(FILE *, void *, int, size_t);
156extern void setbuf(FILE *, void *);
157
158/* Misc file functions */
159extern int rename(const char *, const char *);
160extern int remove(const char *);
161
162#ifndef _HELENOS_SOURCE
163#define _IONBF 0
164#define _IOLBF 1
165#define _IOFBF 2
166
167#endif
168
169#ifdef _HELENOS_SOURCE
170
171/* Nonstandard extensions. */
172
173enum _buffer_type {
174 /** No buffering */
175 _IONBF,
176 /** Line buffering */
177 _IOLBF,
178 /** Full buffering */
179 _IOFBF
180};
181
182enum _buffer_state {
183 /** Buffer is empty */
184 _bs_empty,
185
186 /** Buffer contains data to be written */
187 _bs_write,
188
189 /** Buffer contains prefetched data for reading */
190 _bs_read
191};
192
193extern int vprintf_size(const char *, va_list);
194extern int printf_size(const char *, ...)
195 _HELENOS_PRINTF_ATTRIBUTE(1, 2);
196extern FILE *fdopen(int, const char *);
197extern int fileno(FILE *);
198
199#include <offset.h>
200
201extern int fseek64(FILE *, off64_t, int);
202extern off64_t ftell64(FILE *);
203
204#endif
205
206
207#endif
208
209/** @}
210 */
Note: See TracBrowser for help on using the repository browser.