stdio compat layer for plugins
This is attempt to simplify porting programs to rockbox (as plugins).
Currently this compat layer implements:
fopen(), fclose(), fflush(), fread(), fwrite(), fseek(), fseeko(),
ftell(), ftello(), fgetc(), ungetc(), fputc(), fgets(), clearerr(),
ferror(), feof(), fprintf()
In order to use it you need to include in ported sources
"lib/stdio_compat.h"
Change-Id: I5add615dd19c5af9c767ccbfb1bd5a4e466741cb
2013-01-18 15:16:59 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013 by Marcin Bukat
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
2017-01-21 20:18:31 +00:00
|
|
|
#define MAX_STDIO_FILES 11
|
stdio compat layer for plugins
This is attempt to simplify porting programs to rockbox (as plugins).
Currently this compat layer implements:
fopen(), fclose(), fflush(), fread(), fwrite(), fseek(), fseeko(),
ftell(), ftello(), fgetc(), ungetc(), fputc(), fgets(), clearerr(),
ferror(), feof(), fprintf()
In order to use it you need to include in ported sources
"lib/stdio_compat.h"
Change-Id: I5add615dd19c5af9c767ccbfb1bd5a4e466741cb
2013-01-18 15:16:59 +00:00
|
|
|
|
|
|
|
#undef FILE
|
|
|
|
#define FILE _FILE_
|
|
|
|
|
|
|
|
#define fopen _fopen_
|
|
|
|
#define fclose _fclose_
|
|
|
|
#define fflush _fflush_
|
|
|
|
#define fread _fread_
|
|
|
|
#define fwrite _fwrite_
|
|
|
|
#define fseek _fseek_
|
|
|
|
#define fseeko _fseek_
|
|
|
|
#define ftell _ftell_
|
|
|
|
#define ftello _ftell_
|
|
|
|
#define fgetc _fgetc_
|
|
|
|
#define ungetc _ungetc_
|
|
|
|
#define fputc _fputc_
|
|
|
|
#define fgets _fgets_
|
2017-12-24 18:00:26 +00:00
|
|
|
#undef clearerr
|
stdio compat layer for plugins
This is attempt to simplify porting programs to rockbox (as plugins).
Currently this compat layer implements:
fopen(), fclose(), fflush(), fread(), fwrite(), fseek(), fseeko(),
ftell(), ftello(), fgetc(), ungetc(), fputc(), fgets(), clearerr(),
ferror(), feof(), fprintf()
In order to use it you need to include in ported sources
"lib/stdio_compat.h"
Change-Id: I5add615dd19c5af9c767ccbfb1bd5a4e466741cb
2013-01-18 15:16:59 +00:00
|
|
|
#define clearerr _clearerr_
|
2017-12-24 18:00:26 +00:00
|
|
|
#undef ferror
|
stdio compat layer for plugins
This is attempt to simplify porting programs to rockbox (as plugins).
Currently this compat layer implements:
fopen(), fclose(), fflush(), fread(), fwrite(), fseek(), fseeko(),
ftell(), ftello(), fgetc(), ungetc(), fputc(), fgets(), clearerr(),
ferror(), feof(), fprintf()
In order to use it you need to include in ported sources
"lib/stdio_compat.h"
Change-Id: I5add615dd19c5af9c767ccbfb1bd5a4e466741cb
2013-01-18 15:16:59 +00:00
|
|
|
#define ferror _ferror_
|
2017-12-24 18:00:26 +00:00
|
|
|
#undef feof
|
stdio compat layer for plugins
This is attempt to simplify porting programs to rockbox (as plugins).
Currently this compat layer implements:
fopen(), fclose(), fflush(), fread(), fwrite(), fseek(), fseeko(),
ftell(), ftello(), fgetc(), ungetc(), fputc(), fgets(), clearerr(),
ferror(), feof(), fprintf()
In order to use it you need to include in ported sources
"lib/stdio_compat.h"
Change-Id: I5add615dd19c5af9c767ccbfb1bd5a4e466741cb
2013-01-18 15:16:59 +00:00
|
|
|
#define feof _feof_
|
|
|
|
#define fprintf _fprintf_
|
2017-12-24 17:58:33 +00:00
|
|
|
#undef stdout
|
2017-01-21 20:18:31 +00:00
|
|
|
#define stdout _stdout_
|
2017-12-24 17:58:33 +00:00
|
|
|
#undef stderr
|
2017-01-21 20:18:31 +00:00
|
|
|
#define stderr _stderr_
|
2019-07-20 03:51:07 +00:00
|
|
|
#undef getc
|
2018-02-11 20:34:30 +00:00
|
|
|
#define getc fgetc
|
|
|
|
|
stdio compat layer for plugins
This is attempt to simplify porting programs to rockbox (as plugins).
Currently this compat layer implements:
fopen(), fclose(), fflush(), fread(), fwrite(), fseek(), fseeko(),
ftell(), ftello(), fgetc(), ungetc(), fputc(), fgets(), clearerr(),
ferror(), feof(), fprintf()
In order to use it you need to include in ported sources
"lib/stdio_compat.h"
Change-Id: I5add615dd19c5af9c767ccbfb1bd5a4e466741cb
2013-01-18 15:16:59 +00:00
|
|
|
typedef struct {
|
|
|
|
int fd;
|
|
|
|
int unget_char;
|
|
|
|
int error;
|
|
|
|
} _FILE_;
|
|
|
|
|
2017-01-21 20:18:31 +00:00
|
|
|
extern _FILE_ *_stdout_, *_stderr_;
|
|
|
|
|
stdio compat layer for plugins
This is attempt to simplify porting programs to rockbox (as plugins).
Currently this compat layer implements:
fopen(), fclose(), fflush(), fread(), fwrite(), fseek(), fseeko(),
ftell(), ftello(), fgetc(), ungetc(), fputc(), fgets(), clearerr(),
ferror(), feof(), fprintf()
In order to use it you need to include in ported sources
"lib/stdio_compat.h"
Change-Id: I5add615dd19c5af9c767ccbfb1bd5a4e466741cb
2013-01-18 15:16:59 +00:00
|
|
|
_FILE_ *_fopen_(const char *path, const char *mode);
|
|
|
|
int _fclose_(_FILE_ *stream);
|
|
|
|
int _fflush_(_FILE_ *stream);
|
|
|
|
size_t _fread_(void *ptr, size_t size, size_t nmemb, _FILE_ *stream);
|
|
|
|
size_t _fwrite_(const void *ptr, size_t size, size_t nmemb, _FILE_ *stream);
|
|
|
|
int _fseek_(_FILE_ *stream, long offset, int whence);
|
|
|
|
long _ftell_(_FILE_ *stream);
|
|
|
|
int _fgetc_(_FILE_ *stream);
|
|
|
|
int _ungetc_(int c, _FILE_ *stream);
|
|
|
|
int _fputc_(int c, _FILE_ *stream);
|
|
|
|
char *_fgets_(char *s, int size, _FILE_ *stream);
|
|
|
|
int _unlink_(const char *pathname);
|
|
|
|
void _clearerr_(_FILE_ *stream);
|
|
|
|
int _ferror_(_FILE_ *stream);
|
|
|
|
int _feof_(_FILE_ *stream);
|
|
|
|
int _fprintf_(_FILE_ *stream, const char *format, ...);
|