hlog: add 'section' command to set ARRL/RAC section abbreviation

Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
2 files changed, 17 insertions(+), 0 deletions(-)

M README
M hlog/hlog.c
M README +1 -0
@@ 184,6 184,7 @@ The commands are:
  cm <string>      - set (short) comment for this QSO
  seqs <num>       - set sent contest serial (e.g., 123)
  seqr <num>       - set received contest serial (e.g., 456)
+ section <name>   - set received section abbreviation (e.g., EMA)
 
 In general, the more common commands try to be short, so one is not forced
 to type long strings in the middle of a contact.  As a result, many commands

          
M hlog/hlog.c +16 -0
@@ 236,6 236,7 @@ static enum cmd_result cmd_seq_s(char *a
 static enum cmd_result cmd_pota(char *arg, char *error, size_t errorlen);
 static enum cmd_result cmd_sota(char *arg, char *error, size_t errorlen);
 static enum cmd_result cmd_wwff(char *arg, char *error, size_t errorlen);
+static enum cmd_result cmd_section(char *arg, char *error, size_t errorlen);
 
 static struct val *state_get_date(void);
 static struct val *state_get_start_time(void);

          
@@ 335,6 336,7 @@ static const struct command commands[] =
 	{ "pota",   cmd_pota,		true,  0 },
 	{ "sota",   cmd_sota,		true,  0 },
 	{ "wwff",   cmd_wwff,		true,  0 },
+	{ "section",cmd_section,	true,  0 },
 };
 
 static WINDOW *header_win;

          
@@ 1388,6 1390,20 @@ static enum cmd_result cmd_wwff(char *ar
 	return __cmd_sig(arg, error, errorlen, "WWFF", "rx_wwff");
 }
 
+static enum cmd_result cmd_section(char *arg, char *error, size_t errorlen)
+{
+	int ret;
+
+	ret = qso_set_section(&current->qso->rx, arg);
+	if (ret) {
+		snprintf(error, errorlen, "Failed to set section: %s",
+			 xstrerror(ret));
+		return ret;
+	}
+
+	return CR_OK;
+}
+
 static void print_field(WINDOW *win, int row, int col, const char *str,
 			size_t width, bool dirty)
 {