mirror of
https://github.com/holub/mame
synced 2025-05-12 17:14:19 +03:00
softlist wip code to add more info nodes [Fabio Priuli]
This commit is contained in:
parent
e052e1edf1
commit
c81a150519
@ -281,6 +281,46 @@ static void add_feature(software_list *swlist, char *feature_name, char *feature
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
add_info (same as add_feature, but its target
|
||||
is softinfo->other_info)
|
||||
-------------------------------------------------*/
|
||||
|
||||
static void add_info(software_list *swlist, char *feature_name, char *feature_value)
|
||||
{
|
||||
software_info *info = swlist->softinfo;
|
||||
feature_list *new_entry;
|
||||
|
||||
/* First allocate the new entry */
|
||||
new_entry = (feature_list *)pool_malloc_lib(swlist->pool, sizeof(feature_list) );
|
||||
|
||||
if ( new_entry )
|
||||
{
|
||||
new_entry->next = NULL;
|
||||
new_entry->name = feature_name;
|
||||
new_entry->value = feature_value ? feature_value : feature_name;
|
||||
|
||||
/* Add new feature to end of feature list */
|
||||
if ( info->other_info )
|
||||
{
|
||||
feature_list *list = info->other_info;
|
||||
while ( list->next != NULL )
|
||||
{
|
||||
list = list->next;
|
||||
}
|
||||
list->next = new_entry;
|
||||
}
|
||||
else
|
||||
{
|
||||
info->other_info = new_entry;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Unable to allocate memory */
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
add_software_part
|
||||
-------------------------------------------------*/
|
||||
@ -405,6 +445,16 @@ static void start_handler(void *data, const char *tagname, const char **attribut
|
||||
elem->partdata = (software_part *)pool_malloc_lib(swlist->pool, swlist->part_entries * sizeof(software_part) );
|
||||
if ( !elem->partdata )
|
||||
return;
|
||||
elem->other_info = (feature_list *)pool_malloc_lib(swlist->pool, sizeof(feature_list) );
|
||||
if ( !elem->other_info )
|
||||
return;
|
||||
else
|
||||
{
|
||||
elem->other_info->next = (feature_list *)pool_malloc_lib(swlist->pool, sizeof(feature_list) );
|
||||
elem->other_info->next = NULL;
|
||||
elem->other_info->name = NULL;
|
||||
elem->other_info->value = NULL;
|
||||
}
|
||||
|
||||
/* Handle the supported flag */
|
||||
elem->supported = SOFTWARE_SUPPORTED_YES;
|
||||
@ -448,6 +498,44 @@ static void start_handler(void *data, const char *tagname, const char **attribut
|
||||
text_dest = (char **) &swlist->softinfo->year;
|
||||
else if (!strcmp(tagname, "publisher"))
|
||||
text_dest = (char **) &swlist->softinfo->publisher;
|
||||
else if ( !strcmp(tagname, "info") )
|
||||
{
|
||||
const char *str_feature_name = NULL;
|
||||
const char *str_feature_value = NULL;
|
||||
|
||||
for ( ; attributes[0]; attributes += 2 )
|
||||
{
|
||||
if ( !strcmp( attributes[0], "name" ) )
|
||||
str_feature_name = attributes[1];
|
||||
|
||||
if ( !strcmp( attributes[0], "value" ) )
|
||||
str_feature_value = attributes[1];
|
||||
}
|
||||
|
||||
/* Prepare for adding feature to feature list */
|
||||
if ( str_feature_name && swlist->softinfo )
|
||||
{
|
||||
char *name = (char *)pool_malloc_lib(swlist->pool, ( strlen( str_feature_name ) + 1 ) * sizeof(char) );
|
||||
char *value = NULL;
|
||||
|
||||
if ( !name )
|
||||
return;
|
||||
|
||||
strcpy( name, str_feature_name );
|
||||
|
||||
if ( str_feature_value )
|
||||
{
|
||||
value = (char *)pool_malloc_lib(swlist->pool, ( strlen( str_feature_value ) + 1 ) * sizeof(char) );
|
||||
|
||||
if ( !value )
|
||||
return;
|
||||
|
||||
strcpy( value, str_feature_value );
|
||||
}
|
||||
|
||||
add_info( swlist, name, value );
|
||||
}
|
||||
}
|
||||
else if ( !strcmp(tagname, "part" ) )
|
||||
{
|
||||
const char *str_name = NULL;
|
||||
@ -770,6 +858,17 @@ static void end_handler(void *data, const char *name)
|
||||
break;
|
||||
|
||||
case POS_PART:
|
||||
/* Add other_info inherited from the software_info level, if any */
|
||||
if ( swlist->softinfo && swlist->softinfo->other_info )
|
||||
{
|
||||
feature_list *list = swlist->softinfo->other_info;
|
||||
|
||||
while( list->next )
|
||||
{
|
||||
add_feature( swlist, list->next->name, list->next->value );
|
||||
list = list->next;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case POS_DATA:
|
||||
|
@ -46,6 +46,7 @@ struct software_info
|
||||
const char *parentname;
|
||||
const char *year; /* Copyright year on title screen, actual release dates can be tracked in external resources */
|
||||
const char *publisher;
|
||||
feature_list *other_info;
|
||||
UINT32 supported;
|
||||
software_part *partdata;
|
||||
struct software_info *next; /* Used internally */
|
||||
|
Loading…
Reference in New Issue
Block a user