Convert-Binary-C
view release on metacpan or search on metacpan
bin/memmap.PL view on Meta::CPAN
typedef struct _LinkedList * LinkedList;
typedef struct _HashTable * HashTable;
typedef struct {
enum {
BO_BIG_ENDIAN,
BO_LITTLE_ENDIAN
} bo;
} ArchSpecs;
typedef struct {
char *buffer;
long pos, length;
} Buffer;
typedef struct {
unsigned alignment;
unsigned int_size;
unsigned short_size;
unsigned long_size;
unsigned long_long_size;
int enum_size;
unsigned ptr_size;
unsigned float_size;
unsigned double_size;
unsigned long_double_size;
u_32 flags;
u_32 keywords;
LinkedList disabled_keywords;
LinkedList includes;
LinkedList defines;
LinkedList assertions;
HashTable keyword_map;
} CParseConfig;
typedef struct {
LinkedList enums;
LinkedList structs;
LinkedList typedef_lists;
HashTable htEnumerators;
HashTable htEnums;
HashTable htStructs;
HashTable htTypedefs;
HashTable htFiles;
char *errstr;
} CParseInfo;
typedef struct {
char *bufptr;
unsigned alignment;
unsigned align_base;
int dataTooShortFlag;
Buffer buf;
CParseConfig cfg;
CParseInfo cpi;
ArchSpecs as;
enum {
ET_INTEGER, ET_STRING, ET_BOTH
} enumType;
} CBC;
ENDC
#-------------------------------------------------
# Print the memory map for type 'CBC' with a base
# address of 0x01500000.
#-------------------------------------------------
memmap( $c, 'CBC', 0x01500000 );
#==========================================================
# SUBROUTINES
#==========================================================
sub memmap
{
my($c, $type, $start) = @_;
$start ||= 0;
my $afmt = '%0' . 2*$c->PointerSize . 'X';
for my $offset ( 0 .. $c->sizeof( $type ) - 1 ) {
my $m = $c->member( $type, $offset );
rindex( $m, '+' ) < 0 or next;
my $t = $c->typeof( $type.$m );
printf "$afmt %-16s %s\n", $start+$offset, $t, $m;
}
}
!NO!SUBS!
close OUT or die "Can't close $file: $!";
chmod 0755, $file or die "Can't reset permissions for $file: $!\n";
( run in 0.657 second using v1.01-cache-2.11-cpan-df04353d9ac )