mirror of
https://github.com/digarok/gsplus.git
synced 2024-11-24 06:34:02 +00:00
fix for segfault on screenshot w/ no dir specified
This commit is contained in:
parent
4918fa3c48
commit
8d1161b224
49
src/config.c
49
src/config.c
@ -3,21 +3,21 @@
|
|||||||
Copyright (C) 2016 - Dagen Brock
|
Copyright (C) 2016 - Dagen Brock
|
||||||
|
|
||||||
Copyright (C) 2010 - 2014 by GSport contributors
|
Copyright (C) 2010 - 2014 by GSport contributors
|
||||||
|
|
||||||
Based on the KEGS emulator written by and Copyright (C) 2003 Kent Dickey
|
Based on the KEGS emulator written by and Copyright (C) 2003 Kent Dickey
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify it
|
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
|
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
|
Free Software Foundation; either version 2 of the License, or (at your
|
||||||
option) any later version.
|
option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful, but
|
This program is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
for more details.
|
for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License along
|
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.,
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
#ifdef HAVE_TFE
|
#ifdef HAVE_TFE
|
||||||
#include "tfe/tfesupp.h"
|
#include "tfe/tfesupp.h"
|
||||||
#include "tfe/protos_tfe.h"
|
#include "tfe/protos_tfe.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined _MSC_VER
|
#if defined _MSC_VER
|
||||||
@ -575,8 +575,7 @@ config_init()
|
|||||||
// Find the configuration file
|
// Find the configuration file
|
||||||
g_config_gsplus_name[0] = 0;
|
g_config_gsplus_name[0] = 0;
|
||||||
can_create = 1;
|
can_create = 1;
|
||||||
setup_gsplus_file(&g_config_gsplus_name[0], sizeof(g_config_gsplus_name), 0,
|
setup_gsplus_file(&g_config_gsplus_name[0], sizeof(g_config_gsplus_name), 0, can_create, &g_config_gsplus_name_list[0]);
|
||||||
can_create, &g_config_gsplus_name_list[0]);
|
|
||||||
|
|
||||||
config_parse_config_gsplus_file();
|
config_parse_config_gsplus_file();
|
||||||
}
|
}
|
||||||
@ -656,9 +655,9 @@ cfg_iwreset()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#ifdef HAVE_TFE
|
#ifdef HAVE_TFE
|
||||||
void
|
void
|
||||||
cfg_get_tfe_name()
|
cfg_get_tfe_name()
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
char *ppname = NULL;
|
char *ppname = NULL;
|
||||||
char *ppdes = NULL;
|
char *ppdes = NULL;
|
||||||
@ -679,9 +678,9 @@ cfg_get_tfe_name()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||||
cfg_printf("ERROR: Install/Enable WinPcap for Ethernet Support!!");
|
cfg_printf("ERROR: Install/Enable WinPcap for Ethernet Support!!");
|
||||||
#else
|
#else
|
||||||
cfg_printf("ERROR: Install/Enable LibPcap for Ethernet Support!!");
|
cfg_printf("ERROR: Install/Enable LibPcap for Ethernet Support!!");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -726,8 +725,9 @@ config_parse_option(char *buf, int pos, int len, int line)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// find "name" as first contiguous string
|
// find "name" as first contiguous string
|
||||||
printf("...parse_option: line %d, %p,%p = %s (%s) len:%d\n", line,
|
gloghead(); printf("...parse_option: line %d, len:%d \"%s\"\n", line, len, &buf[pos]);
|
||||||
&buf[pos], buf, &buf[pos], buf, len);
|
|
||||||
|
// printf("...parse_option: line %d, %p,%p = %s (%s) len:%d\n", line, &buf[pos], buf, &buf[pos], buf, len);
|
||||||
|
|
||||||
nameptr = &buf[pos];
|
nameptr = &buf[pos];
|
||||||
while(pos < len) {
|
while(pos < len) {
|
||||||
@ -921,8 +921,7 @@ config_load_roms()
|
|||||||
if(*names_ptr == 0) {
|
if(*names_ptr == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
setup_gsplus_file(&g_cfg_tmp_path[0], CFG_PATH_MAX, 1, 0,
|
setup_gsplus_file(&g_cfg_tmp_path[0], CFG_PATH_MAX, 1, 0, names_ptr);
|
||||||
names_ptr);
|
|
||||||
if(g_cfg_tmp_path[0] != 0) {
|
if(g_cfg_tmp_path[0] != 0) {
|
||||||
file = fopen(&(g_cfg_tmp_path[0]), "rb");
|
file = fopen(&(g_cfg_tmp_path[0]), "rb");
|
||||||
if(!file) {
|
if(!file) {
|
||||||
@ -2556,7 +2555,7 @@ cfg_file_init()
|
|||||||
// Just use g_cfg_file_def_name
|
// Just use g_cfg_file_def_name
|
||||||
strncpy(&g_cfg_tmp_path[0], g_cfg_file_def_name, CFG_PATH_MAX);
|
strncpy(&g_cfg_tmp_path[0], g_cfg_file_def_name, CFG_PATH_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg_get_base_path(&g_cfg_file_curpath[0], &g_cfg_tmp_path[0], 0);
|
cfg_get_base_path(&g_cfg_file_curpath[0], &g_cfg_tmp_path[0], 0);
|
||||||
g_cfg_dirlist.invalid = 1;
|
g_cfg_dirlist.invalid = 1;
|
||||||
}
|
}
|
||||||
@ -2631,7 +2630,7 @@ cfg_dirent_sortfn(const void *obj1, const void *obj2)
|
|||||||
#if defined(MAC) || defined(_WIN32)
|
#if defined(MAC) || defined(_WIN32)
|
||||||
// OG
|
// OG
|
||||||
ret = 0;
|
ret = 0;
|
||||||
// ret = strcasecmp(direntptr1->name, direntptr2->name);
|
// ret = strcasecmp(direntptr1->name, direntptr2->name);
|
||||||
#else
|
#else
|
||||||
ret = strcmp(direntptr1->name, direntptr2->name);
|
ret = strcmp(direntptr1->name, direntptr2->name);
|
||||||
#endif
|
#endif
|
||||||
@ -2804,7 +2803,7 @@ cfg_inspect_maybe_insert_file(char *filename, int should_boot)
|
|||||||
/*
|
/*
|
||||||
Take a look at a file. Based on its size, guess a slot/drive to insert it into.
|
Take a look at a file. Based on its size, guess a slot/drive to insert it into.
|
||||||
Used for blind operations like dragging/dropping files.
|
Used for blind operations like dragging/dropping files.
|
||||||
Optionally boot from that slot.
|
Optionally boot from that slot.
|
||||||
*/
|
*/
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
int slot = 0;
|
int slot = 0;
|
||||||
@ -2819,7 +2818,7 @@ Optionally boot from that slot.
|
|||||||
}
|
}
|
||||||
if (slot > 0)
|
if (slot > 0)
|
||||||
{
|
{
|
||||||
insert_disk(slot,0,filename,0,0,0,-1);
|
insert_disk(slot,0,filename,0,0,0,-1);
|
||||||
printf("Inserted disk in slot %d, drive 1. Filename: %s\n", slot, filename);
|
printf("Inserted disk in slot %d, drive 1. Filename: %s\n", slot, filename);
|
||||||
if (should_boot) {
|
if (should_boot) {
|
||||||
g_temp_boot_slot = slot;
|
g_temp_boot_slot = slot;
|
||||||
@ -3340,7 +3339,7 @@ config_control_panel()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_SDL
|
#ifdef HAVE_SDL
|
||||||
/*If user enters the Virtual Imagewriter control panel, flag it so we can
|
/*If user enters the Virtual Imagewriter control panel, flag it so we can
|
||||||
automatically apply changes on exit.*/
|
automatically apply changes on exit.*/
|
||||||
if(menuptr == g_cfg_imagewriter_menu)
|
if(menuptr == g_cfg_imagewriter_menu)
|
||||||
{
|
{
|
||||||
|
@ -53,7 +53,7 @@ int kb_shift_control_state = 0;
|
|||||||
void x_take_screenshot(); // screenshot stuff
|
void x_take_screenshot(); // screenshot stuff
|
||||||
int g_screenshot_requested = 0; // DB to know if we want to save a screenshot
|
int g_screenshot_requested = 0; // DB to know if we want to save a screenshot
|
||||||
extern char g_config_gsplus_name[];
|
extern char g_config_gsplus_name[];
|
||||||
extern char *g_config_gsplus_screenshot_dir;
|
extern char g_config_gsplus_screenshot_dir[];
|
||||||
int screenshot_index = 0; // allows us to save time by not scanning from 0 each time
|
int screenshot_index = 0; // allows us to save time by not scanning from 0 each time
|
||||||
char screenshot_filename[256];
|
char screenshot_filename[256];
|
||||||
|
|
||||||
@ -650,7 +650,8 @@ void make_next_screenshot_filename()
|
|||||||
// workaround is this horrible hack of saving the bmp -> load bmp -> save png
|
// workaround is this horrible hack of saving the bmp -> load bmp -> save png
|
||||||
void x_take_screenshot() {
|
void x_take_screenshot() {
|
||||||
make_next_screenshot_filename();
|
make_next_screenshot_filename();
|
||||||
printf("Screenshot! ---> %s\n", screenshot_filename);
|
gloghead();
|
||||||
|
printf("Taking screenshot - %s\n", screenshot_filename);
|
||||||
SDL_Surface *sshot = SDL_CreateRGBSurface(0, BASE_WINDOW_WIDTH, X_A2_WINDOW_HEIGHT, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
|
SDL_Surface *sshot = SDL_CreateRGBSurface(0, BASE_WINDOW_WIDTH, X_A2_WINDOW_HEIGHT, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000);
|
||||||
SDL_LockSurface(sshot);
|
SDL_LockSurface(sshot);
|
||||||
int read = SDL_RenderReadPixels(renderer, NULL, SDL_PIXELFORMAT_ARGB8888, sshot->pixels, sshot->pitch);
|
int read = SDL_RenderReadPixels(renderer, NULL, SDL_PIXELFORMAT_ARGB8888, sshot->pixels, sshot->pitch);
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#include "glog.h"
|
#include "glog.h"
|
||||||
|
|
||||||
extern const char *g_config_gsplus_name_list[];
|
extern const char *g_config_gsplus_name_list[];
|
||||||
extern char *g_config_gsplus_screenshot_dir;
|
extern char g_config_gsplus_screenshot_dir[];
|
||||||
#ifdef UNDER_CE
|
#ifdef UNDER_CE
|
||||||
#define vsnprintf _vsnprintf
|
#define vsnprintf _vsnprintf
|
||||||
#endif
|
#endif
|
||||||
@ -946,6 +946,10 @@ gsplusmain(int argc, char **argv)
|
|||||||
sim65816_initglobals();
|
sim65816_initglobals();
|
||||||
moremem_init();
|
moremem_init();
|
||||||
|
|
||||||
|
printf("FOOOAAA\n" );
|
||||||
|
// initialize ss dir to default value (current path)
|
||||||
|
strcpy(g_config_gsplus_screenshot_dir, "./");
|
||||||
|
|
||||||
/* parse args */
|
/* parse args */
|
||||||
for(i = 1; i < argc; i++) {
|
for(i = 1; i < argc; i++) {
|
||||||
if(!strcmp("-badrd", argv[i])) {
|
if(!strcmp("-badrd", argv[i])) {
|
||||||
@ -1055,11 +1059,11 @@ gsplusmain(int argc, char **argv)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
printf("Using %s as configuration file\n", argv[i+1]);
|
printf("Using %s as configuration file\n", argv[i+1]);
|
||||||
g_config_gsplus_name_list[0] = argv[i+1]; // super dangerous ?
|
g_config_gsplus_name_list[0] = argv[i+1]; // overwrite default list with passed item as sole option
|
||||||
g_config_gsplus_name_list[1] = 0; // terminate string array
|
g_config_gsplus_name_list[1] = 0; // terminate string array
|
||||||
i++;
|
i++;
|
||||||
} else if (!strcmp("-ssdir", argv[i])) { // screenshot directory passed
|
} else if (!strcmp("-ssdir", argv[i])) { // screenshot directory passed
|
||||||
g_config_gsplus_screenshot_dir = argv[i+1];
|
strcpy(g_config_gsplus_screenshot_dir, argv[i+1]);
|
||||||
struct stat path_stat;
|
struct stat path_stat;
|
||||||
int ret = stat(g_config_gsplus_screenshot_dir, &path_stat); // (weakly) validate path
|
int ret = stat(g_config_gsplus_screenshot_dir, &path_stat); // (weakly) validate path
|
||||||
if (!S_ISDIR(path_stat.st_mode)) {
|
if (!S_ISDIR(path_stat.st_mode)) {
|
||||||
@ -1308,9 +1312,7 @@ gsport_expand_path(char *out_ptr, const char *in_ptr, int maxlen)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void setup_gsplus_file(char *outname, int maxlen, int ok_if_missing, int can_create_file, const char **name_ptr)
|
||||||
setup_gsplus_file(char *outname, int maxlen, int ok_if_missing,
|
|
||||||
int can_create_file, const char **name_ptr)
|
|
||||||
{
|
{
|
||||||
char local_path[256];
|
char local_path[256];
|
||||||
struct stat stat_buf;
|
struct stat stat_buf;
|
||||||
@ -1329,7 +1331,7 @@ setup_gsplus_file(char *outname, int maxlen, int ok_if_missing,
|
|||||||
while(*cur_name_ptr) {
|
while(*cur_name_ptr) {
|
||||||
strcpy(outname, &(local_path[0]));
|
strcpy(outname, &(local_path[0]));
|
||||||
strncat(outname, *cur_name_ptr, 255-strlen(outname));
|
strncat(outname, *cur_name_ptr, 255-strlen(outname));
|
||||||
if(!ok_if_missing) {
|
if(!ok_if_missing) { // ??
|
||||||
gloghead(); printf("Trying '%s'\n", outname);
|
gloghead(); printf("Trying '%s'\n", outname);
|
||||||
}
|
}
|
||||||
ret = stat(outname, &stat_buf);
|
ret = stat(outname, &stat_buf);
|
||||||
@ -1382,8 +1384,7 @@ setup_gsplus_file(char *outname, int maxlen, int ok_if_missing,
|
|||||||
|
|
||||||
// But clear out the fatal_printfs first
|
// But clear out the fatal_printfs first
|
||||||
clear_fatal_logs();
|
clear_fatal_logs();
|
||||||
setup_gsplus_file(outname, maxlen, ok_if_missing,
|
setup_gsplus_file(outname, maxlen, ok_if_missing, can_create_file, name_ptr);
|
||||||
can_create_file, name_ptr);
|
|
||||||
// It's one-level of recursion--it cannot loop since we
|
// It's one-level of recursion--it cannot loop since we
|
||||||
// clear can_create_file.
|
// clear can_create_file.
|
||||||
// If it returns, then there was succes and we should get out
|
// If it returns, then there was succes and we should get out
|
||||||
|
Loading…
Reference in New Issue
Block a user