1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
|
#!/usr/bin/perl -w
# settings-header.pl: generate settings.h from settings.dat
# Copyright (c) 2002-2003 Philip Kendall
# Copyright (c) 2015 Stuart Brady
# 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.
# 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.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# Author contact information:
# E-mail: philip-fuse@shadowmagic.org.uk
use strict;
use lib 'perl';
use Fuse;
my %options;
while(<>) {
next if /^\s*$/;
next if /^\s*#/;
chomp;
my( $name, $type, $default, $short, $commandline, $configfile ) =
split /\s*,\s*/;
if( not defined $commandline ) {
$commandline = $name;
$commandline =~ s/_/-/g;
}
if( not defined $configfile ) {
$configfile = $commandline;
$configfile =~ s/-//g;
}
$options{$name} = { type => $type, default => $default, short => $short,
commandline => $commandline,
configfile => $configfile };
}
print Fuse::GPL( 'settings.h: Handling configuration settings',
'2001-2003 Philip Kendall' );
print << 'CODE';
/* This file is autogenerated from settings.dat by settings-header.pl.
Do not edit unless you know what will happen! */
#ifndef FUSE_SETTINGS_H
#define FUSE_SETTINGS_H
#include <sys/types.h>
typedef struct settings_info {
CODE
foreach my $name ( sort keys %options ) {
my $type = $options{$name}->{type};
if( $type eq 'boolean' or $type eq 'numeric' ) {
print " int $name;\n";
} elsif( $type eq 'string' ) {
print " char *$name;\n";
} elsif( $type eq 'null' ) {
# Do nothing
} else {
die "Unknown setting type `$type'";
}
}
print << 'CODE';
int show_help;
int show_version;
} settings_info;
extern settings_info settings_current;
extern settings_info settings_default;
int settings_init( int *first_arg, int argc, char **argv );
void settings_defaults( settings_info *settings );
void settings_copy( settings_info *dest, settings_info *src );
#define SETTINGS_ROM_COUNT 30
char **settings_get_rom_setting( settings_info *settings, size_t which,
int is_peripheral );
void settings_set_string( char **string_setting, const char *value );
int settings_free( settings_info *settings );
int settings_write_config( settings_info *settings );
void settings_register_startup( void );
#endif /* #ifndef FUSE_SETTINGS_H */
CODE
|