Use radio_tab[] for compatibility check.
This commit is contained in:
parent
8be79da3e0
commit
dfe210a54c
2
Makefile
2
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
|
||||
|
@ -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
|
||||
|
8
md380.c
8
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;
|
||||
|
17
radio.c
17
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;
|
||||
}
|
||||
|
5
radio.h
5
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.
|
||||
//
|
||||
|
8
uv380.c
8
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;
|
||||
|
Loading…
Reference in New Issue
Block a user