2 ** Copyright 2002, Travis Geiselbrecht. All rights reserved.
3 ** Copyright 2002, Manuel J. Petit. All rights reserved.
4 ** Distributed under the terms of the NewOS License.
5 ** Modified by Justin Smith 2003/06/17. Changed FILE struct.
8 #ifndef __newos__libc_stdio__hh__
9 #define __newos__libc_stdio__hh__
12 #include <sys/types.h>
13 #include <sys/cdefs.h>
22 #define _STDIO_READ 0x0001
23 #define _STDIO_WRITE 0x0002
24 #define _STDIO_EOF 0x0004
25 #define _STDIO_ERROR 0x0008
26 #define _STDIO_UNGET 0x0010
28 //#ifndef __newos__libc_unistd__hh__
37 int fd
; /* system file descriptor */
38 ptrdiff_t rpos
; /* The first unread buffer position */
39 ptrdiff_t buf_pos
; /* first unwritten buffer position */
40 unsigned char* buf
; /* buffer */
41 ptrdiff_t buf_size
; /* buffer size */
42 unsigned char unget
; /* for ungetc */
43 int flags
; /* for feof and ferror */
44 struct __FILE
* next
; /* for fflush */
45 sem_id sid
; /* semaphore */
47 typedef struct __FILE
FILE;
55 int printf(char const *format
, ...) __PRINTFLIKE(1,2);
56 int fprintf(FILE *stream
, char const *format
, ...) __PRINTFLIKE(2,3);
57 int sprintf(char *str
, char const *format
, ...) __PRINTFLIKE(2,3);
58 //int snprintf(char *str, size_t size, char const *format, ...) __PRINTFLIKE(3,4);
59 //int asprintf(char **ret, char const *format, ...) __PRINTFLIKE(2,3);
60 int vprintf(char const *format
, va_list ap
);
61 int vfprintf(FILE *stream
, char const *format
, va_list ap
);
62 int vsprintf(char *str
, char const *format
, va_list ap
);
63 //int vsnprintf(char *str, size_t size, char const *format, va_list ap);
64 //int vasprintf(char **ret, char const *format, va_list ap);
66 size_t fwrite(const void *ptr
, size_t size
, size_t nmemb
, FILE *stream
);
67 int putc(int ch
, FILE *stream
);
68 int fputc(int ch
, FILE *stream
);
71 FILE *fopen(char const *, char const *);
75 long int ftell(FILE *stream
);
76 int fgetpos(FILE *stream
, fpos_t *pos
);
78 int fseek(FILE *stream
, long int offset
, int whence
);
81 void clearerr(FILE *);
83 int fputs(const char *str
, FILE *stream
);
85 FILE *freopen(const char *filename
, const char *mode
, FILE *stream
);
86 char* fgets(char *, int, FILE *);
87 size_t fread(void *ptr
, size_t size
, size_t nmemb
, FILE *stream
);
91 int ungetc(int c
, FILE *stream
);
93 int scanf(char const *format
, ...);
94 int fscanf(FILE *stream
, char const *format
, ...);
95 int sscanf(char const *str
, char const *format
, ...);
96 //int vscanf(char const *format, va_list ap);
97 int vsscanf(char const *str
, char const *format
, va_list ap
);
98 int vfscanf(FILE *stream
, char const *format
, va_list ap
);
100 int _v_printf(int (*_write
)(void*, const void *, ssize_t
), void* arg
, const char *fmt
, va_list args
);
106 // getchar goes off in it's own little non-standard world
107 // This function will be removed soon
117 #if defined(__cplusplus) && !defined(_NEWOS_NO_LIBC_COMPAT)
125 using ::std::clearerr
;
131 using ::std::fgetpos
;
134 using ::std::fprintf
;
138 using ::std::freopen
;
140 //using ::std::fseek;
141 //using ::std::fsetpos;
145 using ::std::getchar
;
147 //using ::std::perror;
150 //using ::std::remove;
151 //using ::std::rename;
152 //using ::std::rewind;
154 //using ::std::setbuf;
155 //using ::std::setvbuf;
156 using ::std::sprintf
;
158 //using ::std::tmpfile;
159 //using ::std::tmpnam;
161 using ::std::vfprintf
;
162 using ::std::vprintf
;
163 using ::std::vsprintf
;