kopia lustrzana https://github.com/jamescoxon/dl-fldigi
Changes to spotting regex parsing
Windows does not recognize '\2' reference tag in regular expression defined in pskrep.cxx. Changed to combination of regexec and string find processing for required result. Added modem frequency to spotting call when logging or forcing a spot report.pull/2/head
rodzic
495ac85df0
commit
fbca004944
|
@ -14,6 +14,8 @@
|
||||||
#include "flinput2.h"
|
#include "flinput2.h"
|
||||||
#include "spot.h"
|
#include "spot.h"
|
||||||
|
|
||||||
|
#include "debug.h"
|
||||||
|
|
||||||
#include <FL/Enumerations.H>
|
#include <FL/Enumerations.H>
|
||||||
#include <FL/Fl_Slider.H>
|
#include <FL/Fl_Slider.H>
|
||||||
#include <FL/fl_ask.H>
|
#include <FL/fl_ask.H>
|
||||||
|
|
|
@ -1433,7 +1433,8 @@ void cb_QRZ(Fl_Widget *b, void *)
|
||||||
break;
|
break;
|
||||||
case FL_RIGHT_MOUSE:
|
case FL_RIGHT_MOUSE:
|
||||||
if (quick_choice(string("Spot \"").append(inpCall->value()).append("\"?").c_str(), false))
|
if (quick_choice(string("Spot \"").append(inpCall->value()).append("\"?").c_str(), false))
|
||||||
spot_manual(inpCall->value(), inpLoc->value());
|
// spot_manual(inpCall->value(), inpLoc->value());
|
||||||
|
spot_manual(inpCall->value(), inpLoc->value(), active_modem->get_freq());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -2879,15 +2880,16 @@ void put_rx_char(unsigned int data)
|
||||||
|
|
||||||
WriteARQ(data);
|
WriteARQ(data);
|
||||||
|
|
||||||
|
bool viewer = (mode >= MODE_PSK_FIRST && mode <= MODE_PSK_LAST && dlgViewer && dlgViewer->visible());
|
||||||
|
if (progStatus.spot_recv && !viewer)
|
||||||
|
spot_recv(data);
|
||||||
|
|
||||||
string s;
|
string s;
|
||||||
if (iscntrl(data))
|
if (iscntrl(data))
|
||||||
s = ascii2[data & 0x7F];
|
s = ascii2[data & 0x7F];
|
||||||
else {
|
else
|
||||||
s += data;
|
s += data;
|
||||||
bool viewer = (mode >= MODE_PSK_FIRST && mode <= MODE_PSK_LAST && dlgViewer && dlgViewer->visible());
|
|
||||||
if (progStatus.spot_recv && !viewer)
|
|
||||||
spot_recv(data);
|
|
||||||
}
|
|
||||||
if (Maillogfile)
|
if (Maillogfile)
|
||||||
Maillogfile->log_to_file(cLogfile::LOG_RX, s);
|
Maillogfile->log_to_file(cLogfile::LOG_RX, s);
|
||||||
|
|
||||||
|
@ -3099,6 +3101,7 @@ void put_echo_char(unsigned int data)
|
||||||
|
|
||||||
if (progStatus.LOGenabled)
|
if (progStatus.LOGenabled)
|
||||||
logfile->log_to_file(cLogfile::LOG_TX, s);
|
logfile->log_to_file(cLogfile::LOG_TX, s);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void resetRTTY() {
|
void resetRTTY() {
|
||||||
|
|
|
@ -195,7 +195,8 @@ static void send_IPC_log(void)
|
||||||
void submit_log(void)
|
void submit_log(void)
|
||||||
{
|
{
|
||||||
if (progStatus.spot_log)
|
if (progStatus.spot_log)
|
||||||
spot_log(inpCall->value(), inpLoc->value());
|
// spot_log(inpCall->value(), inpLoc->value());
|
||||||
|
spot_log(inpCall->value(), inpLoc->value(), active_modem->get_freq());
|
||||||
|
|
||||||
struct tm *tm;
|
struct tm *tm;
|
||||||
time_t t;
|
time_t t;
|
||||||
|
|
|
@ -63,8 +63,16 @@ LOG_SET_SOURCE(debug::LOG_SPOTTER);
|
||||||
// The regular expression that matches the spotter's buffer when it calls us.
|
// The regular expression that matches the spotter's buffer when it calls us.
|
||||||
// It must define at least two capturing groups, the second of which is the
|
// It must define at least two capturing groups, the second of which is the
|
||||||
// spotted callsign.
|
// spotted callsign.
|
||||||
#define CALLSIGN_RE "[[:alnum:]]?[[:alpha:]/]+[[:digit:]]+[[:alnum:]/]+"
|
//#define CALLSIGN_RE "[[:alnum:]]?[[:alpha:]/]+[[:digit:]]+[[:alnum:]/]+"
|
||||||
#define PSKREP_RE "(de|cq|qrz)[^[:alnum:]/\n]+" "(" CALLSIGN_RE ")" " +(.* +)?\\2[^[:alnum:]]+$"
|
//#define PSKREP_RE "(de|cq|qrz)[^[:alnum:]/\n]+" "(" CALLSIGN_RE ")" " +(.* +)?\\2[^[:alnum:]]+$"
|
||||||
|
|
||||||
|
#define CALLSIGN_RE "("\
|
||||||
|
"[[:alnum:]]+/[[:alnum:]]?[[:alpha:]]+[[:digit:]]+[[:alnum:]/]+"\
|
||||||
|
")|("\
|
||||||
|
"[[:alnum:]]?[[:alpha:]]+[[:digit:]]+[[:alnum:]/]+"\
|
||||||
|
")"
|
||||||
|
|
||||||
|
#define PSKREP_RE "(de|cq|qrz)[^[:alnum:]]+" "(" CALLSIGN_RE ")" " +(.* +)?\\2[^[:alnum:]]+$"
|
||||||
|
|
||||||
// Try to flush the report queue every SEND_INTERVAL seconds.
|
// Try to flush the report queue every SEND_INTERVAL seconds.
|
||||||
#define SEND_INTERVAL 300
|
#define SEND_INTERVAL 300
|
||||||
|
|
|
@ -32,8 +32,12 @@
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "spot.h"
|
#include "spot.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
#define SEARCHLEN 32
|
#define SEARCHLEN 32
|
||||||
#define DECBUFSIZE 8 * SEARCHLEN
|
//#define DECBUFSIZE 8 * SEARCHLEN
|
||||||
|
#define DECBUFSIZE 4 * SEARCHLEN
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
@ -55,10 +59,22 @@ typedef vector<callback_t> cblist_t;
|
||||||
|
|
||||||
static cblist_t cblist;
|
static cblist_t cblist;
|
||||||
|
|
||||||
|
#define CALLSIGN_RE "("\
|
||||||
|
"[[:alnum:]]+/[[:alnum:]]?[[:alpha:]]+[[:digit:]]+[[:alnum:]/]+"\
|
||||||
|
")|("\
|
||||||
|
"[[:alnum:]]?[[:alpha:]]+[[:digit:]]+[[:alnum:]/]+"\
|
||||||
|
")"
|
||||||
|
#define CALLSIGN_REP CALLSIGN_RE "[^[:alnum:]]+$"
|
||||||
|
|
||||||
|
static fre_t re_call(CALLSIGN_REP, REG_EXTENDED);
|
||||||
|
|
||||||
void spot_recv(char c, int decoder, int afreq)
|
void spot_recv(char c, int decoder, int afreq)
|
||||||
{
|
{
|
||||||
static trx_mode last_mode = NUM_MODES + 1;
|
static trx_mode last_mode = NUM_MODES + 1;
|
||||||
|
|
||||||
|
if (c == '\n' ) c = ' ';
|
||||||
|
if (c < ' ') return;
|
||||||
|
|
||||||
switch (decoder) {
|
switch (decoder) {
|
||||||
case -1: // mode without multiple decoders
|
case -1: // mode without multiple decoders
|
||||||
decoder = active_modem->get_mode();
|
decoder = active_modem->get_mode();
|
||||||
|
@ -84,19 +100,35 @@ void spot_recv(char c, int decoder, int afreq)
|
||||||
string& buf = buffers[decoder];
|
string& buf = buffers[decoder];
|
||||||
buf.reserve(DECBUFSIZE);
|
buf.reserve(DECBUFSIZE);
|
||||||
|
|
||||||
buf += c;
|
size_t n = buf.length();
|
||||||
string::size_type n = buf.length();
|
|
||||||
if (n == DECBUFSIZE)
|
if (n == DECBUFSIZE)
|
||||||
buf.erase(0, DECBUFSIZE - SEARCHLEN);
|
buf.erase(0, DECBUFSIZE - SEARCHLEN);
|
||||||
const char* search = buf.c_str() + (n > SEARCHLEN ? n - SEARCHLEN : 0);
|
|
||||||
|
|
||||||
for (cblist_t::iterator i = cblist.begin(); i != cblist.end(); ++i) {
|
buf += toupper(c);
|
||||||
if (i->rcb && unlikely(i->re->match(search))) {
|
n = buf.length();
|
||||||
const vector<regmatch_t>& m = i->re->suboff();
|
|
||||||
if (m.empty())
|
//#ifdef __CYGWIN__
|
||||||
i->rcb(afreq, search, NULL, 0, i->data);
|
// This code segment resolves regexec problems on Windows
|
||||||
else
|
// Windows regex compile does not recognize the \2 tag in the reg expression
|
||||||
i->rcb(afreq, search, &m[0], m.size(), i->data);
|
// (see pskrep.cxx)
|
||||||
|
|
||||||
|
string search = buf.substr(n> SEARCHLEN ? n - SEARCHLEN: 0);
|
||||||
|
|
||||||
|
for (cblist_t::iterator cbl = cblist.begin(); cbl != cblist.end(); ++cbl) {
|
||||||
|
if (cbl->rcb) {
|
||||||
|
if (re_call.match(search.c_str())) {
|
||||||
|
const vector<regmatch_t>& offset = re_call.suboff();
|
||||||
|
if (!offset.empty()) {
|
||||||
|
size_t pos = offset[0].rm_so;
|
||||||
|
string call = search.substr(pos);
|
||||||
|
size_t firstcall = search.find(call);
|
||||||
|
if (firstcall != pos)
|
||||||
|
if ( ( (pos = search.find("DE ")) != string::npos && pos < firstcall) ||
|
||||||
|
( (pos = search.find("CQ ")) != string::npos && pos < firstcall) ||
|
||||||
|
( (pos = search.find("QRZ ")) != string::npos && pos < firstcall) )
|
||||||
|
cbl->rcb(afreq, search.c_str(), &offset[0], offset.size(), cbl->data);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue