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
RevLine 
[3eddaff]1/*
[df4ed85]2 * Copyright (c) 2005 Martin Decky
[777832e]3 * Copyright (c) 2018 Jiri Svoboda
[3eddaff]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
[fadd381]30/** @addtogroup libc
[b2951e2]31 * @{
32 */
33/** @file
34 */
35
[fadd381]36#ifndef LIBC_STDIO_H_
37#define LIBC_STDIO_H_
[3eddaff]38
[777832e]39#include <offset.h>
[3214a20]40#include <stdarg.h>
[aa492fe]41#include <io/verify.h>
[1d6dd2a]42#include <_bits/size_t.h>
43#include <_bits/wchar_t.h>
[ed88c8e]44#include <_bits/wint_t.h>
[9ac2013]45
[2595dab]46#define EOF (-1)
[37458472]47
[c23275a]48#ifndef SEEK_SET
[1433ecda]49#define SEEK_SET 0
[c23275a]50#endif
51
52#ifndef SEEK_CUR
[1433ecda]53#define SEEK_CUR 1
[c23275a]54#endif
55
56#ifndef SEEK_END
[1433ecda]57#define SEEK_END 2
[c23275a]58#endif
59
[ef8bcc6]60/** Default size for stream I/O buffers */
[db24058]61#define BUFSIZ 4096
[ef8bcc6]62
[777832e]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
[55092672]66/** Recommended size of fixed-size array for holding file names. */
67#define FILENAME_MAX 4096
68
[79ae36dd]69/** Forward declaration */
70struct _IO_FILE;
71typedef struct _IO_FILE FILE;
[04b687b]72
[777832e]73/** File position */
74typedef struct {
75 off64_t pos;
76} fpos_t;
77
[2595dab]78extern FILE *stdin;
79extern FILE *stdout;
80extern FILE *stderr;
81
82/* Character and string input functions */
[55092672]83#define getc fgetc
[2595dab]84extern int fgetc(FILE *);
[c62d2e1]85extern char *fgets(char *, int, FILE *);
[296890f3]86extern char *gets(char *, size_t) __attribute__((deprecated));
[1c1002a]87
[b27a97bb]88extern int getchar(void);
89
[2595dab]90/* Character and string output functions */
[55092672]91#define putc fputc
[ed88c8e]92extern int fputc(int, FILE *);
[2595dab]93extern int fputs(const char *, FILE *);
94
[ed88c8e]95extern int putchar(int);
[ab00d5a]96extern int puts(const char *);
[3eddaff]97
[bd5414e]98extern int ungetc(int, FILE *);
99
[ed88c8e]100extern wint_t fputwc(wchar_t, FILE *);
101extern wint_t putwchar(wchar_t);
102
[2595dab]103/* Formatted string output functions */
[1433ecda]104extern int fprintf(FILE *, const char *, ...)
[09d13c8e]105 _HELENOS_PRINTF_ATTRIBUTE(2, 3);
[2595dab]106extern int vfprintf(FILE *, const char *, va_list);
[3214a20]107
[9ac2013]108extern int printf(const char *, ...)
[09d13c8e]109 _HELENOS_PRINTF_ATTRIBUTE(1, 2);
[ab00d5a]110extern int vprintf(const char *, va_list);
[3214a20]111
[1433ecda]112extern int snprintf(char *, size_t, const char *, ...)
[09d13c8e]113 _HELENOS_PRINTF_ATTRIBUTE(3, 4);
[55092672]114#if defined(_HELENOS_SOURCE) || defined(_GNU_SOURCE)
[a9763c6]115extern int vasprintf(char **, const char *, va_list);
[9ac2013]116extern int asprintf(char **, const char *, ...)
[09d13c8e]117 _HELENOS_PRINTF_ATTRIBUTE(2, 3);
[296890f3]118#endif
[2595dab]119extern int vsnprintf(char *, size_t, const char *, va_list);
[a8e9ab8d]120
[296890f3]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
[5a6c28d1]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);
[ed18e14]132
[2595dab]133/* File stream functions */
[04b687b]134extern FILE *fopen(const char *, const char *);
[80bee81]135extern FILE *freopen(const char *, const char *, FILE *);
[04b687b]136extern int fclose(FILE *);
[2595dab]137
[04b687b]138extern size_t fread(void *, size_t, size_t, FILE *);
139extern size_t fwrite(const void *, size_t, size_t, FILE *);
[2595dab]140
[777832e]141extern int fgetpos(FILE *, fpos_t *);
142extern int fsetpos(FILE *, const fpos_t *);
143
[456c086]144extern int fseek(FILE *, long, int);
[080ad7f]145extern void rewind(FILE *);
[456c086]146extern long ftell(FILE *);
[04b687b]147extern int feof(FILE *);
[2595dab]148
149extern int fflush(FILE *);
[04b687b]150extern int ferror(FILE *);
151extern void clearerr(FILE *);
152
[777832e]153extern void perror(const char *);
154
[ef8bcc6]155extern void setvbuf(FILE *, void *, int, size_t);
[7699c21]156extern void setbuf(FILE *, void *);
[ef8bcc6]157
[b942a66]158/* Misc file functions */
159extern int rename(const char *, const char *);
160extern int remove(const char *);
161
[bc1b297]162#ifndef _HELENOS_SOURCE
163#define _IONBF 0
164#define _IOLBF 1
165#define _IOFBF 2
[55092672]166
[bc1b297]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
[1c7f381]199#include <offset.h>
200
201extern int fseek64(FILE *, off64_t, int);
202extern off64_t ftell64(FILE *);
203
[bc1b297]204#endif
205
206
[3eddaff]207#endif
[b2951e2]208
[fadd381]209/** @}
[b2951e2]210 */
Note: See TracBrowser for help on using the repository browser.