summaryrefslogtreecommitdiff
path: root/apps/plugins/lib/stdio_compat.h
diff options
context:
space:
mode:
authorMarcin Bukat <marcin.bukat@gmail.com>2013-01-18 16:16:59 +0100
committerFranklin Wei <git@fwei.tk>2017-12-23 20:54:56 -0500
commita8423321b802bff39fe2ba22f2b0a26220a57535 (patch)
tree10ec3a75a1547c6232202664d091388b57917c38 /apps/plugins/lib/stdio_compat.h
parentd35a18f6b4f6b0871cf5369fa9bc2d6ea990fa82 (diff)
downloadrockbox-a8423321b802bff39fe2ba22f2b0a26220a57535.tar.gz
rockbox-a8423321b802bff39fe2ba22f2b0a26220a57535.zip
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
Diffstat (limited to 'apps/plugins/lib/stdio_compat.h')
-rw-r--r--apps/plugins/lib/stdio_compat.h67
1 files changed, 67 insertions, 0 deletions
diff --git a/apps/plugins/lib/stdio_compat.h b/apps/plugins/lib/stdio_compat.h
new file mode 100644
index 0000000000..bb37940296
--- /dev/null
+++ b/apps/plugins/lib/stdio_compat.h
@@ -0,0 +1,67 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2013 by Marcin Bukat
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
15 *
16 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
17 * KIND, either express or implied.
18 *
19 ****************************************************************************/
20
21#include <stddef.h>
22
23#define MAX_STDIO_FILES 8
24
25#undef FILE
26#define FILE _FILE_
27
28#define fopen _fopen_
29#define fclose _fclose_
30#define fflush _fflush_
31#define fread _fread_
32#define fwrite _fwrite_
33#define fseek _fseek_
34#define fseeko _fseek_
35#define ftell _ftell_
36#define ftello _ftell_
37#define fgetc _fgetc_
38#define ungetc _ungetc_
39#define fputc _fputc_
40#define fgets _fgets_
41#define clearerr _clearerr_
42#define ferror _ferror_
43#define feof _feof_
44#define fprintf _fprintf_
45
46typedef struct {
47 int fd;
48 int unget_char;
49 int error;
50} _FILE_;
51
52_FILE_ *_fopen_(const char *path, const char *mode);
53int _fclose_(_FILE_ *stream);
54int _fflush_(_FILE_ *stream);
55size_t _fread_(void *ptr, size_t size, size_t nmemb, _FILE_ *stream);
56size_t _fwrite_(const void *ptr, size_t size, size_t nmemb, _FILE_ *stream);
57int _fseek_(_FILE_ *stream, long offset, int whence);
58long _ftell_(_FILE_ *stream);
59int _fgetc_(_FILE_ *stream);
60int _ungetc_(int c, _FILE_ *stream);
61int _fputc_(int c, _FILE_ *stream);
62char *_fgets_(char *s, int size, _FILE_ *stream);
63int _unlink_(const char *pathname);
64void _clearerr_(_FILE_ *stream);
65int _ferror_(_FILE_ *stream);
66int _feof_(_FILE_ *stream);
67int _fprintf_(_FILE_ *stream, const char *format, ...);