- Fix drumkit name parsing from drumkit.xml by adding <componentList> support

- Fix compile warning on compar_kit()
This commit is contained in:
Arnaud G. GIBERT 2021-11-09 11:00:02 +01:00
parent 3d8e11423b
commit 17383c6a99

View File

@ -87,6 +87,7 @@ struct kit_info {
struct hp_info {
char scan_only;
char in_info;
char in_component_list;
char in_instrument_list;
char in_instrument;
char in_layer;
@ -105,6 +106,12 @@ startElement(void *userData, const char *name, const char **atts)
struct hp_info* info = (struct hp_info*)userData;
info->cur_off = 0;
if (info->in_info) {
if (!info->in_component_list) {
if (!strcmp(name,"componentList")) {
info->in_component_list = 1;
}
else
{
if (info->in_instrument) {
if (!strcmp(name,"layer") && !info->scan_only) {
info->in_layer = 1;
@ -122,6 +129,8 @@ startElement(void *userData, const char *name, const char **atts)
if (!strcmp(name,"instrumentList"))
info->in_instrument_list = 1;
}
}
}
} else {
if (!strcmp(name,"drumkit_info"))
info->in_info = 1;
@ -135,7 +144,7 @@ endElement(void *userData, const char *name)
if (info->cur_off == MAX_CHAR_DATA) info->cur_off--;
info->cur_buf[info->cur_off]='\0';
if (info->in_info && !info->in_instrument_list && !strcmp(name,"name"))
if (info->in_info && !info->in_component_list && !info->in_instrument_list && !strcmp(name,"name"))
info->kit_info->name = strdup(info->cur_buf);
if (info->scan_only && info->in_info && !info->in_instrument_list && !strcmp(name,"info"))
info->kit_info->desc = strdup(info->cur_buf);
@ -187,6 +196,7 @@ endElement(void *userData, const char *name)
info->cur_instrument = NULL;
info->in_instrument = 0;
}
if (info->in_component_list && !strcmp(name,"componentList")) info->in_component_list = 0;
if (info->in_instrument_list && !strcmp(name,"instrumentList")) info->in_instrument_list = 0;
if (info->in_info && !strcmp(name,"drumkit_info")) info->in_info = 0;
}
@ -232,7 +242,7 @@ static char* expand_path(char* path, char* buf) {
static int *compar_kit(const void *p1, const void *p2)
static int compar_kit(const void *p1, const void *p2)
{
return (int) strcmp( (* (scanned_kit **) p1)->name, (* (scanned_kit **) p2)->name);
}