Add /q command for converting Q-Code (case-insensitive) to Question/Answer combination

This commit is contained in:
2026-08-31 22:04:07 +02:00
parent c056b1b67a
commit 44d13ab071
7 changed files with 144 additions and 3 deletions
+15
View File
@@ -21,6 +21,9 @@
// Longest code in the morse table is '$' ('...-..-'), seven characters.
#define HAMMY_MORSE_MAX 16
// The current longest string in the qcodes table is 42; 128 is pretty generous. TODO: Change this if the qcodes table ever changes
#define HAMMY_QCODE_MAX 128
// A country has at most a handful of licence classes, each with at most a
// couple of segments covering one exact frequency. 24 is generous.
#define HAMMY_FREQ_PRIVS_MAX 24
@@ -33,6 +36,7 @@ struct hammy_refdb_t {
sqlite3_stmt* stExact;
sqlite3_stmt* stPrefix;
sqlite3_stmt* stMorse;
sqlite3_stmt* stQCode;
sqlite3_stmt* stFreqMain;
sqlite3_stmt* stFreqIaru;
sqlite3_stmt* stFreqNearest;
@@ -41,6 +45,10 @@ struct hammy_refdb_t {
sqlite3_stmt* stCountryList;
char morseCode[HAMMY_MORSE_MAX]; // Scratch for the last hammy_refdb_get_morse() hit
char qcodeQuestion[HAMMY_QCODE_MAX]; // Scratch for the last hammy_refdb_get_qcode() hit
char qcodeAnswer[HAMMY_QCODE_MAX]; // Scratch for the last hammy_refdb_get_qcode() hit
char version[64];
};
@@ -146,6 +154,13 @@ bool hammy_refdb_dxcc(hammy_refdb_t* db, const char* callsign, hammy_dxcc_t* out
// the NEXT call on the same handle - copy it if it has to outlive that.
bool hammy_refdb_get_morse(hammy_refdb_t* db, char c, const char** out);
// Looks up a QSO code in the qcodes table. Case-insensitive; non-ASCII bytes
// never match. Returns false if not found, leaving *out untouched.
//
// On a hit *out points at the storage owned by refdb and is only valid until
// the NEXT call on the same handle - copy it if it has to outlive that.
bool hammy_refdb_get_qcode(hammy_refdb_t* db, const char* code, const char** outQuestion, const char** outAnswer);
// What band is freq_hz in, and who may transmit there.
//
// country is an ISO 3166-1 alpha-2 code; NULL or empty means "US". Always
+14
View File
@@ -0,0 +1,14 @@
#ifndef HAMMY_UTILS_H
#define HAMMY_UTILS_H
#include <ctype.h>
#include <stdio.h>
#include <stdint.h>
// Converts in-place to uppercase
void hammy_to_uppercase(char* str);
// Converts in-place to lowercase
void hammy_to_lowercase(char* str);
#endif