# stdio.h

Go to the documentation of this file.

    00001 /*
    00002  * PSP Software Development Kit - http://www.pspdev.org
    00003  * -----------------------------------------------------------------------
    00004  * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
    00005  *
    00006  * stdio.h
    00007  *
    00008  * Copyright (c) 2002-2004 PS2DEV
    00009  * Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
    00010  * Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
    00011  * Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
    00012  *
    00013  * $Id: stdio.h 1095 2005-09-27 21:02:16Z jim $
    00014  */
    00015
    00016 #ifndef __STDIO_H__
    00017 #define __STDIO_H__
    00018
    00019 #include <pspkernel.h>
    00020 #include <stdarg.h>
    00021
    00022 #ifdef __cplusplus
    00023 extern "C" {
    00024 #endif
    00025
    00026
    00027 /* Some aliases for the unix 'unistd' functions */
    00028 static __inline__ int open(const char *fname, int flags, ...) { return sceIoOpen(fname, flags, 0777); }
    00029 static __inline__ int close(int handle) { return sceIoClose(handle); }
    00030 static __inline__ ssize_t read(int handle, void * buffer, size_t size) { return sceIoRead(handle, buffer, size); }
    00031 static __inline__ ssize_t write(int handle, const void * buffer, size_t size) { return sceIoWrite(handle, buffer, size); }
    00032 static __inline__ off_t lseek(int handle, off_t position, int wheel) { return sceIoLseek(handle, position, wheel); }
    00033 static __inline__ off_t tell(int handle) { return sceIoLseek(handle, 0, 1); }
    00034
    00035 /* Some win32 equivalents... baaah */
    00036 #define _open open
    00037 #define _close close
    00038 #define _read read
    00039 #define _write write
    00040 #define _lseek lseek
    00041
    00042 #define _O_APPEND O_APPEND
    00043 #define _O_BINARY O_BINARY
    00044 #define _O_CREAT  O_CREAT
    00045 #define _O_RDONKY O_RDONKY
    00046 #define _O_RDWR   O_RDWR
    00047 #define _O_TEXT   O_TEXT
    00048 #define _O_TRUNC  O_TRUNC
    00049 #define _O_WRONLY O_WRONLY
    00050
    00051 #ifndef O_BINARY
    00052 #define O_BINARY 0
    00053 #endif
    00054
    00055 #ifndef O_TEXT
    00056 #define O_TEXT 0
    00057 #endif
    00058
    00059
    00060 #define BUFSIZ                         1024
    00061
    00062 #define _NFILE                         16
    00063
    00064
    00065 #define _IOFBF                         0x0000
    00066 #define _IOLBF                         0x0100
    00067 #define _IONBF                         0x0004
    00068 #define _IOEOF                         0x0020
    00069 #define _IOERR                         0x0040
    00070
    00071 #define _IOREAD                        0x0001
    00072 #define _IOWRT                         0x0002
    00073 #define _IORW                          0x0200
    00074 #define _IOMYBUF                       0x0010
    00075
    00076
    00077 /* ensure EOF is defined. */
    00078 #ifndef EOF
    00079 #define EOF                            (-1)
    00080 #endif
    00081
    00082
    00083 #define FOPEN_MAX                      _NFILE
    00084 #define FILENAME_MAX                   1024
    00085
    00086
    00087 #define SEEK_SET                       0
    00088 #define SEEK_CUR                       1
    00089 #define SEEK_END                       2
    00090
    00091
    00092 /* ensure fpos_t is defined. */
    00093 #ifndef __FPOS_T_DEFINED
    00094 #define __FPOS_T_DEFINED
    00095 typedef long fpos_t;
    00096 #endif // __FPOS_T_DEFINED
    00097
    00098
    00099 /* ensure FILE is defined. */
    00100 #ifndef __FILE_DEFINED
    00101 #define __FILE_DEFINED
    00102 typedef struct {
    00103   int  type;
    00104   int  fd;
    00105   int  cnt;
    00106   int  flag;
    00107   int  has_putback;
    00108   u8   putback;
    00109 } FILE;
    00110 #endif // __FILE_DEFINED
    00111
    00112
    00113 extern FILE __iob[_NFILE];
    00114
    00115
    00116 #define stdin                          (&__iob[0])
    00117 #define stdout                         (&__iob[1])
    00118 #define stderr                         (&__iob[2])
    00119
    00120
    00121 /* function declarations. */
    00122 void   clearerr(FILE *);
    00123 int    feof(FILE *);
    00124 int    ferror(FILE *);
    00125 FILE   *fopen(const char *, const char *);
    00126 FILE   *fdopen(int, const char *);
    00127 int    fclose(FILE *);
    00128 int    fflush(FILE *);
    00129 int    fgetc(FILE *);
    00130 int    fgetpos(FILE *, fpos_t *);
    00131 char   *fgets(char *, int, FILE *);
    00132 int    fileno(FILE *);
    00133 int    fputc(int, FILE *);
    00134 int    fputs(const char *, FILE *);
    00135 size_t fread(void *, size_t, size_t, FILE *);
    00136 FILE   *freopen(const char *, const char *, FILE *);
    00137 int    fscanf(FILE *, const char *, ...);
    00138 int    fseek(FILE *, long, int);
    00139 int    fsetpos(FILE *, const fpos_t *);
    00140 long   ftell(FILE *);
    00141 size_t fwrite(const void *, size_t, size_t, FILE *);
    00142 int    getc(FILE *);
    00143 int    getchar(void);
    00144 char   *gets(char *);
    00145 void   perror(const char *);
    00146 int    putc(int, FILE *);
    00147 int    puts(const char *);
    00148 int    remove(const char *);
    00149 int    rename(const char *, const char *);
    00150 void   rewind(FILE *);
    00151 int    scanf(const char *, ...);
    00152 int    setbuf(FILE *, char *);
    00153 int    setvbuf(FILE *, char *, int, size_t);
    00154 int    sscanf(const char *, const char *, ...);
    00155 FILE   *tmpfile(void);
    00156 char   *tmpnam(char *);
    00157 int    vfscanf(FILE *, const char *, va_list);
    00158 int    vscanf(const char *, va_list);
    00159 int    vsscanf(const char *, const char *, va_list);
    00160 int    vxscanf(int (*xgetc)(void **), void (*xungetc)(int, void **), void *stream, const char *, va_list);
    00161 int    xscanf(int (*xgetc)(void **), void (*xungetc)(int, void **), void *stream, const char *, ...);
    00162
    00163 int    ungetc(int, FILE *);
    00164
    00165 int    _fcloseall(void);
    00166 int    _fflushall(void);
    00167
    00168 int    chdir(const char *path);
    00169
    00170
    00171 /* from xprintf */
    00172 int vxprintf(void (*func)(char*, int, void *), void * arg, const char * format, va_list ap);
    00173 int vsnprintf(char *buf, size_t n, const char *fmt, va_list ap);
    00174 int vsprintf(char *buf, const char *fmt, va_list ap);
    00175 char *vmprintf(const char *zFormat, va_list ap);
    00176 int vfprintf(FILE *pOut, const char *zFormat, va_list ap);
    00177 int vprintf(const char *format, va_list ap);
    00178 int vasprintf(char **strp, const char *format, va_list ap);
    00179
    00180 int xprintf(void (*func)(char*, int, void *), void * arg, const char * format, ...)
    00181     __attribute__((format(printf,3,4)));
    00182 int snprintf(char *str, size_t sz, const char *format, ...)
    00183     __attribute__((format(printf,3,4)));
    00184 int sprintf(char *buf, const char *fmt, ...)
    00185     __attribute__((format(printf,2,3)));
    00186 char *mprintf(const char *zFormat, ...)
    00187     __attribute__((format(printf,1,2)));
    00188 int fprintf(FILE *pOut, const char *zFormat, ...)
    00189     __attribute__((format(printf,2,3)));
    00190 int printf(const char *format, ...)
    00191     __attribute__((format(printf,1,2)));
    00192 int asprintf(char **strp, const char *format, ...)
    00193     __attribute__((format(printf,2,3)));
    00194
    00195 int putchar(int);
    00196
    00197 int npmPuts(const char *buf);
    00198 int nprintf(const char *format, ...);
    00199 int vnprintf(const char *format, va_list args);
    00200 int sio_printf(const char *format, ...);
    00201
    00202 #ifdef __cplusplus
    00203 }
    00204 #endif
    00205
    00206
    00207 #endif // __STDIO_H__