diff options
Diffstat (limited to 'apps/plugins')
31 files changed, 88 insertions, 60 deletions
diff --git a/apps/plugins/calculator.c b/apps/plugins/calculator.c index 942f031890..c19d6bbc5b 100644 --- a/apps/plugins/calculator.c +++ b/apps/plugins/calculator.c @@ -102,6 +102,9 @@ PLUGIN_HEADER #define X_5_POS (X_4_POS + REC_WIDTH) /* x5 = 110, column 111 left blank */ #define SIGN(x) ((x)<0?-1:1) +#ifndef ABS +#define ABS(a) (((a) < 0) ? -(a) : (a)) +#endif /* variable button definitions */ #if CONFIG_KEYPAD == RECORDER_PAD diff --git a/apps/plugins/doom/d_deh.c b/apps/plugins/doom/d_deh.c index d3f7496885..82426c1bab 100644 --- a/apps/plugins/doom/d_deh.c +++ b/apps/plugins/doom/d_deh.c @@ -44,7 +44,7 @@ #include "d_think.h" #include "w_wad.h" -#include "sscanf.h" +#include <stdio.h> /* sscanf */ #include "rockmacros.h" #define TRUE 1 diff --git a/apps/plugins/doom/doom.make b/apps/plugins/doom/doom.make index bdc32230eb..54a63eb707 100644 --- a/apps/plugins/doom/doom.make +++ b/apps/plugins/doom/doom.make @@ -13,7 +13,7 @@ DOOMBUILDDIR := $(BUILDDIR)/apps/plugins/doom ROCKS += $(DOOMBUILDDIR)/doom.rock DOOM_SRC := $(call preprocess, $(DOOMSRCDIR)/SOURCES) -DOOM_SRC += $(ROOTDIR)/firmware/common/sscanf.c +DOOM_SRC += $(ROOTDIR)/firmware/libc/sscanf.c DOOM_OBJ := $(call c2obj, $(DOOM_SRC)) # add source files to OTHER_SRC to get automatic dependencies diff --git a/apps/plugins/doom/rockmacros.h b/apps/plugins/doom/rockmacros.h index e066fe861c..89c943622a 100644 --- a/apps/plugins/doom/rockmacros.h +++ b/apps/plugins/doom/rockmacros.h @@ -33,9 +33,13 @@ extern bool doomexit; int printf(const char *fmt, ...); int fileexists(const char * fname); char *my_strtok( char * s, const char * delim ); +#undef alloca #define alloca __builtin_alloca -#define fdprintf(...) rb->fdprintf(__VA_ARGS__) +#undef fdprintf +#define fdprintf(...) rb->fdprintf(__VA_ARGS__) +#undef vsnprintf #define vsnprintf(...) rb->vsnprintf(__VA_ARGS__) +#undef read_line #define read_line(a,b,c) rb->read_line((a),(b),(c)) #ifdef SIMULATOR @@ -52,19 +56,33 @@ int my_close(int id); #define filesize(a) rb->filesize((a)) #define read(a,b,c) rb->read((a),(b),(c)) #define write(a,b,c) rb->write((a),(b),(c)) +#undef strtok #define strtok(a,b) my_strtok((a),(b)) +#undef strcat #define strcat(a,b) rb->strcat((a),(b)) +#undef memset #define memset(a,b,c) rb->memset((a),(b),(c)) +#undef memmove #define memmove(a,b,c) rb->memmove((a),(b),(c)) +#undef memcmp #define memcmp(a,b,c) rb->memcmp((a),(b),(c)) +#undef memchr #define memchr(a,b,c) rb->memchr((a),(b),(c)) +#undef strcpy #define strcpy(a,b) rb->strcpy((a),(b)) +#undef strlen #define strlen(a) rb->strlen((a)) +#undef strcmp #define strcmp(a,b) rb->strcmp((a),(b)) +#undef strncmp #define strncmp(a,b,c) rb->strncmp((a),(b),(c)) +#undef strchr #define strchr(a,b) rb->strchr((a),(b)) +#undef strrchr #define strrchr(a,b) rb->strrchr((a),(b)) +#undef strcasecmp #define strcasecmp(a,b) rb->strcasecmp((a),(b)) +#undef strncasecmp #define strncasecmp(a,b,c) rb->strncasecmp((a),(b),(c)) #define srand(a) rb->srand((a)) #define rand() rb->rand() diff --git a/apps/plugins/frotz/frotz.c b/apps/plugins/frotz/frotz.c index 96029b85cb..f64431f14e 100644 --- a/apps/plugins/frotz/frotz.c +++ b/apps/plugins/frotz/frotz.c @@ -285,14 +285,14 @@ void os_beep(int volume) static unsigned char unget_buf; static int unget_file; -int ungetc(int c, int f) +int frotz_ungetc(int c, int f) { unget_file = f; unget_buf = c; return c; } -int fgetc(int f) +int frotz_fgetc(int f) { unsigned char cb; if (unget_file == f) @@ -305,7 +305,7 @@ int fgetc(int f) return cb; } -int fputc(int c, int f) +int frotz_fputc(int c, int f) { unsigned char cb = c; if (rb->write(f, &cb, 1) != 1) diff --git a/apps/plugins/frotz/frotzplugin.h b/apps/plugins/frotz/frotzplugin.h index 8caddb470d..1a52bdb913 100644 --- a/apps/plugins/frotz/frotzplugin.h +++ b/apps/plugins/frotz/frotzplugin.h @@ -37,9 +37,12 @@ /* * we need functions for character io */ -extern int ungetc(int c, int f); -extern int fgetc(int f); -extern int fputc(int c, int f); +extern int frotz_ungetc(int c, int f); +#define ungetc frotz_ungetc +extern int frotz_fgetc(int f); +#define fgetc frotz_fgetc +extern int frotz_fputc(int c, int f); +#define fputc frotz_fputc /* * this is used instead of os_read_key for more prompts and the like diff --git a/apps/plugins/imageviewer/png/png.c b/apps/plugins/imageviewer/png/png.c index 310b08d990..c398af70c5 100644 --- a/apps/plugins/imageviewer/png/png.c +++ b/apps/plugins/imageviewer/png/png.c @@ -1359,7 +1359,7 @@ int load_image(char *filename, struct image_info *info, } else { if (!running_slideshow) { - rb->snprintf(print, sizeof(print), "loading %lu bytes", image_size); + rb->snprintf(print, sizeof(print), "loading %zu bytes", image_size); rb->lcd_puts(0, 1, print); rb->lcd_update(); } diff --git a/apps/plugins/invadrox.c b/apps/plugins/invadrox.c index 3e5c98e2a3..851487cf9a 100644 --- a/apps/plugins/invadrox.c +++ b/apps/plugins/invadrox.c @@ -81,6 +81,10 @@ PLUGIN_HEADER #define DBG(format, arg...) {} #endif +#ifndef ABS +#define ABS(a) (((a) < 0) ? -(a) : (a)) +#endif + #if CONFIG_KEYPAD == IRIVER_H100_PAD #define QUIT BUTTON_OFF diff --git a/apps/plugins/lib/buflib.c b/apps/plugins/lib/buflib.c index 5d03ca4bb9..930e49d02e 100644 --- a/apps/plugins/lib/buflib.c +++ b/apps/plugins/lib/buflib.c @@ -23,8 +23,8 @@ * ****************************************************************************/ +#include <stdlib.h> /* for abs() */ #include "buflib.h" - /* The main goal of this design is fast fetching of the pointer for a handle. * For that reason, the handles are stored in a table at the end of the buffer * with a fixed address, so that returning the pointer for a handle is a simple @@ -311,7 +311,7 @@ buflib_free(struct buflib_context *ctx, int handle_num) while (next_block < freed_block) { block = next_block; - next_block += ABS(block->val); + next_block += abs(block->val); } /* If next_block == block, the above loop didn't go anywhere. If it did, * and the block before this one is empty, we can combine them. diff --git a/apps/plugins/lib/jhash.h b/apps/plugins/lib/jhash.h index 97d1ac3d93..7699e24587 100644 --- a/apps/plugins/lib/jhash.h +++ b/apps/plugins/lib/jhash.h @@ -24,8 +24,8 @@ #ifndef _LIB_JHASH_H_ #define _LIB_JHASH_H_ #include <inttypes.h> /* defines uint32_t etc */ -#include <sys/types.h> -#include <plugin.h> +#include <string.h> /* size_t */ +#include "plugin.h" /* hashw() -- hash an array of uint32_t into a 32-bit value diff --git a/apps/plugins/lib/strncpy.c b/apps/plugins/lib/strncpy.c index 7c1973ba66..f80e759969 100644 --- a/apps/plugins/lib/strncpy.c +++ b/apps/plugins/lib/strncpy.c @@ -39,6 +39,7 @@ QUICKREF #include <string.h> #include <limits.h> +#include "plugin.h" /*SUPPRESS 560*/ /*SUPPRESS 530*/ diff --git a/apps/plugins/lua/gmtime.c b/apps/plugins/lua/gmtime.c index f13c855de8..deb24e08c9 100644 --- a/apps/plugins/lua/gmtime.c +++ b/apps/plugins/lua/gmtime.c @@ -20,7 +20,7 @@ const short __spm[13] = (31+28+31+30+31+30+31+31+30+31+30+31), }; -int __isleap(int year) { +static inline int isleap(int year) { /* every fourth year is a leap year except for century years that are * not divisible by 400. */ /* return (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)); */ @@ -36,7 +36,7 @@ struct tm *gmtime(const time_t *timep) { work=*timep/(SPD); r.tm_wday=(4+work)%7; for (i=1970; ; ++i) { - register time_t k=__isleap(i)?366:365; + register time_t k=isleap(i)?366:365; if (work>=k) work-=k; else @@ -46,7 +46,7 @@ struct tm *gmtime(const time_t *timep) { r.tm_yday=work; r.tm_mday=1; - if (__isleap(i) && (work>58)) { + if (isleap(i) && (work>58)) { if (work==59) r.tm_mday=2; /* 29.2. */ work-=1; } diff --git a/apps/plugins/midi/midiplay.c b/apps/plugins/midi/midiplay.c index b225014fce..2c685f2e4b 100644 --- a/apps/plugins/midi/midiplay.c +++ b/apps/plugins/midi/midiplay.c @@ -450,6 +450,8 @@ static int midimain(const void * filename) enum plugin_status plugin_start(const void* parameter) { int retval; + PLUGINLIB_EXIT_INIT; + PLUGIN_IRAM_INIT(rb) if (parameter == NULL) diff --git a/apps/plugins/midi/midiutil.c b/apps/plugins/midi/midiutil.c index f1b6668be2..87e0f9d9a4 100644 --- a/apps/plugins/midi/midiutil.c +++ b/apps/plugins/midi/midiutil.c @@ -163,8 +163,3 @@ int printf(const char *fmt, ...) return 1; } -void exit(int code) -{ - code = code; /* Stub function, kill warning for now */ -} - diff --git a/apps/plugins/midi/midiutil.h b/apps/plugins/midi/midiutil.h index f984e71aff..b1ed6569b7 100644 --- a/apps/plugins/midi/midiutil.h +++ b/apps/plugins/midi/midiutil.h @@ -21,6 +21,8 @@ #define FRACTSIZE 12 +#include "lib/pluginlib_exit.h" + #define BUF_SIZE 16384 /* 64 kB output buffers */ #define NBUF 2 @@ -145,7 +147,6 @@ int readFourBytes(int file); int readVarData(int file); int eof(int fd); unsigned char * readData(int file, int len); -void exit(int code); #define malloc(n) my_malloc(n) void * my_malloc(int size); diff --git a/apps/plugins/mpegplayer/disk_buf.c b/apps/plugins/mpegplayer/disk_buf.c index 4f37bfa5bf..59d4816fb4 100644 --- a/apps/plugins/mpegplayer/disk_buf.c +++ b/apps/plugins/mpegplayer/disk_buf.c @@ -855,7 +855,7 @@ bool disk_buf_init(void) disk_buf.pos_last = 0; disk_buf.low_wm = DISK_BUF_LOW_WATERMARK; - disk_buf.start = mpeg_malloc_all(&disk_buf.size, MPEG_ALLOC_DISKBUF); + disk_buf.start = mpeg_malloc_all((size_t*)&disk_buf.size, MPEG_ALLOC_DISKBUF); if (disk_buf.start == NULL) return false; diff --git a/apps/plugins/random_folder_advance_config.c b/apps/plugins/random_folder_advance_config.c index d5e7a10cdc..f7bb790dc1 100644 --- a/apps/plugins/random_folder_advance_config.c +++ b/apps/plugins/random_folder_advance_config.c @@ -23,7 +23,7 @@ PLUGIN_HEADER -static bool abort; +static bool cancel; static int fd; static int dirs_count; static int lasttick; @@ -70,7 +70,7 @@ void traversedir(char* location, char* name) if (dir) { entry = rb->readdir(dir); while (entry) { - if (abort) + if (cancel) break; /* Skip .. and . */ if (entry->d_name[0] == '.') @@ -113,7 +113,7 @@ void traversedir(char* location, char* name) lasttick = *rb->current_tick; if (rb->action_userabort(TIMEOUT_NOBLOCK)) { - abort = true; + cancel = true; break; } } @@ -213,7 +213,7 @@ bool custom_dir(void) void generate(void) { dirs_count = 0; - abort = false; + cancel = false; fd = rb->open(RFA_FILE,O_CREAT|O_WRONLY, 0666); rb->write(fd,&dirs_count,sizeof(int)); if (fd < 0) @@ -621,7 +621,7 @@ enum plugin_status plugin_start(const void* parameter) { (void)parameter; - abort = false; + cancel = false; return main_menu(); } diff --git a/apps/plugins/rockboy/menu.c b/apps/plugins/rockboy/menu.c index 2f6c3102ff..e081a81d18 100644 --- a/apps/plugins/rockboy/menu.c +++ b/apps/plugins/rockboy/menu.c @@ -158,7 +158,7 @@ static void build_slot_path(char *buf, size_t bufsiz, size_t slot_id) { munge_name(name_buf, strlen(name_buf)); /* glom the whole mess together */ - snprintf(buf, bufsiz, "%s/%s-%ld.rbs", STATE_DIR, name_buf, slot_id + 1); + snprintf(buf, bufsiz, "%s/%s-%zud.rbs", STATE_DIR, name_buf, slot_id + 1); } /* @@ -253,17 +253,17 @@ static void slot_info(char *info_buf, size_t info_bufsiz, size_t slot_id) { if (read(fd, buf, 20) > 0) { buf[20] = '\0'; - snprintf(info_buf, info_bufsiz, "%ld. %s", slot_id + 1, buf); + snprintf(info_buf, info_bufsiz, "%zud. %s", slot_id + 1, buf); } else - snprintf(info_buf, info_bufsiz, "%ld. ERROR", slot_id + 1); + snprintf(info_buf, info_bufsiz, "%zud. ERROR", slot_id + 1); close(fd); } else { /* if we couldn't open the file, then the slot is empty */ - snprintf(info_buf, info_bufsiz, "%ld. %s", slot_id + 1, "<Empty>"); + snprintf(info_buf, info_bufsiz, "%zu. %s", slot_id + 1, "<Empty>"); } } diff --git a/apps/plugins/rockboy/rockboy.make b/apps/plugins/rockboy/rockboy.make index ca0ed17a0a..81e9a1f798 100644 --- a/apps/plugins/rockboy/rockboy.make +++ b/apps/plugins/rockboy/rockboy.make @@ -11,7 +11,7 @@ ROCKBOY_SRCDIR = $(APPSDIR)/plugins/rockboy ROCKBOY_OBJDIR = $(BUILDDIR)/apps/plugins/rockboy ROCKBOY_SRC := $(call preprocess, $(ROCKBOY_SRCDIR)/SOURCES) -ROCKBOY_SRC += $(ROOTDIR)/firmware/common/sscanf.c +ROCKBOY_SRC += $(ROOTDIR)/firmware/libc/sscanf.c ROCKBOY_OBJ := $(call c2obj, $(ROCKBOY_SRC)) OTHER_SRC += $(ROCKBOY_SRC) diff --git a/apps/plugins/rockboy/rtc.c b/apps/plugins/rockboy/rtc.c index 6f33bc4f9d..248ebc0714 100644 --- a/apps/plugins/rockboy/rtc.c +++ b/apps/plugins/rockboy/rtc.c @@ -7,7 +7,6 @@ #include "defs.h" #include "mem.h" #include "rtc-gb.h" -#include "sscanf.h" struct rtc rtc; diff --git a/apps/plugins/search.c b/apps/plugins/search.c index ba16b8821b..7edb7e229a 100644 --- a/apps/plugins/search.c +++ b/apps/plugins/search.c @@ -20,7 +20,7 @@ * ****************************************************************************/ #include "plugin.h" -#include "ctype.h" +#include <ctype.h> PLUGIN_HEADER diff --git a/apps/plugins/shortcuts/shortcuts.h b/apps/plugins/shortcuts/shortcuts.h index bfe3540c4d..3d6c421c5a 100644 --- a/apps/plugins/shortcuts/shortcuts.h +++ b/apps/plugins/shortcuts/shortcuts.h @@ -51,7 +51,7 @@ typedef struct sc_file_s extern void *memory_buf; -extern long memory_bufsize; +extern size_t memory_bufsize; extern sc_file_t sc_file; diff --git a/apps/plugins/shortcuts/shortcuts_common.c b/apps/plugins/shortcuts/shortcuts_common.c index dee1657afc..da212a55a3 100644 --- a/apps/plugins/shortcuts/shortcuts_common.c +++ b/apps/plugins/shortcuts/shortcuts_common.c @@ -35,7 +35,7 @@ /* Memory (will be used for entries) */ void *memory_buf; -long memory_bufsize; /* Size of memory_buf in bytes */ +size_t memory_bufsize; /* Size of memory_buf in bytes */ /* The file we're processing */ diff --git a/apps/plugins/stats.c b/apps/plugins/stats.c index eaa1055a73..3420579881 100644 --- a/apps/plugins/stats.c +++ b/apps/plugins/stats.c @@ -24,7 +24,7 @@ PLUGIN_HEADER static int files, dirs, musicfiles, largestdir; static int lasttick; -static bool abort; +static bool cancel; #if CONFIG_KEYPAD == PLAYER_PAD #define STATS_STOP BUTTON_STOP @@ -173,7 +173,7 @@ void traversedir(char* location, char* name) if (dir) { entry = rb->readdir(dir); while (entry) { - if (abort) + if (cancel) break; /* Skip .. and . */ if (rb->strcmp(entry->d_name, ".") && rb->strcmp(entry->d_name, "..")) @@ -206,7 +206,7 @@ void traversedir(char* location, char* name) || button == STATS_STOP_REMOTE #endif ) { - abort = true; + cancel = true; break; } } @@ -229,14 +229,14 @@ enum plugin_status plugin_start(const void* parameter) dirs = 0; musicfiles = 0; largestdir = 0; - abort = false; + cancel = false; rb->splash(HZ, "Counting..."); update_screen(); lasttick = *rb->current_tick; traversedir("", ""); - if (abort) { + if (cancel) { rb->splash(HZ, "Aborted"); return PLUGIN_OK; } diff --git a/apps/plugins/wav2wv.c b/apps/plugins/wav2wv.c index 03900884f9..3211203db9 100644 --- a/apps/plugins/wav2wv.c +++ b/apps/plugins/wav2wv.c @@ -97,8 +97,8 @@ static int32_t temp_buffer [TEMP_SAMPLES] IDATA_ATTR; static int wav2wv(const char *infile) { int in_fd, out_fd, num_chans, error = false, last_buttons; - unsigned int32_t total_bytes_read = 0, total_bytes_written = 0; - unsigned int32_t total_samples, samples_remaining; + uint32_t total_bytes_read = 0, total_bytes_written = 0; + uint32_t total_samples, samples_remaining; int32_t *input_buffer = (int32_t *) audiobuf; unsigned char *output_buffer = (unsigned char *)(audiobuf + 0x100000); char outfile[MAX_PATH]; @@ -180,7 +180,7 @@ static int wav2wv(const char *infile) wvupdate (start_tick, native_header.SampleRate, total_samples, 0, 0, 0); for (samples_remaining = total_samples; samples_remaining;) { - unsigned int32_t samples_count, samples_to_pack, bytes_count; + uint32_t samples_count, samples_to_pack, bytes_count; int cnt, buttons; int32_t value, *lp; signed char *cp; @@ -204,7 +204,7 @@ static int wav2wv(const char *infile) cp = (signed char *) input_buffer; while (samples_to_pack) { - unsigned int32_t samples_this_pass = TEMP_SAMPLES / num_chans; + uint32_t samples_this_pass = TEMP_SAMPLES / num_chans; if (samples_this_pass > samples_to_pack) samples_this_pass = samples_to_pack; diff --git a/apps/plugins/zxbox/helpers.h b/apps/plugins/zxbox/helpers.h index ba8607d5cb..c8cb9c1554 100644 --- a/apps/plugins/zxbox/helpers.h +++ b/apps/plugins/zxbox/helpers.h @@ -7,9 +7,12 @@ extern off_t my_ftell(int); extern void *my_malloc(size_t size); +#undef getc #define getc my_getc -#define malloc my_malloc -#define ftell my_ftell +#undef putc #define putc my_putc +#undef ftell +#define ftell my_ftell +#define malloc my_malloc #endif /* HELPERS_H */ diff --git a/apps/plugins/zxbox/snapshot.c b/apps/plugins/zxbox/snapshot.c index 0b80b64497..468f46667e 100644 --- a/apps/plugins/zxbox/snapshot.c +++ b/apps/plugins/zxbox/snapshot.c @@ -18,8 +18,9 @@ * */ +#include <stdlib.h> +#include <string.h> /* size_t */ #include "zxmisc.h" -#include "helpers.h" #include "spperif.h" #include "z80.h" @@ -29,9 +30,8 @@ #include "spconf.h" -#include <stdio.h> -#include <stdlib.h> -#include <sys/types.h> +/* include this at last to avoid clashes with stdio functions */ +#include "helpers.h" #define COMPRESS_SAVE 1 diff --git a/apps/plugins/zxbox/spconf.c b/apps/plugins/zxbox/spconf.c index 728f78638c..0daabc7d77 100644 --- a/apps/plugins/zxbox/spconf.c +++ b/apps/plugins/zxbox/spconf.c @@ -17,6 +17,10 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ + +#include <stdio.h> +#include <string.h> +#include <ctype.h> #include "zxmisc.h" #include "spconf_p.h" #include "interf.h" @@ -26,11 +30,7 @@ #include "snapshot.h" /* for SN_Z80 and SN_SNA */ #include "tapefile.h" /* for TAP_TAP and TAP_TZX */ #include "zxconfig.h" -#include "stdio.h" -#include "string.h" -#include "sys/types.h" #include "helpers.h" -#include "ctype.h" extern const char *spcf_keynames_ascii[]; diff --git a/apps/plugins/zxbox/sptape.c b/apps/plugins/zxbox/sptape.c index 21f962ea28..80921a0afd 100644 --- a/apps/plugins/zxbox/sptape.c +++ b/apps/plugins/zxbox/sptape.c @@ -31,7 +31,6 @@ #include <stdlib.h> #include <string.h> #include <errno.h> -#include <sys/types.h> #define MAXLINELEN 256 diff --git a/apps/plugins/zxbox/tapefile.c b/apps/plugins/zxbox/tapefile.c index 0e262aa0f7..92f4ea69f6 100644 --- a/apps/plugins/zxbox/tapefile.c +++ b/apps/plugins/zxbox/tapefile.c @@ -29,7 +29,7 @@ #include <stdlib.h> #include <string.h> #include <errno.h> -#include <sys/types.h> +#include "inttypes.h" #include "zxconfig.h" #include "helpers.h" #define max(x, y) ((x) > (y) ? (x) : (y)) diff --git a/apps/plugins/zxbox/zxmisc.h b/apps/plugins/zxbox/zxmisc.h index 4ad25a0604..904af24e3d 100644 --- a/apps/plugins/zxbox/zxmisc.h +++ b/apps/plugins/zxbox/zxmisc.h @@ -21,7 +21,7 @@ #ifndef ZXMISC_H #define ZXMISC_H -#include <sys/types.h> +#include <string.h> /* size_t */ extern char *get_base_name(char *fname); extern int check_ext(const char *filename, const char *ext); |