You've already forked fuse-utils
mirror of
https://git.code.sf.net/p/fuse-emulator/fuse-utils
synced 2025-08-09 00:42:13 +03:00
Put libspectrum version into creator information, and ensure that
libspectrum_init is called by all programs which use libspectrum functions. Legacy-ID: 1707
This commit is contained in:
@@ -49,3 +49,6 @@
|
||||
20031007 tapeconv.c: remove double-free bug if tape reading fails.
|
||||
20031009 utils.c: add information from uname() into creator custom data.
|
||||
20031010 utils.c: on Solaris, uname() returns 1 to indicate success.
|
||||
20031013 Put libspectrum version into creator information, and ensure that
|
||||
libspectrum_init is called by all programs which use libspectrum
|
||||
functions.
|
||||
|
@@ -74,6 +74,8 @@ int main(int argc, char* argv[])
|
||||
return 1;
|
||||
}
|
||||
|
||||
error = init_libspectrum(); if( error ) return error;
|
||||
|
||||
error = mmap_file( argv[1], &buffer, &length ); if( error ) return error;
|
||||
|
||||
error = libspectrum_identify_file( &type, argv[1], buffer, length );
|
||||
|
@@ -57,7 +57,7 @@ main( int argc, char **argv )
|
||||
|
||||
progname = argv[0];
|
||||
|
||||
if( libspectrum_init() ) return 16;
|
||||
if( init_libspectrum() ) return 16;
|
||||
|
||||
if( argc < 2 ) {
|
||||
fprintf( stderr, "%s: usage: %s <rzxfile>\n", progname, progname );
|
||||
|
@@ -65,6 +65,7 @@ main( int argc, char **argv )
|
||||
{
|
||||
unsigned char *buffer; size_t length;
|
||||
unsigned char *snap_buffer; size_t snap_length;
|
||||
int error;
|
||||
|
||||
libspectrum_rzx *rzx;
|
||||
libspectrum_snap *snap = NULL;
|
||||
@@ -74,7 +75,7 @@ main( int argc, char **argv )
|
||||
|
||||
progname = argv[0];
|
||||
|
||||
if( libspectrum_init() ) return 1;
|
||||
error = init_libspectrum(); if( error ) return error;
|
||||
|
||||
init_options( &options );
|
||||
if( parse_options( argc, argv, &options ) ) return 1;
|
||||
|
@@ -59,6 +59,8 @@ main( int argc, char **argv )
|
||||
return 1;
|
||||
}
|
||||
|
||||
error = init_libspectrum(); if( error ) return error;
|
||||
|
||||
error = libspectrum_snap_alloc( &snap ); if( error ) return error;
|
||||
|
||||
if( mmap_file( argv[1], &buffer, &length ) ) {
|
||||
|
@@ -46,13 +46,15 @@ char *progname;
|
||||
int
|
||||
main( int argc, char **argv )
|
||||
{
|
||||
int c;
|
||||
int c, error;
|
||||
char *input_type_string = NULL; libspectrum_id_t input_type;
|
||||
char *output_type_string = NULL; libspectrum_id_t output_type;
|
||||
libspectrum_tape *tzx;
|
||||
|
||||
progname = argv[0];
|
||||
|
||||
error = init_libspectrum(); if( error ) return error;
|
||||
|
||||
/* Don't screw up people's terminals */
|
||||
if( isatty( STDOUT_FILENO ) ) {
|
||||
fprintf( stderr, "%s: won't output binary data to a terminal\n",
|
||||
|
@@ -282,6 +282,7 @@ main( int argc, char **argv )
|
||||
{
|
||||
int ret = 0;
|
||||
int arg = 0;
|
||||
int error;
|
||||
|
||||
progname = argv[0];
|
||||
|
||||
@@ -290,6 +291,8 @@ main( int argc, char **argv )
|
||||
return 1;
|
||||
}
|
||||
|
||||
error = init_libspectrum(); if( error ) return error;
|
||||
|
||||
while( ++arg < argc )
|
||||
ret |= process_tzx( argv[arg] );
|
||||
|
||||
|
34
utils.c
34
utils.c
@@ -40,12 +40,31 @@
|
||||
|
||||
extern char *progname;
|
||||
|
||||
/* The minimum version of libspectrum we need */
|
||||
static const char *LIBSPECTRUM_MIN_VERSION = "0.2.0";
|
||||
|
||||
int
|
||||
init_libspectrum( void )
|
||||
{
|
||||
if( libspectrum_check_version( LIBSPECTRUM_MIN_VERSION ) ) {
|
||||
if( libspectrum_init() ) return 1;
|
||||
} else {
|
||||
fprintf( stderr, "libspectrum version %s found, but %s required",
|
||||
libspectrum_version(), LIBSPECTRUM_MIN_VERSION );
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
get_creator( libspectrum_creator **creator, const char *program )
|
||||
{
|
||||
char *custom;
|
||||
int version[4] = { 0, 0, 0, 0 };
|
||||
struct utsname buf;
|
||||
libspectrum_error error; int sys_error;
|
||||
size_t i;
|
||||
|
||||
sys_error = uname( &buf );
|
||||
if( sys_error == -1 ) {
|
||||
@@ -60,10 +79,16 @@ get_creator( libspectrum_creator **creator, const char *program )
|
||||
error = libspectrum_creator_set_program( *creator, program );
|
||||
if( error ) { libspectrum_creator_free( *creator ); return error; }
|
||||
|
||||
error = libspectrum_creator_set_major( *creator, 0x0006 );
|
||||
sscanf( VERSION, "%u.%u.%u.%u",
|
||||
&version[0], &version[1], &version[2], &version[3] );
|
||||
for( i=0; i<4; i++ ) if( version[i] > 0xff ) version[i] = 0xff;
|
||||
|
||||
error = libspectrum_creator_set_major( *creator,
|
||||
version[0] * 0x100 + version[1] );
|
||||
if( error ) { libspectrum_creator_free( *creator ); return error; }
|
||||
|
||||
error = libspectrum_creator_set_minor( *creator, 0x0100 );
|
||||
error = libspectrum_creator_set_minor( *creator,
|
||||
version[2] * 0x100 + version[3] );
|
||||
if( error ) { libspectrum_creator_free( *creator ); return error; }
|
||||
|
||||
custom = malloc( 256 );
|
||||
@@ -74,8 +99,9 @@ get_creator( libspectrum_creator **creator, const char *program )
|
||||
return 1;
|
||||
}
|
||||
|
||||
snprintf( custom, 256, "uname: %s %s %s\n", buf.sysname, buf.machine,
|
||||
buf.release );
|
||||
snprintf( custom, 256, "libspectrum: %s\nuname: %s %s %s\n",
|
||||
libspectrum_version(),
|
||||
buf.sysname, buf.machine, buf.release );
|
||||
|
||||
error = libspectrum_creator_set_custom( *creator,
|
||||
custom, strlen( custom ) );
|
||||
|
Reference in New Issue
Block a user