Use radio_tab[] for compatibility check.

This commit is contained in:
Serge 2018-09-13 23:31:39 -07:00
parent 8be79da3e0
commit dfe210a54c
6 changed files with 28 additions and 14 deletions

View File

@ -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

View File

@ -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

View File

@ -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;

17
radio.c
View File

@ -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;
}

View File

@ -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.
//

View File

@ -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;