common: add ARRL/RAC section to qso_side

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

M common/adif.c
M common/include/hlog/qso.h
M common/qso-pack.c
M common/qso.c
M xlua/qso.c
M common/adif.c +1 -0
@@ 111,6 111,7 @@ static const struct side_field side_fiel
 	{ "my_itu_zone",      "ituz",             qso_get_zone_itu },
 	{ "my_cq_zone",       "cqz",              qso_get_zone_cqz },
 	{ "stx",              "srx",              qso_get_seq },
+	{ "my_arrl_sect",     "arrl_sect",        qso_get_section_val },
 };
 
 static const struct side_field strict_mode_fields[] = {

          
M common/include/hlog/qso.h +8 -1
@@ 1,5 1,5 @@ 
 /*
- * Copyright (c) 2020-2021 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ * Copyright (c) 2020-2021,2023 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal

          
@@ 52,6 52,7 @@ struct qso_side {
 	struct val *itu;
 	struct val *cqz;
 	struct val *seq; /* contest qso seq # */
+	struct val *section; /* ARRL/RAC section name */
 };
 
 struct qso {

          
@@ 144,6 145,9 @@ extern int qso_set_zone_cqz_val(struct q
 extern int qso_set_seq(struct qso_side *side, uint64_t seq);
 extern int qso_set_seq_user(struct qso_side *side, const char *seq);
 extern int qso_set_seq_val(struct qso_side *side, struct val *val);
+extern int qso_set_section(struct qso_side *side, const char *section);
+extern int qso_set_section_str(struct qso_side *side, struct str *section);
+extern int qso_set_section_val(struct qso_side *side, struct val *val);
 
 /*
  * Clear the various parts of a QSO.

          
@@ 171,6 175,7 @@ extern void qso_clear_zone_dxcc(struct q
 extern void qso_clear_zone_itu(struct qso_side *side);
 extern void qso_clear_zone_cqz(struct qso_side *side);
 extern void qso_clear_seq(struct qso_side *side);
+extern void qso_clear_section(struct qso_side *side);
 
 /*
  * Get the various parts of a QSO.

          
@@ 211,5 216,7 @@ extern struct val *qso_get_zone_dxcc(con
 extern struct val *qso_get_zone_itu(const struct qso_side *side);
 extern struct val *qso_get_zone_cqz(const struct qso_side *side);
 extern struct val *qso_get_seq(const struct qso_side *side);
+extern struct str *qso_get_section(const struct qso_side *side);
+extern struct val *qso_get_section_val(const struct qso_side *side);
 
 #endif

          
M common/qso-pack.c +1 -0
@@ 57,6 57,7 @@ static const struct side_field {
 	{ "itu",       0, qso_get_zone_itu,          qso_set_zone_itu_val },
 	{ "cqz",       0, qso_get_zone_cqz,          qso_set_zone_cqz_val },
 	{ "seq",       0, qso_get_seq,               qso_set_seq_val },
+	{ "section",   1, qso_get_section_val,       qso_set_section_val },
 };
 
 /*

          
M common/qso.c +8 -0
@@ 69,6 69,7 @@ static void qso_side_free(struct qso_sid
 	val_putref(side->itu);
 	val_putref(side->cqz);
 	val_putref(side->seq);
+	val_putref(side->section);
 }
 
 void qso_free(struct qso *qso)

          
@@ 142,6 143,7 @@ static void qso_side_reset(struct qso_si
 	qso_clear_zone_itu(side);
 	qso_clear_zone_cqz(side);
 	qso_clear_seq(side);
+	qso_clear_section(side);
 }
 
 void qso_reset(struct qso *qso)

          
@@ 183,6 185,7 @@ static void qso_copy_side(struct qso_sid
 	dst->itu = val_getref(src->itu);
 	dst->cqz = val_getref(src->cqz);
 	dst->seq = val_getref(src->seq);
+	dst->section = val_getref(src->section);
 }
 
 void qso_copy(struct qso *dst, struct qso *src)

          
@@ 825,6 828,11 @@ int qso_set_seq_user(struct qso_side *si
 GEN_GSC(seq, seq, VT_INT);
 GEN_ALIAS(seq)
 
+/* section */
+GEN_GSC(section, section, VT_STR);
+GET_STR(section, section);
+SET_STR(section, section);
+
 /* band - derived from freq, no set/clear */
 struct val *qso_get_band(const struct qso_side *side)
 {

          
M xlua/qso.c +3 -0
@@ 123,6 123,9 @@ static const struct field side_fields[] 
 			  qso_clear_zone_cqz } },
 	{ "seq", T_SIDE,
 		.side = { qso_get_seq, qso_set_seq_user, qso_clear_seq } },
+	{ "section", T_SIDE,
+		.side = { qso_get_section_val, qso_set_section,
+			  qso_clear_section } },
 };
 
 struct field qso_fields[] = {