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

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

fgetpos, fsetpos, perror.

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