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

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

Clean up libposix stdio.h and stdlib.h a bit.

  • Property mode set to 100644
File size: 4.9 KB
Line 
1/*
2 * Copyright (c) 2005 Martin Decky
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup libc
30 * @{
31 */
32/** @file
33 */
34
35#ifndef LIBC_STDIO_H_
36#define LIBC_STDIO_H_
37
38#include <stdarg.h>
39#include <io/verify.h>
40#include <_bits/size_t.h>
41#include <_bits/wchar_t.h>
42#include <_bits/wint_t.h>
43
44#define EOF (-1)
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/** Default size for stream I/O buffers */
59#define BUFSIZ 4096
60
61/** Recommended size of fixed-size array for holding file names. */
62#define FILENAME_MAX 4096
63
64/** Forward declaration */
65struct _IO_FILE;
66typedef struct _IO_FILE FILE;
67
68extern FILE *stdin;
69extern FILE *stdout;
70extern FILE *stderr;
71
72/* Character and string input functions */
73#define getc fgetc
74extern int fgetc(FILE *);
75extern char *fgets(char *, int, FILE *);
76
77extern int getchar(void);
78
79/* Character and string output functions */
80#define putc fputc
81extern int fputc(int, FILE *);
82extern int fputs(const char *, FILE *);
83
84extern int putchar(int);
85extern int puts(const char *);
86
87extern int ungetc(int, FILE *);
88
89extern wint_t fputwc(wchar_t, FILE *);
90extern wint_t putwchar(wchar_t);
91
92/* Formatted string output functions */
93extern int fprintf(FILE *, const char *, ...)
94 _HELENOS_PRINTF_ATTRIBUTE(2, 3);
95extern int vfprintf(FILE *, const char *, va_list);
96
97extern int printf(const char *, ...)
98 _HELENOS_PRINTF_ATTRIBUTE(1, 2);
99extern int vprintf(const char *, va_list);
100
101extern int snprintf(char *, size_t, const char *, ...)
102 _HELENOS_PRINTF_ATTRIBUTE(3, 4);
103#if defined(_HELENOS_SOURCE) || defined(_GNU_SOURCE)
104extern int vasprintf(char **, const char *, va_list);
105extern int asprintf(char **, const char *, ...)
106#endif
107 _HELENOS_PRINTF_ATTRIBUTE(2, 3);
108extern int vsnprintf(char *, size_t, const char *, va_list);
109
110/* Formatted input */
111extern int scanf(const char *, ...);
112extern int vscanf(const char *, va_list);
113extern int fscanf(FILE *, const char *, ...);
114extern int vfscanf(FILE *, const char *, va_list);
115extern int sscanf(const char *, const char *, ...);
116extern int vsscanf(const char *, const char *, va_list);
117
118/* File stream functions */
119extern FILE *fopen(const char *, const char *);
120extern FILE *freopen(const char *, const char *, FILE *);
121extern int fclose(FILE *);
122
123extern size_t fread(void *, size_t, size_t, FILE *);
124extern size_t fwrite(const void *, size_t, size_t, FILE *);
125
126extern int fseek(FILE *, long, int);
127extern void rewind(FILE *);
128extern long ftell(FILE *);
129extern int feof(FILE *);
130
131extern int fflush(FILE *);
132extern int ferror(FILE *);
133extern void clearerr(FILE *);
134
135extern void setvbuf(FILE *, void *, int, size_t);
136extern void setbuf(FILE *, void *);
137
138/* Misc file functions */
139extern int rename(const char *, const char *);
140extern int remove(const char *);
141
142#ifndef _HELENOS_SOURCE
143#define _IONBF 0
144#define _IOLBF 1
145#define _IOFBF 2
146
147extern char *gets(char *, size_t);
148
149#endif
150
151#ifdef _HELENOS_SOURCE
152
153/* Nonstandard extensions. */
154
155enum _buffer_type {
156 /** No buffering */
157 _IONBF,
158 /** Line buffering */
159 _IOLBF,
160 /** Full buffering */
161 _IOFBF
162};
163
164enum _buffer_state {
165 /** Buffer is empty */
166 _bs_empty,
167
168 /** Buffer contains data to be written */
169 _bs_write,
170
171 /** Buffer contains prefetched data for reading */
172 _bs_read
173};
174
175extern int vprintf_size(const char *, va_list);
176extern int printf_size(const char *, ...)
177 _HELENOS_PRINTF_ATTRIBUTE(1, 2);
178extern FILE *fdopen(int, const char *);
179extern int fileno(FILE *);
180
181#include <offset.h>
182
183extern int fseek64(FILE *, off64_t, int);
184extern off64_t ftell64(FILE *);
185
186#endif
187
188
189#endif
190
191/** @}
192 */
Note: See TracBrowser for help on using the repository browser.