2
* Copyright (c) 2005 Martin Decky
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions
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.
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.
38
#include <sys/types.h>
45
/** Default size for stream I/O buffers */
48
#define DEBUG(fmt, ...) \
51
int _n = snprintf(_buf, sizeof(_buf), fmt, ##__VA_ARGS__); \
53
(void) __SYSCALL3(SYS_KLOG, 1, (sysarg_t) _buf, str_size(_buf)); \
72
/** Linked list pointer. */
75
/** Underlying file descriptor. */
78
/** Error indicator. */
81
/** End-of-file indicator. */
87
/** Phone to the file provider */
91
enum _buffer_type btype;
96
/** Buffer I/O pointer */
104
/* Character and string input functions */
105
extern int fgetc(FILE *);
106
extern char *fgets(char *, size_t, FILE *);
108
extern int getchar(void);
109
extern char *gets(char *, size_t);
111
/* Character and string output functions */
112
extern int fputc(wchar_t, FILE *);
113
extern int fputs(const char *, FILE *);
115
extern int putchar(wchar_t);
116
extern int puts(const char *);
118
/* Formatted string output functions */
119
extern int fprintf(FILE *, const char*, ...);
120
extern int vfprintf(FILE *, const char *, va_list);
122
extern int printf(const char *, ...);
123
extern int vprintf(const char *, va_list);
125
extern int snprintf(char *, size_t , const char *, ...);
126
extern int asprintf(char **, const char *, ...);
127
extern int vsnprintf(char *, size_t, const char *, va_list);
129
/* File stream functions */
130
extern FILE *fopen(const char *, const char *);
131
extern FILE *fdopen(int, const char *);
132
extern int fclose(FILE *);
134
extern size_t fread(void *, size_t, size_t, FILE *);
135
extern size_t fwrite(const void *, size_t, size_t, FILE *);
137
extern int fseek(FILE *, long, int);
138
extern void rewind(FILE *);
139
extern int ftell(FILE *);
140
extern int feof(FILE *);
142
extern int fflush(FILE *);
143
extern int ferror(FILE *);
144
extern void clearerr(FILE *);
146
extern void setvbuf(FILE *, void *, int, size_t);
148
/* Misc file functions */
149
extern int rename(const char *, const char *);