forked from Miroirs/x49gp
Compare commits
No commits in common. "6089396a7a504234d6b1d9859b41a10bb3358298" and "c7d1a1700ee1f3d49c56d0764a52024808b5d523" have entirely different histories.
6089396a7a
...
c7d1a1700e
6 changed files with 87 additions and 266 deletions
18
Makefile
18
Makefile
|
@ -7,19 +7,12 @@ PATCHLEVEL = 0
|
|||
|
||||
#
|
||||
DEBUG_CFLAGS = -g # -pg
|
||||
OPTIM ?= 2
|
||||
|
||||
LUA_VERSION ?= lua
|
||||
PKG_CONFIG ?= pkg-config
|
||||
|
||||
### lua
|
||||
LUACFLAGS = $(shell "$(PKG_CONFIG)" --cflags $(LUA_VERSION))
|
||||
LUALIBS = $(shell "$(PKG_CONFIG)" --libs $(LUA_VERSION))
|
||||
OPTIM = 2
|
||||
|
||||
# GTK
|
||||
GTK_VERSION ?= "+-3.0"
|
||||
GTK_CFLAGS = $(shell "$(PKG_CONFIG)" --cflags gtk$(GTK_VERSION)) -DGTK_DISABLE_SINGLE_INCLUDES -DGSEAL_ENABLE
|
||||
GTK_LDLIBS = $(shell "$(PKG_CONFIG)" --libs gtk$(GTK_VERSION)) -lz -lm
|
||||
GTK_VERSION = "+-3.0"
|
||||
GTK_CFLAGS = $(shell pkg-config --cflags gtk$(GTK_VERSION)) -DGTK_DISABLE_SINGLE_INCLUDES -DGSEAL_ENABLE
|
||||
GTK_LDLIBS = $(shell pkg-config --libs gtk$(GTK_VERSION)) -lz -lm
|
||||
|
||||
# Embedded qemu
|
||||
QEMU_DIR = src/qemu-git
|
||||
|
@ -94,7 +87,6 @@ X49GP_CFLAGS = $(CFLAGS) \
|
|||
$(X49GP_INCLUDES) \
|
||||
$(QEMU_DEFINES) \
|
||||
$(GTK_CFLAGS) \
|
||||
$(LUACFLAGS) \
|
||||
-D_GNU_SOURCE=1 \
|
||||
-DVERSION_MAJOR=$(VERSION_MAJOR) \
|
||||
-DVERSION_MINOR=$(VERSION_MINOR) \
|
||||
|
@ -107,7 +99,7 @@ ifeq ($(DEBUG), yes)
|
|||
endif
|
||||
|
||||
X49GP_LDFLAGS = $(DEBUG_CFLAGS) $(LDFLAGS)
|
||||
X49GP_LDLIBS = $(QEMU_OBJS) $(GDB_LIBS) $(COCOA_LIBS) $(GTK_LDLIBS) $(LUALIBS)
|
||||
X49GP_LDLIBS = $(QEMU_OBJS) $(GDB_LIBS) $(COCOA_LIBS) $(GTK_LDLIBS)
|
||||
|
||||
SRCS = ./src/x49gpng/main.c \
|
||||
./src/x49gpng/module.c \
|
||||
|
|
|
@ -278,12 +278,12 @@ int main( int argc, char** argv )
|
|||
if ( x49gp_modules_init( x49gp ) )
|
||||
exit( EXIT_FAILURE );
|
||||
|
||||
x49gp->basename = g_path_get_dirname( opt.state_filename );
|
||||
x49gp->basename = g_path_get_dirname( opt.config );
|
||||
x49gp->debug_port = opt.debug_port;
|
||||
x49gp->startup_reinit = opt.reinit;
|
||||
x49gp->firmware = opt.firmware;
|
||||
|
||||
int error = x49gp_modules_load( x49gp, opt.state_filename );
|
||||
int error = x49gp_modules_load( x49gp, opt.config );
|
||||
if ( error || opt.reinit >= X49GP_REINIT_REBOOT_ONLY ) {
|
||||
if ( error && error != -EAGAIN )
|
||||
exit( EXIT_FAILURE );
|
||||
|
@ -312,7 +312,7 @@ int main( int argc, char** argv )
|
|||
|
||||
x49gp_main_loop( x49gp );
|
||||
|
||||
x49gp_modules_save( x49gp, opt.state_filename );
|
||||
x49gp_modules_save( x49gp, opt.config );
|
||||
x49gp_modules_exit( x49gp );
|
||||
|
||||
#if false
|
||||
|
|
|
@ -100,16 +100,16 @@ int x49gp_modules_load( x49gp_t* x49gp, const char* filename )
|
|||
return error;
|
||||
}
|
||||
|
||||
x49gp->state_filename = g_key_file_new();
|
||||
if ( NULL == x49gp->state_filename ) {
|
||||
x49gp->config = g_key_file_new();
|
||||
if ( NULL == x49gp->config ) {
|
||||
fprintf( stderr, "%s:%u: g_key_file_new: Out of memory\n", __FUNCTION__, __LINE__ );
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
if ( !g_key_file_load_from_file( x49gp->state_filename, filename, G_KEY_FILE_KEEP_COMMENTS, &gerror ) &&
|
||||
if ( !g_key_file_load_from_file( x49gp->config, filename, G_KEY_FILE_KEEP_COMMENTS, &gerror ) &&
|
||||
!g_error_matches( gerror, G_FILE_ERROR, G_FILE_ERROR_NOENT ) ) {
|
||||
fprintf( stderr, "%s:%u: g_key_file_load_from_file: %s\n", __FUNCTION__, __LINE__, gerror->message );
|
||||
g_key_file_free( x49gp->state_filename );
|
||||
g_key_file_free( x49gp->config );
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ int x49gp_modules_load( x49gp_t* x49gp, const char* filename )
|
|||
|
||||
list_for_each_entry( module, &x49gp->modules, list )
|
||||
{
|
||||
error = module->load( module, x49gp->state_filename );
|
||||
error = module->load( module, x49gp->config );
|
||||
if ( error ) {
|
||||
if ( error == -EAGAIN )
|
||||
result = -EAGAIN;
|
||||
|
@ -126,15 +126,15 @@ int x49gp_modules_load( x49gp_t* x49gp, const char* filename )
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG_X49GP_MODULES
|
||||
{
|
||||
extern unsigned char* phys_ram_base;
|
||||
|
||||
#ifdef DEBUG_X49GP_MODULES
|
||||
printf( "%s: phys_ram_base: %p\n", __FUNCTION__, phys_ram_base );
|
||||
printf( "\t%02x %02x %02x %02x %02x %02x %02x %02x\n", phys_ram_base[ 0 ], phys_ram_base[ 1 ], phys_ram_base[ 2 ],
|
||||
phys_ram_base[ 3 ], phys_ram_base[ 4 ], phys_ram_base[ 5 ], phys_ram_base[ 6 ], phys_ram_base[ 7 ] );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -154,12 +154,12 @@ int x49gp_modules_save( x49gp_t* x49gp, const char* filename )
|
|||
|
||||
list_for_each_entry( module, &x49gp->modules, list )
|
||||
{
|
||||
error = module->save( module, x49gp->state_filename );
|
||||
error = module->save( module, x49gp->config );
|
||||
if ( error )
|
||||
return error;
|
||||
}
|
||||
|
||||
data = g_key_file_to_data( x49gp->state_filename, &length, &gerror );
|
||||
data = g_key_file_to_data( x49gp->config, &length, &gerror );
|
||||
if ( NULL == data ) {
|
||||
fprintf( stderr, "%s:%u: g_key_file_to_data: %s\n", __FUNCTION__, __LINE__, gerror->message );
|
||||
return -ENOMEM;
|
||||
|
|
|
@ -5,166 +5,61 @@
|
|||
#include <getopt.h>
|
||||
#include <glib.h>
|
||||
|
||||
#include <lua.h>
|
||||
#include <lauxlib.h>
|
||||
|
||||
#include "options.h"
|
||||
|
||||
#include "gdbstub.h"
|
||||
|
||||
struct options opt = {
|
||||
.config_lua_filename = NULL,
|
||||
.state_filename = NULL,
|
||||
.debug_port = 0,
|
||||
.start_debugger = false,
|
||||
.reinit = X49GP_REINIT_NONE,
|
||||
.firmware = NULL,
|
||||
.model = MODEL_50G,
|
||||
.name = NULL,
|
||||
.text_scale = 1,
|
||||
.display_scale = 2,
|
||||
#if defined( __linux__ )
|
||||
.font = "urw gothic l",
|
||||
#else
|
||||
.font = "Century Gothic",
|
||||
#endif
|
||||
};
|
||||
|
||||
lua_State* config_lua_values;
|
||||
|
||||
static inline bool config_read( const char* filename )
|
||||
{
|
||||
int rc;
|
||||
|
||||
assert( filename != NULL );
|
||||
|
||||
/*---------------------------------------------------
|
||||
; Create the Lua state, which includes NO predefined
|
||||
; functions or values. This is literally an empty
|
||||
; slate.
|
||||
;----------------------------------------------------*/
|
||||
config_lua_values = luaL_newstate();
|
||||
if ( config_lua_values == NULL ) {
|
||||
fprintf( stderr, "cannot create Lua state\n" );
|
||||
return false;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------
|
||||
; For the truly paranoid about sandboxing, enable the
|
||||
; following code, which removes the string library,
|
||||
; which some people find problematic to leave un-sand-
|
||||
; boxed. But in my opinion, if you are worried about
|
||||
; such attacks in a configuration file, you have bigger
|
||||
; security issues to worry about than this.
|
||||
;------------------------------------------------------*/
|
||||
#ifdef PARANOID
|
||||
lua_pushliteral( config_lua_values, "x" );
|
||||
lua_pushnil( config_lua_values );
|
||||
lua_setmetatable( config_lua_values, -2 );
|
||||
lua_pop( config_lua_values, 1 );
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------
|
||||
; Lua 5.2+ can restrict scripts to being text only,
|
||||
; to avoid a potential problem with loading pre-compiled
|
||||
; Lua scripts that may have malformed Lua VM code that
|
||||
; could possibly lead to an exploit, but again, if you
|
||||
; have to worry about that, you have bigger security
|
||||
; issues to worry about. But in any case, here I'm
|
||||
; restricting the file to "text" only.
|
||||
;------------------------------------------------------*/
|
||||
rc = luaL_loadfile( config_lua_values, filename );
|
||||
if ( rc != LUA_OK ) {
|
||||
/* fprintf( stderr, "Lua error: (%d) %s\n", rc, lua_tostring( config_lua_values, -1 ) ); */
|
||||
return false;
|
||||
}
|
||||
|
||||
rc = lua_pcall( config_lua_values, 0, 0, 0 );
|
||||
if ( rc != LUA_OK ) {
|
||||
/* fprintf( stderr, "Lua error: (%d) %s\n", rc, lua_tostring( config_lua_values, -1 ) ); */
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void print_config( void )
|
||||
{
|
||||
fprintf( stdout, "--------------------------------------------------------------------------------\n" );
|
||||
fprintf( stdout, "-- Configuration file for x49gpng\n" );
|
||||
fprintf( stdout, "-- This is a comment\n" );
|
||||
|
||||
fprintf( stdout, "name = \"%s\"\n", opt.name );
|
||||
|
||||
fprintf( stdout, "model = \"" );
|
||||
switch ( opt.model ) {
|
||||
case MODEL_49GP:
|
||||
fprintf( stdout, "49gp" );
|
||||
break;
|
||||
case MODEL_49GP_NEWRPL:
|
||||
fprintf( stdout, "49gp-newrpl" );
|
||||
break;
|
||||
case MODEL_50G:
|
||||
fprintf( stdout, "50g" );
|
||||
break;
|
||||
case MODEL_50G_NEWRPL:
|
||||
fprintf( stdout, "50g-newrpl" );
|
||||
break;
|
||||
}
|
||||
fprintf( stdout, "\" -- possible values: \"49gp\", \"50g\", \"49gp-newrpl\", \"50g-newrpl\"\n" );
|
||||
fprintf( stdout, "font = \"%s\"\n", opt.font );
|
||||
fprintf( stdout, "text_scale = %i\n", opt.text_scale );
|
||||
fprintf( stdout, "display_scale = %i\n", opt.display_scale );
|
||||
|
||||
fprintf( stdout, "--- End of saturnng configuration ----------------------------------------------\n" );
|
||||
}
|
||||
struct options opt;
|
||||
|
||||
void config_init( char* progname, int argc, char* argv[] )
|
||||
{
|
||||
int option_index;
|
||||
int c = '?';
|
||||
|
||||
char* config_lua_filename = ( char* )"config.lua";
|
||||
|
||||
bool do_enable_debugger = false;
|
||||
bool do_start_debugger = false;
|
||||
bool do_reflash = false;
|
||||
bool do_reflash_full = false;
|
||||
|
||||
char* clopt_name = NULL;
|
||||
char* clopt_font = NULL;
|
||||
int clopt_model = -1;
|
||||
int clopt_text_scale = -1;
|
||||
int clopt_display_scale = -1;
|
||||
opt.config = NULL;
|
||||
opt.debug_port = 0;
|
||||
opt.start_debugger = false;
|
||||
opt.reinit = X49GP_REINIT_NONE;
|
||||
opt.firmware = NULL;
|
||||
opt.model = MODEL_50G;
|
||||
opt.name = NULL;
|
||||
opt.text_scale = 1;
|
||||
opt.display_scale = 2;
|
||||
|
||||
int print_config_and_exit = false;
|
||||
#if defined( __linux__ )
|
||||
opt.font = "urw gothic l";
|
||||
#else
|
||||
opt.font = "Century Gothic";
|
||||
#endif
|
||||
|
||||
const char* optstring = "hrc:D:df:Fn:t:";
|
||||
struct option long_options[] = {
|
||||
{"help", no_argument, NULL, 'h' },
|
||||
{"print-config", no_argument, &print_config_and_exit, true},
|
||||
{"help", no_argument, NULL, 'h'},
|
||||
|
||||
{"config", required_argument, NULL, 'c' },
|
||||
{"config", required_argument, NULL, 'c'},
|
||||
|
||||
{"state", required_argument, NULL, 1 },
|
||||
{"enable-debug", required_argument, NULL, 'D'},
|
||||
{"debug", no_argument, NULL, 'd'},
|
||||
{"reflash", required_argument, NULL, 'f'},
|
||||
{"reflash-full", no_argument, NULL, 'F'},
|
||||
{"reboot", no_argument, NULL, 'r'},
|
||||
|
||||
{"enable-debug", required_argument, NULL, 'D' },
|
||||
{"debug", no_argument, NULL, 'd' },
|
||||
{"reflash", required_argument, NULL, 'f' },
|
||||
{"reflash-full", no_argument, NULL, 'F' },
|
||||
{"reboot", no_argument, NULL, 'r' },
|
||||
{"50g", no_argument, NULL, 506},
|
||||
{"50g-newrpl", no_argument, NULL, 507},
|
||||
{"49gp", no_argument, NULL, 496},
|
||||
{"49gp-newrpl", no_argument, NULL, 497},
|
||||
{"name", required_argument, NULL, 'n'},
|
||||
{"text-scale", required_argument, NULL, 's'},
|
||||
{"display-scale", required_argument, NULL, 'S'},
|
||||
|
||||
{"50g", no_argument, NULL, 506 },
|
||||
{"50g-newrpl", no_argument, NULL, 507 },
|
||||
{"49gp", no_argument, NULL, 496 },
|
||||
{"49gp-newrpl", no_argument, NULL, 497 },
|
||||
{"name", required_argument, NULL, 'n' },
|
||||
{"text-scale", required_argument, NULL, 's' },
|
||||
{"display-scale", required_argument, NULL, 'S' },
|
||||
{"font", required_argument, NULL, 't'},
|
||||
|
||||
{"font", required_argument, NULL, 't' },
|
||||
|
||||
{0, 0, 0, 0 }
|
||||
{0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
while ( c != EOF ) {
|
||||
|
@ -177,7 +72,7 @@ void config_init( char* progname, int argc, char* argv[] )
|
|||
"Usage: %s [<options>]\n"
|
||||
"Valid options:\n"
|
||||
" -h --help print this message and exit\n"
|
||||
" --state[=<filename>] alternate config file\n"
|
||||
" -c --config[=<filename>] alternate config file\n"
|
||||
" --50g show HP 50g faceplate (default)\n"
|
||||
" --50g-newrpl show HP 50g faceplate with newRPL labels\n"
|
||||
" --49gp show HP 49g+ faceplate\n"
|
||||
|
@ -207,12 +102,11 @@ void config_init( char* progname, int argc, char* argv[] )
|
|||
if ( opt.reinit < X49GP_REINIT_REBOOT_ONLY )
|
||||
opt.reinit = X49GP_REINIT_REBOOT_ONLY;
|
||||
break;
|
||||
case 1:
|
||||
opt.state_filename = strdup( optarg );
|
||||
case 'c':
|
||||
opt.config = strdup( optarg );
|
||||
break;
|
||||
case 'D':
|
||||
do_enable_debugger = true;
|
||||
opt.debug_port = atoi( optarg );
|
||||
break;
|
||||
case 'd':
|
||||
do_start_debugger = true;
|
||||
|
@ -224,124 +118,52 @@ void config_init( char* progname, int argc, char* argv[] )
|
|||
do_reflash_full = true;
|
||||
break;
|
||||
case 496:
|
||||
clopt_model = MODEL_49GP;
|
||||
if ( clopt_name == NULL )
|
||||
clopt_name = "HP 49g+";
|
||||
opt.model = MODEL_49GP;
|
||||
break;
|
||||
case 497:
|
||||
clopt_model = MODEL_49GP_NEWRPL;
|
||||
if ( clopt_name == NULL )
|
||||
clopt_name = "HP 49g+ / newRPL";
|
||||
opt.model = MODEL_49GP_NEWRPL;
|
||||
break;
|
||||
case 506:
|
||||
clopt_model = MODEL_50G;
|
||||
if ( clopt_name == NULL )
|
||||
clopt_name = "HP 50g";
|
||||
opt.model = MODEL_50G;
|
||||
break;
|
||||
case 507:
|
||||
clopt_model = MODEL_50G_NEWRPL;
|
||||
if ( clopt_name == NULL )
|
||||
clopt_name = "HP 50g / newRPL";
|
||||
opt.model = MODEL_50G_NEWRPL;
|
||||
break;
|
||||
case 'n':
|
||||
clopt_name = strdup( optarg );
|
||||
opt.name = strdup( optarg );
|
||||
break;
|
||||
case 's':
|
||||
clopt_text_scale = atoi( optarg );
|
||||
opt.text_scale = atoi( optarg );
|
||||
break;
|
||||
case 'S':
|
||||
clopt_display_scale = atoi( optarg );
|
||||
opt.display_scale = atoi( optarg );
|
||||
break;
|
||||
case 't':
|
||||
clopt_font = strdup( optarg );
|
||||
opt.font = strdup( optarg );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
char config_dir[ strlen( progname ) + 9 ];
|
||||
const char* home = g_get_home_dir();
|
||||
sprintf( config_dir, ".config/%s", progname );
|
||||
|
||||
opt.config_lua_filename = g_build_filename( home, config_dir, config_lua_filename, NULL );
|
||||
|
||||
/**********************/
|
||||
/* 1. read config.lua */
|
||||
/**********************/
|
||||
bool haz_config_file = config_read( opt.config_lua_filename );
|
||||
if ( haz_config_file ) {
|
||||
lua_getglobal( config_lua_values, "model" );
|
||||
const char* svalue_model = luaL_optstring( config_lua_values, -1, "50g" );
|
||||
if ( svalue_model != NULL ) {
|
||||
if ( strcmp( svalue_model, "50g" ) == 0 )
|
||||
opt.model = MODEL_50G;
|
||||
if ( strcmp( svalue_model, "50g-newrpl" ) == 0 )
|
||||
opt.model = MODEL_50G_NEWRPL;
|
||||
if ( strcmp( svalue_model, "49gp" ) == 0 )
|
||||
opt.model = MODEL_49GP;
|
||||
if ( strcmp( svalue_model, "49gp-newrpl" ) == 0 )
|
||||
opt.model = MODEL_49GP_NEWRPL;
|
||||
}
|
||||
|
||||
lua_getglobal( config_lua_values, "name" );
|
||||
opt.name = strdup( luaL_optstring( config_lua_values, -1, NULL ) );
|
||||
|
||||
lua_getglobal( config_lua_values, "font" );
|
||||
opt.font = strdup( luaL_optstring( config_lua_values, -1, NULL ) );
|
||||
|
||||
lua_getglobal( config_lua_values, "text_scale" );
|
||||
opt.text_scale = luaL_optinteger( config_lua_values, -1, 1.0 );
|
||||
|
||||
lua_getglobal( config_lua_values, "display_scale" );
|
||||
opt.display_scale = luaL_optinteger( config_lua_values, -1, 1.0 );
|
||||
}
|
||||
|
||||
/****************************************************/
|
||||
/* 2. treat command-line params which have priority */
|
||||
/****************************************************/
|
||||
if ( clopt_name != NULL )
|
||||
opt.name = strdup( clopt_name );
|
||||
else
|
||||
switch ( opt.model ) {
|
||||
case MODEL_50G_NEWRPL:
|
||||
opt.name = "HP 50g / newRPL";
|
||||
break;
|
||||
case MODEL_49GP:
|
||||
opt.name = "HP 49g+";
|
||||
break;
|
||||
case MODEL_49GP_NEWRPL:
|
||||
opt.name = "HP 49g+ / newRPL";
|
||||
break;
|
||||
case MODEL_50G:
|
||||
default:
|
||||
opt.name = "HP 50g";
|
||||
break;
|
||||
}
|
||||
if ( clopt_font != NULL )
|
||||
opt.font = strdup( clopt_font );
|
||||
if ( clopt_model != -1 )
|
||||
opt.model = clopt_model;
|
||||
if ( clopt_text_scale != -1 )
|
||||
opt.text_scale = clopt_text_scale;
|
||||
if ( clopt_display_scale != -1 )
|
||||
opt.display_scale = clopt_display_scale;
|
||||
|
||||
if ( print_config_and_exit ) {
|
||||
print_config();
|
||||
exit( EXIT_SUCCESS );
|
||||
}
|
||||
|
||||
if ( !haz_config_file ) {
|
||||
fprintf( stderr, "\nConfiguration file %s doesn't seem to exist or is invalid!\n", opt.config_lua_filename );
|
||||
fprintf( stderr, "You can solve this by running `mkdir -p %s/%s && %s --print-config >> %s`\n\n", home, config_dir, progname,
|
||||
opt.config_lua_filename );
|
||||
}
|
||||
|
||||
if ( do_enable_debugger ) {
|
||||
if ( opt.debug_port == 0 )
|
||||
char* end;
|
||||
int port;
|
||||
|
||||
if ( optarg == NULL && opt.debug_port == 0 )
|
||||
opt.debug_port = DEFAULT_GDBSTUB_PORT;
|
||||
|
||||
port = strtoul( optarg, &end, 0 );
|
||||
if ( ( end == optarg ) || ( *end != '\0' ) ) {
|
||||
fprintf( stderr, "Invalid port \"%s\", using default\n", optarg );
|
||||
if ( opt.debug_port == 0 )
|
||||
opt.debug_port = DEFAULT_GDBSTUB_PORT;
|
||||
}
|
||||
|
||||
if ( opt.debug_port != 0 && opt.debug_port != DEFAULT_GDBSTUB_PORT )
|
||||
fprintf( stderr, "Additional debug port \"%s\" specified, overriding\n", optarg );
|
||||
opt.debug_port = port;
|
||||
|
||||
opt.start_debugger = do_start_debugger;
|
||||
}
|
||||
if ( do_reflash ) {
|
||||
|
@ -349,13 +171,21 @@ void config_init( char* progname, int argc, char* argv[] )
|
|||
opt.reinit = X49GP_REINIT_FLASH;
|
||||
|
||||
if ( opt.firmware != NULL )
|
||||
fprintf( stderr, "Additional firmware file \"%s\" specified, overriding\n", optarg );
|
||||
fprintf( stderr,
|
||||
"Additional firmware file \"%s\" specified,"
|
||||
" overriding\n",
|
||||
optarg );
|
||||
opt.firmware = optarg;
|
||||
|
||||
if ( do_reflash_full )
|
||||
opt.reinit = X49GP_REINIT_FLASH_FULL;
|
||||
}
|
||||
|
||||
if ( opt.state_filename == NULL )
|
||||
opt.state_filename = g_build_filename( home, config_dir, "state", NULL );
|
||||
if ( opt.config == NULL ) {
|
||||
char config_dir[ strlen( progname ) + 9 ];
|
||||
|
||||
const char* home = g_get_home_dir();
|
||||
sprintf( config_dir, ".config/%s", progname );
|
||||
opt.config = g_build_filename( home, config_dir, "config", NULL );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
typedef enum { MODEL_49GP = 0, MODEL_49GP_NEWRPL, MODEL_50G, MODEL_50G_NEWRPL } x49gpng_model_t;
|
||||
|
||||
struct options {
|
||||
char* state_filename;
|
||||
char* config;
|
||||
int debug_port;
|
||||
int start_debugger;
|
||||
char* firmware;
|
||||
|
@ -28,7 +28,6 @@ struct options {
|
|||
char* font;
|
||||
int display_scale;
|
||||
int text_scale;
|
||||
char* config_lua_filename;
|
||||
};
|
||||
|
||||
extern struct options opt;
|
||||
|
|
|
@ -83,7 +83,7 @@ struct __x49gp_s__ {
|
|||
|
||||
x49gp_ui_t* ui;
|
||||
|
||||
GKeyFile* state_filename;
|
||||
GKeyFile* config;
|
||||
const char* progname;
|
||||
const char* progpath;
|
||||
const char* basename;
|
||||
|
|
Loading…
Reference in a new issue