PSXSDK
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
stdio.h
Go to the documentation of this file.
1 /*
2  * stdio.h implementation for PSXSDK
3  */
4 
5 #ifndef _STDIO_H
6 #define _STDIO_H
7 
8 #ifdef _PSXSDK_WRAPPER
9 
10 /*
11  * Dirty hack...
12  */
13 
14 #include "/usr/include/stdio.h"
15 
16 #else
17 
18 typedef unsigned int size_t;
19 typedef signed int ssize_t;
20 
21 #include <stdarg.h>
22 #include <stdbool.h>
23 
24 #define SEEK_SET 0
25 #define SEEK_CUR 1
26 #define SEEK_END 2
27 
28 #define EOF -1
29 
30 /* NULL */
31 #ifndef NULL
32 #define NULL (void*)0
33 #endif
34 
36 {
39 };
40 
41 extern int __stdio_direction;
42 
47 typedef struct
48 {
50  int fildes;
52  unsigned int pos;
54  unsigned int mode;
56  unsigned int dev;
58  unsigned int size;
60  unsigned int used;
61 }FILE;
62 
63 /*
64  * The functions below are just prototypes for assembly wrappers which
65  * call BIOS functions, so they're actually supplied by the BIOS
66  * and not implemented by the PSX SDK.
67  */
68 
69 /* Console functions */
70 
71 extern int putchar(int c);
72 extern int puts(const char *str);
73 
79 extern int printf(const char *format, ...);
80 
81 // If PSXSDK_DEBUG is defined, dprintf() calls are turned into printf() calls
82 // otherwise they are left out
83 
84 #ifdef PSXSDK_DEBUG
85  #define dprintf printf
86 #else
87  #define dprintf(fmt, ...)
88 #endif
89 
90 int vsnprintf(char *string, size_t size, const char *fmt, va_list ap);
91 int vsprintf(char *string, const char *fmt, va_list ap);
92 int sprintf(char *string, const char *fmt, ...);
93 int snprintf(char *string, size_t size, const char *fmt, ...);
94 int vprintf(char *fmt, va_list ap);
95 
96 FILE *fdopen(int fildes, const char *mode);
97 FILE *fopen(char *path, const char *mode);
98 int fclose(FILE *stream);
99 int fread(void *ptr, int size, int nmemb, FILE *f);
100 
101 int fgetc(FILE *f);
102 int ftell(FILE *f);
103 int fseek(FILE *f, int offset, int whence);
104 
105 #define getc(f) fgetc(f)
106 
107 int rename(char *oldname, char *newname);
108 int remove(char *filename);
109 
110 #ifndef __cplusplus
111 // Define delete(x) to be remove(x) only when compiling plain C.
112 #define delete(x) remove(x)
113 #endif
114 
119 void redirect_stdio_to_sio(void);
120 
129 void sio_stdio_mapcr(unsigned int setting);
130 
135 int vsscanf(const char *str, const char *fmt, va_list ap);
136 int sscanf(const char *str, const char *fmt, ...);
137 
138 
143 int sio_putchar(int c);
144 int sio_puts(const char *str);
145 int sio_printf(const char *fmt, ...);
146 int sio_vprintf(const char *fmt, va_list ap);
147 
148 #endif
149 
150 #endif
151