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
David Freese 2009-01-08 05:41:52 -06:00
rodzic 495ac85df0
commit fbca004944
5 zmienionych plików z 66 dodań i 20 usunięć

Wyświetl plik

@ -14,6 +14,8 @@
#include "flinput2.h"
#include "spot.h"
#include "debug.h"
#include <FL/Enumerations.H>
#include <FL/Fl_Slider.H>
#include <FL/fl_ask.H>

Wyświetl plik

@ -1433,7 +1433,8 @@ void cb_QRZ(Fl_Widget *b, void *)
break;
case FL_RIGHT_MOUSE:
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;
default:
break;
@ -2879,15 +2880,16 @@ void put_rx_char(unsigned int 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;
if (iscntrl(data))
s = ascii2[data & 0x7F];
else {
else
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)
Maillogfile->log_to_file(cLogfile::LOG_RX, s);
@ -3099,6 +3101,7 @@ void put_echo_char(unsigned int data)
if (progStatus.LOGenabled)
logfile->log_to_file(cLogfile::LOG_TX, s);
}
void resetRTTY() {

Wyświetl plik

@ -195,7 +195,8 @@ static void send_IPC_log(void)
void submit_log(void)
{
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;
time_t t;

Wyświetl plik

@ -63,8 +63,16 @@ LOG_SET_SOURCE(debug::LOG_SPOTTER);
// 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
// spotted callsign.
#define CALLSIGN_RE "[[:alnum:]]?[[:alpha:]/]+[[:digit:]]+[[:alnum:]/]+"
#define PSKREP_RE "(de|cq|qrz)[^[:alnum:]/\n]+" "(" CALLSIGN_RE ")" " +(.* +)?\\2[^[:alnum:]]+$"
//#define CALLSIGN_RE "[[:alnum:]]?[[:alpha:]/]+[[:digit:]]+[[: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.
#define SEND_INTERVAL 300

Wyświetl plik

@ -32,8 +32,12 @@
#include "debug.h"
#include "spot.h"
#include <iostream>
using namespace std;
#define SEARCHLEN 32
#define DECBUFSIZE 8 * SEARCHLEN
//#define DECBUFSIZE 8 * SEARCHLEN
#define DECBUFSIZE 4 * SEARCHLEN
using namespace std;
@ -55,10 +59,22 @@ typedef vector<callback_t> cblist_t;
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)
{
static trx_mode last_mode = NUM_MODES + 1;
if (c == '\n' ) c = ' ';
if (c < ' ') return;
switch (decoder) {
case -1: // mode without multiple decoders
decoder = active_modem->get_mode();
@ -84,19 +100,35 @@ void spot_recv(char c, int decoder, int afreq)
string& buf = buffers[decoder];
buf.reserve(DECBUFSIZE);
buf += c;
string::size_type n = buf.length();
size_t n = buf.length();
if (n == DECBUFSIZE)
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) {
if (i->rcb && unlikely(i->re->match(search))) {
const vector<regmatch_t>& m = i->re->suboff();
if (m.empty())
i->rcb(afreq, search, NULL, 0, i->data);
else
i->rcb(afreq, search, &m[0], m.size(), i->data);
buf += toupper(c);
n = buf.length();
//#ifdef __CYGWIN__
// This code segment resolves regexec problems on Windows
// Windows regex compile does not recognize the \2 tag in the reg expression
// (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);
}
}
}
}
}