diff --git a/Makefile b/Makefile index 13b6004..796d2f0 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ CC = gcc -VERSION = 0.6 +VERSION = 0.7 GITCOUNT = $(shell git rev-list HEAD --count) CFLAGS = -g -O -Wall -Werror -DVERSION='"$(VERSION).$(GITCOUNT)"' LDFLAGS = -g diff --git a/Makefile-mingw b/Makefile-mingw index d8c5f10..f282624 100644 --- a/Makefile-mingw +++ b/Makefile-mingw @@ -1,6 +1,6 @@ CC = gcc -VERSION = 0.6 +VERSION = 0.7 GITCOUNT = $(shell git rev-list HEAD --count) CFLAGS = -g -O -Wall -Werror -DVERSION='"$(VERSION).$(GITCOUNT)"' LDFLAGS = -g -s diff --git a/md380.c b/md380.c index 6ca1c97..3d4794f 100644 --- a/md380.c +++ b/md380.c @@ -1373,12 +1373,8 @@ static void md380_parse_parameter(radio_device_t *radio, char *param, char *valu general_settings_t *gs = GET_SETTINGS(); if (strcasecmp("Radio", param) == 0) { - // Accept any of compatible identifiers. - if (strcasecmp("TYT MD-380", value) != 0 && - strcasecmp("Zastone D900", value) != 0 && - strcasecmp("Zastone DP880", value) != 0 && - strcasecmp("Radtel RT-27D", value) != 0) { - fprintf(stderr, "Bad value for %s: %s\n", param, value); + if (!radio_is_compatible(value)) { + fprintf(stderr, "Incompatible model: %s\n", value); exit(-1); } return; diff --git a/radio.c b/radio.c index dabb2e4..4c84e96 100644 --- a/radio.c +++ b/radio.c @@ -340,3 +340,20 @@ void radio_write_csv(const char *filename) device->write_csv(device, csv); fclose(csv); } + +// +// Check for compatible radio model. +// +int radio_is_compatible(const char *name) +{ + int i; + + for (i=0; radio_tab[i].ident; i++) { + // Radio is compatible when it has the same parse routine. + if (device->parse_parameter == radio_tab[i].device->parse_parameter && + strcasecmp(name, radio_tab[i].device->name) == 0) { + return 1; + } + } + return 0; +} diff --git a/radio.h b/radio.h index 722c3cb..eebf9c5 100644 --- a/radio.h +++ b/radio.h @@ -87,6 +87,11 @@ void radio_write_csv(const char *filename); // void radio_list(void); +// +// Check for compatible radio model. +// +int radio_is_compatible(const char *ident); + // // Device-dependent interface to the radio. // diff --git a/uv380.c b/uv380.c index ebdd6c9..bf6456d 100644 --- a/uv380.c +++ b/uv380.c @@ -1466,12 +1466,8 @@ static void uv380_parse_parameter(radio_device_t *radio, char *param, char *valu general_settings_t *gs = GET_SETTINGS(); if (strcasecmp("Radio", param) == 0) { - // Accept any of compatible identifiers. - if (strcasecmp("TYT MD-2017", value) != 0 && - strcasecmp("TYT MD-UV380", value) != 0 && - strcasecmp("TYT MD-UV390", value) != 0 && - strcasecmp("TYT MD-9600", value) != 0) { - fprintf(stderr, "Bad value for %s: %s\n", param, value); + if (!radio_is_compatible(value)) { + fprintf(stderr, "Incompatible model: %s\n", value); exit(-1); } return;