From 52986fb79ea70f09fff8000d13dc56b8e1e237d4 Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Sat, 19 May 2007 19:13:56 +0000 Subject: Fix name collision on misc.h between zxbox and core. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13420 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/zxbox/SOURCES | 2 +- apps/plugins/zxbox/misc.c | 139 ------------------------------------------ apps/plugins/zxbox/misc.h | 38 ------------ apps/plugins/zxbox/snapshot.c | 4 +- apps/plugins/zxbox/spconf.c | 4 +- apps/plugins/zxbox/spkey.c | 4 +- apps/plugins/zxbox/spmain.c | 6 +- apps/plugins/zxbox/spsound.c | 4 +- apps/plugins/zxbox/sptape.c | 4 +- apps/plugins/zxbox/zxmisc.c | 139 ++++++++++++++++++++++++++++++++++++++++++ 10 files changed, 153 insertions(+), 191 deletions(-) delete mode 100644 apps/plugins/zxbox/misc.c delete mode 100644 apps/plugins/zxbox/misc.h create mode 100644 apps/plugins/zxbox/zxmisc.c diff --git a/apps/plugins/zxbox/SOURCES b/apps/plugins/zxbox/SOURCES index af5cc7aba0..ae0307135f 100644 --- a/apps/plugins/zxbox/SOURCES +++ b/apps/plugins/zxbox/SOURCES @@ -3,7 +3,7 @@ helpers.c interf.c keynames.c loadim.c -misc.c +zxmisc.c rom_imag.c snapshot.c spconf.c diff --git a/apps/plugins/zxbox/misc.c b/apps/plugins/zxbox/misc.c deleted file mode 100644 index c293677e16..0000000000 --- a/apps/plugins/zxbox/misc.c +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (C) 1996-1998 Szeredi Miklos - * Email: mszeredi@inf.bme.hu - * - * 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. See the file COPYING. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -#include "misc.h" -#include "zxconfig.h" -#include -#include -#include -#include -#include "helpers.h" -#include "zxconfig.h" -#define DIR_SEP_CHAR '/' - -char *get_base_name(char *fname) -{ - char *p; - - p = fname; - for(; *p; p++); - for(; p >= fname && *p != DIR_SEP_CHAR; p--); - return ++p; -} - - -int check_ext(const char *filename, const char *ext) -{ - int flen, elen; - int i; - - flen = (int) rb->strlen(filename); - elen = (int) rb->strlen(ext); - - if(flen <= elen + 1) return 0; - - if(filename[flen-elen-1] != '.') return 0; - for(i = 0; i < elen; i++) if(filename[flen-elen+i] != toupper(ext[i])) break; - if(i == elen) return 1; - for(i = 0; i < elen; i++) if(filename[flen-elen+i] != tolower(ext[i])) break; - if(i == elen) return 1; - return 0; -} - -void add_extension(char *filename, const char *ext) -{ - int i; - int upper; - - i = (int) rb->strlen(filename); - if(filename[i] > 64 && filename[i] < 96) upper = 1; - else upper = 0; - - filename[i++] = '.'; - if(upper) - for(; *ext; i++, ext++) filename[i] = toupper(*ext); - else - for(; *ext; i++, ext++) filename[i] = tolower(*ext); -} - -int file_exist(const char *filename) -{ - /*FILE *fp;*/ - int fd; - - fd = rb->open(filename, O_RDONLY); - if(fd != NULL) { - rb->close(fd); - return 1; - } - else return 0; -/* if(errno == ENOENT) return 0; - return 1;*/ -} - -int try_extension(char *filename, const char *ext) -{ - int tend; - - tend = (int) rb->strlen(filename); - add_extension(filename, ext); - if(file_exist(filename)) return 1; - - filename[tend] = '\0'; - return 0; -} - -void *malloc_err(size_t size) -{ - char *p; - - p = (char *) my_malloc(size); - if(p == NULL) { - // fprintf(stderr, "Out of memory!\n"); - /*exit(1);*/ - } - return (void *) p; -} - -char *make_string(char *ostr, const char *nstr) -{ - if(ostr != NULL) /*free(ostr)*/ostr=0; - ostr = malloc_err(rb->strlen(nstr) + 1); - rb->strcpy(ostr, nstr); - return ostr; -} - -void free_string(char *ostr) -{ - if(ostr != NULL) /*free(ostr)*/ostr=0; -} - -int mis_strcasecmp(const char *s1, const char *s2) -{ - int c1, c2; - - for(;; s1++, s2++) { - c1 = tolower(*s1); - c2 = tolower(*s2); - - if(!c1 || c1 != c2) break; - } - return c1-c2; -} diff --git a/apps/plugins/zxbox/misc.h b/apps/plugins/zxbox/misc.h deleted file mode 100644 index 2dc9f60105..0000000000 --- a/apps/plugins/zxbox/misc.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 1996-1998 Szeredi Miklos - * Email: mszeredi@inf.bme.hu - * - * 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. See the file COPYING. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -#ifndef MISC_H -#define MISC_H - -#include - -extern char *get_base_name(char *fname); -extern int check_ext(const char *filename, const char *ext); -extern void add_extension(char *filename, const char *ext); -extern int file_exist(const char *filename); -extern int try_extension(char *filename, const char *ext); -extern char *spif_get_tape_fileinfo(int *startp, int *nump); -extern void *malloc_err(size_t size); -extern char *make_string(char *ostr, const char *nstr); -extern void free_string(char *ostr); - -extern int mis_strcasecmp(const char *s1, const char *s2); - -#endif /* MISC_H */ diff --git a/apps/plugins/zxbox/snapshot.c b/apps/plugins/zxbox/snapshot.c index 5528b710c2..d693d1f6b8 100644 --- a/apps/plugins/zxbox/snapshot.c +++ b/apps/plugins/zxbox/snapshot.c @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 1996-1998 Szeredi Miklos * Email: mszeredi@inf.bme.hu * @@ -18,7 +18,7 @@ * */ -#include "misc.h" +#include "zxmisc.h" #include "helpers.h" #include "spperif.h" #include "z80.h" diff --git a/apps/plugins/zxbox/spconf.c b/apps/plugins/zxbox/spconf.c index 952b3c4c12..d316ad0fbf 100644 --- a/apps/plugins/zxbox/spconf.c +++ b/apps/plugins/zxbox/spconf.c @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 1996-1998 Szeredi Miklos * Email: mszeredi@inf.bme.hu * @@ -17,7 +17,7 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ -#include "misc.h" +#include "zxmisc.h" #include "spconf_p.h" #include "interf.h" #include "spscr_p.h" diff --git a/apps/plugins/zxbox/spkey.c b/apps/plugins/zxbox/spkey.c index fff2737776..a21aed6af2 100644 --- a/apps/plugins/zxbox/spkey.c +++ b/apps/plugins/zxbox/spkey.c @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 1996-1998 Szeredi Miklos * Email: mszeredi@inf.bme.hu * @@ -19,7 +19,7 @@ */ /* #define DEBUG_KEYS */ -#include "misc.h" +#include "zxmisc.h" #include "spkey.h" #include "spkey_p.h" diff --git a/apps/plugins/zxbox/spmain.c b/apps/plugins/zxbox/spmain.c index b153b4191f..3f0bc9319e 100644 --- a/apps/plugins/zxbox/spmain.c +++ b/apps/plugins/zxbox/spmain.c @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 1996-1998 Szeredi Miklos * Email: mszeredi@inf.bme.hu * @@ -17,7 +17,7 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ -#include "misc.h" +#include "zxmisc.h" #include "zxconfig.h" #include "lib/configfile.h" #include "lib/oldmenuapi.h" @@ -361,7 +361,7 @@ static bool zxbox_menu(void) { "Options", NULL }, { "Quit", NULL }, }; - + m = menu_init(rb,items, sizeof(items) / sizeof(*items), NULL, NULL, NULL, NULL); diff --git a/apps/plugins/zxbox/spsound.c b/apps/plugins/zxbox/spsound.c index c99c1e6729..f9a4c6caa7 100644 --- a/apps/plugins/zxbox/spsound.c +++ b/apps/plugins/zxbox/spsound.c @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 1996-1998 Szeredi Miklos 2006 Anton Romanov * Email: mszeredi@inf.bme.hu * @@ -25,7 +25,7 @@ #include "zxconfig.h" #include "spperif.h" #include "z80.h" -#include "misc.h" +#include "zxmisc.h" #include "interf.h" #include "spmain.h" diff --git a/apps/plugins/zxbox/sptape.c b/apps/plugins/zxbox/sptape.c index 76817ca68c..f0e04de2fb 100644 --- a/apps/plugins/zxbox/sptape.c +++ b/apps/plugins/zxbox/sptape.c @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 1996-1998 Szeredi Miklos * Email: mszeredi@inf.bme.hu * @@ -17,7 +17,7 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ -#include "misc.h" +#include "zxmisc.h" #include "sptape.h" #include "tapefile.h" diff --git a/apps/plugins/zxbox/zxmisc.c b/apps/plugins/zxbox/zxmisc.c new file mode 100644 index 0000000000..df147be7bf --- /dev/null +++ b/apps/plugins/zxbox/zxmisc.c @@ -0,0 +1,139 @@ +/* + * Copyright (C) 1996-1998 Szeredi Miklos + * Email: mszeredi@inf.bme.hu + * + * 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. See the file COPYING. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include "zxmisc.h" +#include "zxconfig.h" +#include +#include +#include +#include +#include "helpers.h" +#include "zxconfig.h" +#define DIR_SEP_CHAR '/' + +char *get_base_name(char *fname) +{ + char *p; + + p = fname; + for(; *p; p++); + for(; p >= fname && *p != DIR_SEP_CHAR; p--); + return ++p; +} + + +int check_ext(const char *filename, const char *ext) +{ + int flen, elen; + int i; + + flen = (int) rb->strlen(filename); + elen = (int) rb->strlen(ext); + + if(flen <= elen + 1) return 0; + + if(filename[flen-elen-1] != '.') return 0; + for(i = 0; i < elen; i++) if(filename[flen-elen+i] != toupper(ext[i])) break; + if(i == elen) return 1; + for(i = 0; i < elen; i++) if(filename[flen-elen+i] != tolower(ext[i])) break; + if(i == elen) return 1; + return 0; +} + +void add_extension(char *filename, const char *ext) +{ + int i; + int upper; + + i = (int) rb->strlen(filename); + if(filename[i] > 64 && filename[i] < 96) upper = 1; + else upper = 0; + + filename[i++] = '.'; + if(upper) + for(; *ext; i++, ext++) filename[i] = toupper(*ext); + else + for(; *ext; i++, ext++) filename[i] = tolower(*ext); +} + +int file_exist(const char *filename) +{ + /*FILE *fp;*/ + int fd; + + fd = rb->open(filename, O_RDONLY); + if(fd != NULL) { + rb->close(fd); + return 1; + } + else return 0; +/* if(errno == ENOENT) return 0; + return 1;*/ +} + +int try_extension(char *filename, const char *ext) +{ + int tend; + + tend = (int) rb->strlen(filename); + add_extension(filename, ext); + if(file_exist(filename)) return 1; + + filename[tend] = '\0'; + return 0; +} + +void *malloc_err(size_t size) +{ + char *p; + + p = (char *) my_malloc(size); + if(p == NULL) { + // fprintf(stderr, "Out of memory!\n"); + /*exit(1);*/ + } + return (void *) p; +} + +char *make_string(char *ostr, const char *nstr) +{ + if(ostr != NULL) /*free(ostr)*/ostr=0; + ostr = malloc_err(rb->strlen(nstr) + 1); + rb->strcpy(ostr, nstr); + return ostr; +} + +void free_string(char *ostr) +{ + if(ostr != NULL) /*free(ostr)*/ostr=0; +} + +int mis_strcasecmp(const char *s1, const char *s2) +{ + int c1, c2; + + for(;; s1++, s2++) { + c1 = tolower(*s1); + c2 = tolower(*s2); + + if(!c1 || c1 != c2) break; + } + return c1-c2; +} -- cgit v1.2.3