Fixed bug in tool menu, harmonized paths and filename length to 256

This commit is contained in:
fabio.olimpieri 2013-02-10 13:08:05 +00:00
parent d7825a30e6
commit b1b2f85992
8 changed files with 66 additions and 71 deletions

View File

@ -27,6 +27,7 @@
// #define MUT
#define KB_BUFFER_LENGHT 10
#define MAX_PATH_LENGTH 256
extern char salir;
@ -175,9 +176,9 @@ struct computer {
FILE *tap_file;
unsigned char tape_fast_load; // 0 normal load; 1 fast load
unsigned char rewind_on_reset;
unsigned char current_tap[2049];
unsigned char last_selected_file[2049];
unsigned char last_selected_poke_file[2049];
unsigned char current_tap[MAX_PATH_LENGTH];
unsigned char last_selected_file[MAX_PATH_LENGTH];
unsigned char last_selected_poke_file[MAX_PATH_LENGTH];
unsigned char tape_current_bit;
unsigned int tape_block_level;
@ -194,7 +195,7 @@ struct computer {
// Microdrive global variables
FILE *mdr_file; // Current microdrive file
unsigned char mdr_current_mdr[2049]; // current path and name for microdrive file
unsigned char mdr_current_mdr[MAX_PATH_LENGTH]; // current path and name for microdrive file
unsigned char mdr_active; // 0: not installed; 1: installed
unsigned char mdr_paged; // 0: not pagined; 1: pagined
unsigned int mdr_tapehead; // current position in the tape
@ -251,7 +252,7 @@ struct computer {
unsigned char ftp_enable;
unsigned char FTPUser[32];
unsigned char FTPPwd[32];
unsigned char FTPPath[512];
unsigned char FTPPath[MAX_PATH_LENGTH];
unsigned char FTPIp[64];
unsigned char FTPPassive;
unsigned short FTPPort;

View File

@ -68,17 +68,17 @@ struct computer ordenador;
SDL_Surface *screen;
char salir,sound_aborted;
unsigned int *sound[NUM_SNDBUF];
char path_snaps[2049];
char path_taps[2049];
char path_mdrs[2049];
char path_scr1[2049];
char path_scr2[2049];
char path_confs[2049];
char path_tmp[2049];
char load_path_snaps[2049];
char load_path_taps[2049];
char load_path_scr1[2049];
char load_path_poke[2049];
char path_snaps[MAX_PATH_LENGTH];
char path_taps[MAX_PATH_LENGTH];
char path_mdrs[MAX_PATH_LENGTH];
char path_scr1[MAX_PATH_LENGTH];
char path_scr2[MAX_PATH_LENGTH];
char path_confs[MAX_PATH_LENGTH];
char path_tmp[MAX_PATH_LENGTH];
char load_path_snaps[MAX_PATH_LENGTH];
char load_path_taps[MAX_PATH_LENGTH];
char load_path_scr1[MAX_PATH_LENGTH];
char load_path_poke[MAX_PATH_LENGTH];
unsigned int colors[80];
unsigned int jump_frames,curr_frames;
@ -263,7 +263,7 @@ int remove_dir(char *dir)
struct stat st;
dp = opendir (dir);
char str[2049];
char str[MAX_PATH_LENGTH];
if (dp != NULL)
{
@ -765,7 +765,7 @@ int save_config_game(struct computer *object, char *filename, int overwrite) {
void load_config_network(struct computer *object) {
char line[1024],carac,done;
char line[256],carac,done;
int pos;
FILE *fconfig;
unsigned char smb_enable=0, ftp_enable=0, FTPPassive=0;
@ -881,8 +881,8 @@ fclose(fconfig);
int load_config(struct computer *object, char *filename) {
char config_path[1024];
char line[1024],carac,done;
char config_path[MAX_PATH_LENGTH];
char line[256],carac,done;
int pos, key_sdl=0;
FILE *fconfig;
unsigned char volume=255,mode128k=255,issue=255,ntsc=255, joystick1=255,joystick2=255,ay_emul=255,mdr_active=255,
@ -1121,7 +1121,7 @@ int load_config(struct computer *object, char *filename) {
int main(int argc,char *argv[]) {
int bucle,tstados,tstados_screen, argumento,fullscreen,dblbuffer,hwsurface,length;
char gamefile[4096],config_path[1024] ;
char gamefile[MAX_PATH_LENGTH],config_path[MAX_PATH_LENGTH] ;
word PC=0;

View File

@ -25,6 +25,7 @@
#define emulator_h
#define NUM_SNDBUF 2
#define MAX_PATH_LENGTH 256
extern char debug_var;
@ -32,17 +33,17 @@ extern SDL_Surface *screen;
extern Z80FREE procesador;
extern struct computer ordenador;
extern unsigned int *sound[NUM_SNDBUF];
extern char path_snaps[2049];
extern char path_taps[2049];
extern char path_mdrs[2049];
extern char path_scr1[2049];
extern char path_scr2[2049];
extern char path_confs[2049];
extern char path_tmp[2049];
extern char load_path_snaps[2049];
extern char load_path_taps[2049];
extern char load_path_scr1[2049];
extern char load_path_poke[2049];
extern char path_snaps[MAX_PATH_LENGTH];
extern char path_taps[MAX_PATH_LENGTH];
extern char path_mdrs[MAX_PATH_LENGTH];
extern char path_scr1[MAX_PATH_LENGTH];
extern char path_scr2[MAX_PATH_LENGTH];
extern char path_confs[MAX_PATH_LENGTH];
extern char path_tmp[MAX_PATH_LENGTH];
extern char load_path_snaps[MAX_PATH_LENGTH];
extern char load_path_taps[MAX_PATH_LENGTH];
extern char load_path_scr1[MAX_PATH_LENGTH];
extern char load_path_poke[MAX_PATH_LENGTH];
extern unsigned int colors[80];
extern unsigned int jump_frames,curr_frames;

View File

@ -204,7 +204,7 @@ void maybe_load_conf(const char *filename)
{
const char *dir = path_confs;
char *ptr;
char db[256];
char db[MAX_PATH_LENGTH];
char fb[81];
if (filename==NULL) return;
@ -218,7 +218,7 @@ void maybe_load_conf(const char *filename)
ptr = strrchr (fb, '.');
if (ptr) *ptr = 0;
snprintf(db, 255, "%s/%s.conf", dir, fb);
snprintf(db, MAX_PATH_LENGTH-1, "%s/%s.conf", dir, fb);
if (!load_config(&ordenador,db)) msgInfo("Configurations loaded",2000,NULL) ;
}
@ -304,7 +304,7 @@ void create_tapfile_sdl() {
unsigned char *videomem;
int ancho,retorno;
unsigned char nombre2[1024];
unsigned char nombre2[MAX_PATH_LENGTH];
videomem=screen->pixels;
ancho=screen->w;
@ -851,7 +851,7 @@ void create_mdrfile_sdl() {
unsigned char *videomem;
int ancho,retorno,bucle,retval;
unsigned char nombre2[1024];
unsigned char nombre2[MAX_PATH_LENGTH];
videomem=screen->pixels;
ancho=screen->w;
@ -1043,22 +1043,13 @@ static int save_scr(int i)
const char *tape = ordenador.last_selected_file;
char *ptr;
FILE *fichero;
char db[256];
char db[MAX_PATH_LENGTH];
char fb[81];
int retorno,retval, length, retorno2;
char path_scr[2049];
int retorno,retval, retorno2;
retorno2=0; //Stay in menu as default
strcpy(path_scr,getenv("HOME"));
length=strlen(path_scr);
if ((length>0)&&(path_scr[length-1]!='/'))
strcat(path_scr,"/");
//Save only on SD card
if (i==1) strcat(path_scr,"scr"); else
if (i==2) strcat(path_scr,"scr2"); else return 0;
dir = path_scr;
if (i==1) dir=path_scr1; else
if (i==2) dir=path_scr2; else return 0;
// Name (for saves) - TO CHECK
if (tape && strrchr(tape, '/'))
@ -1072,7 +1063,7 @@ static int save_scr(int i)
// Save SCR file
snprintf(db, 255, "%s/%s.scr", dir, fb);
snprintf(db, MAX_PATH_LENGTH-1, "%s/%s.scr", dir, fb);
fichero=fopen(db,"r");
@ -1493,7 +1484,7 @@ switch (which)
static int tools()
{
int opt , retorno;
int submenus[4];
int submenus[4], old_port;
memset(submenus, 0, sizeof(submenus));
@ -1504,12 +1495,14 @@ static int tools()
submenus[2] = !ordenador.vk_auto;
submenus[3] = !ordenador.vk_rumble;
old_port=ordenador.port;
opt = menu_select_title("Tools menu",
tools_messages, submenus);
if (opt < 0)
return 0;
set_port(submenus[1]);
if (old_port!= submenus[1]) set_port(submenus[1]);
ordenador.vk_auto = !submenus[2];
ordenador.vk_rumble = !submenus[3];
@ -1563,7 +1556,7 @@ static int save_load_snapshot(int which)
char *dir_load = load_path_snaps;
const char *tape = ordenador.last_selected_file;
char *ptr;
char db[256];
char db[MAX_PATH_LENGTH];
char fb[81];
int retorno, retorno2;
@ -1617,7 +1610,7 @@ static int save_load_snapshot(int which)
free((void*)filename);
} break;
case 1: // Save snapshot file
snprintf(db, 255, "%s/%s.z80", dir, fb);
snprintf(db, MAX_PATH_LENGTH-1, "%s/%s.z80", dir, fb);
retorno=save_z80(db,0);
switch(retorno)
@ -1651,7 +1644,7 @@ static int save_load_game_configurations(int which)
char *dir = path_confs;
const char *tape = ordenador.last_selected_file;
char *ptr;
char db[256];
char db[MAX_PATH_LENGTH];
char fb[81];
int retorno, retorno2;
@ -1695,7 +1688,7 @@ static int save_load_game_configurations(int which)
if (ptr) *ptr = 0;
snprintf(db, 255, "%s/%s.conf", dir, fb);
snprintf(db, MAX_PATH_LENGTH-1, "%s/%s.conf", dir, fb);
retorno=save_config_game(&ordenador,db,0);
@ -1728,7 +1721,7 @@ static void save_load_general_configurations(int which)
int retorno;
unsigned char old_bw,old_mode;
char config_path[1024];
char config_path[MAX_PATH_LENGTH];
int length;
FILE *fconfig;

View File

@ -64,7 +64,7 @@ typedef struct
typedef struct
{
char title[256];
char title[MAX_PATH_LENGTH];
const char **pp_msgs;
TTF_Font *p_font;
int x1,y1;
@ -294,7 +294,7 @@ static const char **get_file_list_zip(const char *path)
for (cur=2;cur<gi.number_entry+2;cur++)
{
char filename_inzip[1024];
char filename_inzip[MAX_PATH_LENGTH];
unz_file_info file_info;
err = unzGetCurrentFileInfo(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
@ -615,8 +615,8 @@ static void menu_draw(SDL_Surface *screen, menu_t *p_menu, int sel, int font_siz
SDL_Rect r;
int entries_visible = (p_menu->y2 - p_menu->y1-5) / line_height - 1;
const char *selected_file = NULL;
char filename[2049];
char name[512];
char filename[MAX_PATH_LENGTH];
char name[MAX_PATH_LENGTH];
char *ptr;
int i, y, length, max_string;
@ -1060,7 +1060,7 @@ uint32_t menu_wait_key_press()
return keys;
}
extern char curdir[256];
extern char curdir[MAX_PATH_LENGTH];
static int menu_select_internal(SDL_Surface *screen,
menu_t *p_menu, int *p_submenus, int sel,

View File

@ -739,7 +739,7 @@ void create_tapfile() {
unsigned char *videomem;
int ancho,retorno;
unsigned char nombre2[1024];
unsigned char nombre2[MAX_PATH_LENGTH];
videomem=screen->pixels;
ancho=screen->w;
@ -923,7 +923,7 @@ void create_mdrfile() {
unsigned char *videomem;
int ancho,retorno,bucle,retval;
unsigned char nombre2[1024];
unsigned char nombre2[MAX_PATH_LENGTH];
videomem=screen->pixels;
ancho=screen->w;
@ -987,7 +987,7 @@ void create_scrfile() {
unsigned char *videomem;
int ancho,retorno,retval;
unsigned char nombre2[1024];
unsigned char nombre2[MAX_PATH_LENGTH];
FILE *fichero;
char *name;
@ -1485,7 +1485,7 @@ void save_z80file() {
unsigned char *videomem;
int ancho,retorno;
unsigned char nombre2[1024];
unsigned char nombre2[MAX_PATH_LENGTH];
char *name;
videomem=screen->pixels;
@ -1647,7 +1647,7 @@ struct fichero *read_directory(char *cpath,enum LOAD_FILE_TYPES kind) {
struct dirent *entry;
DIR *directory;
struct stat estado;
unsigned char path[2049],fichero[2049],extension[5],found;
unsigned char path[MAX_PATH_LENGTH],fichero[MAX_PATH_LENGTH],extension[5],found;
int bucle,length;
strcpy(path,cpath);
@ -1938,7 +1938,7 @@ void print_files(struct fichero *filelist,int from,int mark) {
int bucle,numitems,ancho,pos;
char ink1,ink2;
unsigned char spaces[39]=" ";
unsigned char namefile[2089];
unsigned char namefile[MAX_PATH_LENGTH];
unsigned char *videomem;
videomem=screen->pixels;

View File

@ -19,8 +19,8 @@
*/
struct fichero {
char nombre[256]; // filename (for files and directories)
char nombrepath[2049]; // filename with path
char nombre[MAX_PATH_LENGTH]; // filename (for files and directories)
char nombrepath[MAX_PATH_LENGTH]; // filename with path
int tipo; // file type (0=file, 1=directory, 2=parent directory)
struct fichero *next;
};

View File

@ -25,7 +25,7 @@
#include <sys/stat.h>
#include <unistd.h>
char tabla[1024];
//char tabla[1024];
#include <fcntl.h>
#ifndef GEKKO