diff --git a/src/callinput.c b/src/callinput.c index 1a7a4cd5..5db5e5c8 100644 --- a/src/callinput.c +++ b/src/callinput.c @@ -77,6 +77,7 @@ #include "time_update.h" #include "trx_memory.h" #include "ui_utils.h" +#include "utils.h" #include "showzones.h" #include "bands.h" #include "fldigixmlrpc.h" @@ -85,7 +86,6 @@ typedef enum { STORE_OR_POP, POP, SWAP } memory_op_t; void send_bandswitch(freq_t freq); int autosend(void); -bool plain_number(char *str); void handle_bandswitch(int direction); void handle_memory_operation(memory_op_t op); @@ -877,30 +877,6 @@ bool valid_call_char(int ch) { || ch == '/'; } -/** check if string is plain number - * - * Check if string contains only digits - * \param str the string to check - * \return true if only digits inside - * false contains at least one non-digit or it's an empty string - */ -bool plain_number(char *str) { - int i; - - if (strlen(str) == 0) { - return false; - } - - for (i = 0; i < strlen(str); i++) { - if (!isdigit(str[i])) { - return false; - } - } - - return true; -} - - /** autosend function * * autosend allow an operator in RUN mode to just enter the call of the diff --git a/src/callinput.h b/src/callinput.h index 817e8fee..776f00e3 100644 --- a/src/callinput.h +++ b/src/callinput.h @@ -28,6 +28,5 @@ int callinput(void); void send_bandswitch(freq_t freq); bool valid_call_char(int ch); -bool plain_number(char *str); #endif /* CALLINPUT_H */ diff --git a/src/main.c b/src/main.c index b7438ef7..0ed137bf 100644 --- a/src/main.c +++ b/src/main.c @@ -693,6 +693,8 @@ static void init_variables() { #ifdef HAVE_PYTHON FREE_DYNAMIC_STRING(plugin_config); #endif + + init_contests(); } /** load all databases diff --git a/src/parse_logcfg.c b/src/parse_logcfg.c index 1a07f9c6..d9f68dce 100644 --- a/src/parse_logcfg.c +++ b/src/parse_logcfg.c @@ -1304,6 +1304,7 @@ static config_t logcfg_configs[] = { {"USEPARTIALS", CFG_BOOL(use_part)}, {"PARTIALS", CFG_BOOL(partials)}, {"RECALL_MULTS", CFG_CONTEST_BOOL(recall_mult)}, + {"RECALL_NUMERIC_EXCHANGES", CFG_CONTEST_BOOL(recall_numeric_exchanges)}, {"WYSIWYG_MULTIBAND", CFG_BOOL(wysiwyg_multi)}, {"WYSIWYG_ONCE", CFG_BOOL(wysiwyg_once)}, {"RIT_CLEAR", CFG_BOOL(rit)}, diff --git a/src/recall_exchange.c b/src/recall_exchange.c index 3485e413..fc39f462 100644 --- a/src/recall_exchange.c +++ b/src/recall_exchange.c @@ -26,6 +26,7 @@ #include "tlf.h" #include "tlf_curses.h" #include "setcontest.h" +#include "utils.h" /** \brief Recall former exchange or lookup initial exchange file @@ -63,6 +64,13 @@ int get_proposed_exchange(void) { } } + if (found == 1 && + !contest->recall_numeric_exchanges && plain_number(proposed_exchange)) { + // do not recall numeric exchanges + proposed_exchange[0] = 0; + found = -1; + } + if (found == -1) { /* if no exchange could be recycled and no comment available diff --git a/src/sendqrg.c b/src/sendqrg.c index 57d02508..890f5286 100644 --- a/src/sendqrg.c +++ b/src/sendqrg.c @@ -24,7 +24,7 @@ #include #include "bands.h" -#include "callinput.h" +#include "utils.h" #include "cw_utils.h" #include "err_utils.h" #include "hamlib_keyer.h" diff --git a/src/setcontest.c b/src/setcontest.c index efe1ed04..5a2939fc 100644 --- a/src/setcontest.c +++ b/src/setcontest.c @@ -297,9 +297,19 @@ contest_config_t *lookup_contest(char *name) { } +/** initalize contests + * + */ +void init_contests() { + for (int i = 0; i < NR_CONTESTS; i++) { + contest_configs[i]->recall_numeric_exchanges = true; + } +} + + /** show a list of supported/hard-coded contests * - * works out of ncurses context for 'tlf -l' i + * works out of ncurses context for 'tlf -l' */ void list_contests() { puts( diff --git a/src/setcontest.h b/src/setcontest.h index 964be8ff..e1a8a772 100644 --- a/src/setcontest.h +++ b/src/setcontest.h @@ -29,6 +29,7 @@ extern contest_config_t config_qso; +void init_contests(); bool general_ismulti(spot *data); contest_config_t *lookup_contest(char *name); void list_contests(); diff --git a/src/tlf.h b/src/tlf.h index 3fb4ab5a..76a14bd3 100644 --- a/src/tlf.h +++ b/src/tlf.h @@ -259,6 +259,7 @@ typedef struct { contest_type_t id; char *name; bool recall_mult; + bool recall_numeric_exchanges; bool exchange_serial; int exchange_width; struct { diff --git a/src/utils.c b/src/utils.c index 051a88ee..8c217c73 100644 --- a/src/utils.c +++ b/src/utils.c @@ -17,6 +17,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include #include #include #include @@ -233,3 +234,27 @@ void get_partial_callsign(char *call1, char *call2, char *partial) { free_call_parts(cp1); free_call_parts(cp2); } + +/** check if string is plain number + * + * Check if string contains only digits + * \param str the string to check + * \return true if only digits inside + * false contains at least one non-digit or it's an empty string + */ +bool plain_number(char *str) { + int i; + + if (strlen(str) == 0) { + return false; + } + + for (i = 0; i < strlen(str); i++) { + if (!isdigit(str[i])) { + return false; + } + } + + return true; +} + diff --git a/src/utils.h b/src/utils.h index fa53d138..f44c7975 100644 --- a/src/utils.h +++ b/src/utils.h @@ -26,5 +26,6 @@ bool check_qra(char *qra); char *find_available(char *filename); void get_partial_callsign(char *call1, char *call2, char *partial); +bool plain_number(char *str); #endif /* UTILS_H */ diff --git a/test/test_recallexchange.c b/test/test_recallexchange.c index 117495b6..07f51bd3 100644 --- a/test/test_recallexchange.c +++ b/test/test_recallexchange.c @@ -8,6 +8,7 @@ // OBJECT ../src/recall_exchange.o // OBJECT ../src/initial_exchange.o +// OBJECT ../src/utils.o contest_config_t config_any = { .id = 123, diff --git a/tlf.1.in b/tlf.1.in index af718d05..d5d62793 100644 --- a/tlf.1.in +++ b/tlf.1.in @@ -3075,7 +3075,20 @@ Multiplier is DXCC country or section from multiplier file. .B RECALL_MULTS Exchange can be recycled, will be filled into exchange field when it is known (see also -.BR INITIAL_EXCHANGE ). +.BR INITIAL_EXCHANGE +and +.BR RECALL_NUMERIC_EXCHANGES ). +. +.TP +\fBRECALL_NUMERIC_EXCHANGES\fR[=<\fION\fR|\fIOFF\fR>] +Controls whether all-numeric exchanges (like serial or zone number) shall be +recalled when using +.BR RECALL_MULTS . +Default is \fION\fR, meaning that numeric exchanges are also recalled. +If set to \fIOFF\fR then numeric exchanges are not recalled. +This setting can be useful in contests where +a group of stations send fixed non-numeric exchanges +(county or DOK, for example) and the rest sent serial number. . .TP \fBINITIAL_EXCHANGE\fR=\fIexchanges.txt\fR