diff options
Diffstat (limited to 'apps/plugin.h')
-rw-r--r-- | apps/plugin.h | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/apps/plugin.h b/apps/plugin.h index 96a9aabe1d..896565e9a0 100644 --- a/apps/plugin.h +++ b/apps/plugin.h | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <stdbool.h> | 32 | #include <stdbool.h> |
33 | #include <stdio.h> | 33 | #include <stdio.h> |
34 | #include <stdlib.h> | 34 | #include <stdlib.h> |
35 | #include <sys/types.h> | ||
35 | #include "config.h" | 36 | #include "config.h" |
36 | #include "dir.h" | 37 | #include "dir.h" |
37 | #include "kernel.h" | 38 | #include "kernel.h" |
@@ -51,7 +52,9 @@ | |||
51 | 52 | ||
52 | #ifdef PLUGIN | 53 | #ifdef PLUGIN |
53 | #if defined(DEBUG) || defined(SIMULATOR) | 54 | #if defined(DEBUG) || defined(SIMULATOR) |
55 | #undef DEBUGF | ||
54 | #define DEBUGF rb->debugf | 56 | #define DEBUGF rb->debugf |
57 | #undef LDEBUGF | ||
55 | #define LDEBUGF rb->debugf | 58 | #define LDEBUGF rb->debugf |
56 | #else | 59 | #else |
57 | #define DEBUGF(...) | 60 | #define DEBUGF(...) |
@@ -59,13 +62,19 @@ | |||
59 | #endif | 62 | #endif |
60 | #endif | 63 | #endif |
61 | 64 | ||
65 | #ifdef SIMULATOR | ||
66 | #define PREFIX(_x_) sim_ ## _x_ | ||
67 | #else | ||
68 | #define PREFIX(_x_) _x_ | ||
69 | #endif | ||
70 | |||
62 | /* increase this every time the api struct changes */ | 71 | /* increase this every time the api struct changes */ |
63 | #define PLUGIN_API_VERSION 31 | 72 | #define PLUGIN_API_VERSION 32 |
64 | 73 | ||
65 | /* update this to latest version if a change to the api struct breaks | 74 | /* update this to latest version if a change to the api struct breaks |
66 | backwards compatibility (and please take the opportunity to sort in any | 75 | backwards compatibility (and please take the opportunity to sort in any |
67 | new function which are "waiting" at the end of the function table) */ | 76 | new function which are "waiting" at the end of the function table) */ |
68 | #define PLUGIN_MIN_API_VERSION 29 | 77 | #define PLUGIN_MIN_API_VERSION 32 |
69 | 78 | ||
70 | /* plugin return codes */ | 79 | /* plugin return codes */ |
71 | enum plugin_status { | 80 | enum plugin_status { |
@@ -165,17 +174,17 @@ struct plugin_api { | |||
165 | void (*button_clear_queue)(void); | 174 | void (*button_clear_queue)(void); |
166 | 175 | ||
167 | /* file */ | 176 | /* file */ |
168 | int (*open)(const char* pathname, int flags); | 177 | int (*PREFIX(open))(const char* pathname, int flags); |
169 | int (*close)(int fd); | 178 | int (*close)(int fd); |
170 | ssize_t (*read)(int fd, void* buf, size_t count); | 179 | ssize_t (*read)(int fd, void* buf, size_t count); |
171 | off_t (*lseek)(int fd, off_t offset, int whence); | 180 | off_t (*lseek)(int fd, off_t offset, int whence); |
172 | int (*creat)(const char *pathname, mode_t mode); | 181 | int (*PREFIX(creat))(const char *pathname, mode_t mode); |
173 | ssize_t (*write)(int fd, const void* buf, size_t count); | 182 | ssize_t (*write)(int fd, const void* buf, size_t count); |
174 | int (*remove)(const char* pathname); | 183 | int (*PREFIX(remove))(const char* pathname); |
175 | int (*rename)(const char* path, const char* newname); | 184 | int (*PREFIX(rename))(const char* path, const char* newname); |
176 | int (*ftruncate)(int fd, off_t length); | 185 | int (*PREFIX(ftruncate))(int fd, off_t length); |
177 | off_t (*filesize)(int fd); | 186 | off_t (*PREFIX(filesize))(int fd); |
178 | int (*fprintf)(int fd, const char *fmt, ...); | 187 | int (*fdprintf)(int fd, const char *fmt, ...); |
179 | int (*read_line)(int fd, char* buffer, int buffer_size); | 188 | int (*read_line)(int fd, char* buffer, int buffer_size); |
180 | bool (*settings_parseline)(char* line, char** name, char** value); | 189 | bool (*settings_parseline)(char* line, char** name, char** value); |
181 | #ifndef SIMULATOR | 190 | #ifndef SIMULATOR |
@@ -188,7 +197,7 @@ struct plugin_api { | |||
188 | struct dirent* (*readdir)(DIR* dir); | 197 | struct dirent* (*readdir)(DIR* dir); |
189 | 198 | ||
190 | /* kernel/ system */ | 199 | /* kernel/ system */ |
191 | void (*sleep)(int ticks); | 200 | void (*PREFIX(sleep))(int ticks); |
192 | void (*yield)(void); | 201 | void (*yield)(void); |
193 | long* current_tick; | 202 | long* current_tick; |
194 | long (*default_event_handler)(long event); | 203 | long (*default_event_handler)(long event); |
@@ -213,6 +222,9 @@ struct plugin_api { | |||
213 | void* (*memcpy)(void *out, const void *in, size_t n); | 222 | void* (*memcpy)(void *out, const void *in, size_t n); |
214 | const char *_ctype_; | 223 | const char *_ctype_; |
215 | int (*atoi)(const char *str); | 224 | int (*atoi)(const char *str); |
225 | char *(*strchr)(const char *s, int c); | ||
226 | char *(*strcat)(char *s1, const char *s2); | ||
227 | int (*memcmp)(const void *s1, const void *s2, size_t n); | ||
216 | 228 | ||
217 | /* sound */ | 229 | /* sound */ |
218 | void (*mpeg_sound_set)(int setting, int value); | 230 | void (*mpeg_sound_set)(int setting, int value); |
@@ -225,7 +237,7 @@ struct plugin_api { | |||
225 | #endif | 237 | #endif |
226 | 238 | ||
227 | /* playback control */ | 239 | /* playback control */ |
228 | void (*mpeg_play)(int offset); | 240 | void (*PREFIX(mpeg_play))(int offset); |
229 | void (*mpeg_stop)(void); | 241 | void (*mpeg_stop)(void); |
230 | void (*mpeg_pause)(void); | 242 | void (*mpeg_pause)(void); |
231 | void (*mpeg_resume)(void); | 243 | void (*mpeg_resume)(void); |
@@ -295,10 +307,6 @@ struct plugin_api { | |||
295 | 307 | ||
296 | /* new stuff at the end, sort into place next time | 308 | /* new stuff at the end, sort into place next time |
297 | the API gets incompatible */ | 309 | the API gets incompatible */ |
298 | |||
299 | char *(*strchr)(const char *s, int c); | ||
300 | char *(*strcat)(char *s1, const char *s2); | ||
301 | int (*memcmp)(const void *s1, const void *s2, size_t n); | ||
302 | }; | 310 | }; |
303 | 311 | ||
304 | /* defined by the plugin loader (plugin.c) */ | 312 | /* defined by the plugin loader (plugin.c) */ |