Skip to content

Commit eb94921

Browse files
committedApr 26, 2021
Update KISSPORT default handling
- Do not require use of KISSPORT 0 to remove default setting from KISSPORT configuration - For existing config files with KISSPORT 0, warn that the setting is not needed and ignore
1 parent b66c21d commit eb94921

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed
 

‎src/config.c

+30-30
Original file line numberDiff line numberDiff line change
@@ -857,8 +857,6 @@ void config_init (char *fname, struct audio_s *p_audio_config,
857857
p_misc_config->kiss_port[i] = 0; // entry not used.
858858
p_misc_config->kiss_chan[i] = -1;
859859
}
860-
p_misc_config->kiss_port[0] = DEFAULT_KISS_PORT;
861-
p_misc_config->kiss_chan[0] = -1; // all channels.
862860

863861
p_misc_config->enable_kiss_pt = 0; /* -p option */
864862
p_misc_config->kiss_copy = 0;
@@ -4537,6 +4535,13 @@ void config_init (char *fname, struct audio_s *p_audio_config,
45374535
continue;
45384536
}
45394537

4538+
if (tcp_port == 0) {
4539+
// If existing config files have KISSPORT 0, ignore it and move on
4540+
text_color_set(DW_COLOR_ERROR);
4541+
dw_printf ("Line %d: Warning: KISSPORT 0 setting no longer needed.\n", line);
4542+
continue;
4543+
}
4544+
45404545
t = split(NULL,0);
45414546
if (t != NULL) {
45424547
chan = atoi(t);
@@ -4547,37 +4552,27 @@ void config_init (char *fname, struct audio_s *p_audio_config,
45474552
}
45484553
}
45494554

4550-
// "KISSPORT 0" is used to remove the default entry.
4551-
4552-
if (tcp_port == 0) {
4553-
p_misc_config->kiss_port[0] = 0; // Should all be wiped out?
4554-
}
4555-
else {
4556-
4557-
// Try to find an empty slot.
4558-
// A duplicate TCP port number will overwrite the previous value.
4555+
// Try to find an empty slot.
4556+
// A duplicate TCP port number will overwrite the previous value.
45594557

4560-
int slot = -1;
4561-
for (int i = 0; i < MAX_KISS_TCP_PORTS && slot == -1; i++) {
4562-
if (p_misc_config->kiss_port[i] == tcp_port) {
4563-
slot = i;
4564-
if ( ! (slot == 0 && tcp_port == DEFAULT_KISS_PORT)) {
4565-
text_color_set(DW_COLOR_ERROR);
4566-
dw_printf ("Line %d: Warning: Duplicate TCP port %d will overwrite previous value.\n", line, tcp_port);
4567-
}
4568-
}
4569-
else if (p_misc_config->kiss_port[i] == 0) {
4570-
slot = i;
4571-
}
4572-
}
4573-
if (slot >= 0) {
4574-
p_misc_config->kiss_port[slot] = tcp_port;
4575-
p_misc_config->kiss_chan[slot] = chan;
4576-
}
4577-
else {
4558+
int slot = -1;
4559+
for (int i = 0; i < MAX_KISS_TCP_PORTS && slot == -1; i++) {
4560+
if (p_misc_config->kiss_port[i] == tcp_port) {
4561+
slot = i;
45784562
text_color_set(DW_COLOR_ERROR);
4579-
dw_printf ("Line %d: Too many KISSPORT commands.\n", line);
4563+
dw_printf ("Line %d: Warning: Duplicate TCP port %d will overwrite previous value.\n", line, tcp_port);
45804564
}
4565+
else if (p_misc_config->kiss_port[i] == 0) {
4566+
slot = i;
4567+
}
4568+
}
4569+
if (slot >= 0) {
4570+
p_misc_config->kiss_port[slot] = tcp_port;
4571+
p_misc_config->kiss_chan[slot] = chan;
4572+
}
4573+
else {
4574+
text_color_set(DW_COLOR_ERROR);
4575+
dw_printf ("Line %d: Too many KISSPORT commands.\n", line);
45814576
}
45824577
}
45834578

@@ -5357,6 +5352,11 @@ void config_init (char *fname, struct audio_s *p_audio_config,
53575352
p_misc_config->maxv22 = p_misc_config->retry / 3;
53585353
}
53595354

5355+
/* If no kiss port specified, add default to first slot */
5356+
if (p_misc_config->kiss_port[0] == 0) {
5357+
p_misc_config->kiss_port[0] = DEFAULT_KISS_PORT;
5358+
}
5359+
53605360
} /* end config_init */
53615361

53625362

0 commit comments

Comments
 (0)