@@ 388,7 388,7 @@ int main(int argc, char **argv)
* 1. ncurses ui
* 2. wsjtx udp listener
*/
- ret = wsjtx_start();
+ ret = wsjtx_start(lua);
if (ret)
goto err_script;
@@ 30,6 30,7 @@
#include <hlog/udpsvc.h>
#include "contest.h"
+#include "script.h"
#include "wsjtx.h"
static struct udpsvc *svc;
@@ 218,7 219,8 @@ static char *terminate_str(char *out, si
return out;
}
-static int log_qso(struct message *msg, const void *raw, size_t rawlen)
+static int log_qso(struct xlua_state *lua, struct message *msg, const void *raw,
+ size_t rawlen)
{
char tmp[1024];
struct qso *qso;
@@ 337,6 339,11 @@ static int log_qso(struct message *msg,
if (ret)
goto err;
+ /* inform the contest script */
+ ret = script_event_qso_done(lua, qso, tmp, sizeof(tmp));
+ if (ret)
+ goto err;
+
/*
* Now, save the QSO.
*/
@@ 349,8 356,9 @@ err:
}
static void wsjtx_process(const union xsockaddr *addr, size_t addrlen,
- void *buf, size_t len, void *unused)
+ void *buf, size_t len, void *arg)
{
+ struct xlua_state *lua = arg;
struct rawmessage *raw = buf;
struct message msg;
struct buffer payload;
@@ 391,7 399,7 @@ static void wsjtx_process(const union xs
if (!decode_qso_logged(&msg, &payload))
return;
- ret = log_qso(&msg, buf, len);
+ ret = log_qso(lua, &msg, buf, len);
if (ret)
cmn_err(CE_WARN, "Failed to log QSO: %s",
xstrerror(ret));
@@ 402,12 410,12 @@ static void wsjtx_process(const union xs
}
}
-int wsjtx_start(void)
+int wsjtx_start(struct xlua_state *lua)
{
struct udpsvc *svc;
svc = udpsvc(WSJTX_HOST, WSJTX_PORT, false, "wsjtx", wsjtx_process,
- NULL);
+ lua);
if (IS_ERR(svc)) {
cmn_err(CE_ERROR, "wsjtx: failed to start listener: %s",
xstrerror(PTR_ERR(svc)));
@@ 1,5 1,5 @@
/*
- * Copyright (c) 2021 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
+ * Copyright (c) 2021,2024 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
@@ 23,7 23,9 @@
#ifndef __WSJTX_H
#define __WSJTX_H
-extern int wsjtx_start(void);
+#include <hlog-lua/xlua.h>
+
+extern int wsjtx_start(struct xlua_state *lua);
extern void wsjtx_stop(void);
#endif