Skip to content

Commit 05fe044

Browse files
committed
WIP: Submit score to contestonlinescore.com
This adds a new dependency on libcurl and uses it to post the current score and QSO/multiplier count to and contest online scoreboard every two minutes. Since submitting HTTP requests takes time and the current background process also handles time-critical things like sending CW, a new background thread is added that simply loops between submits the score and waiting two minutes. The score is also sent at program exit to submit the last QSOs. New logcfg parameters: ONLINESCORE, ONLINESCORE_URL, ONLINESCORE_USER, ONLINESCORE_PASS. TODO: * proper libcurl autoconf integration * the submitted multiplier information does not properly reflect the contest yet * submitted CABRILLO-OPERATORS data isn't properly displayed by https://contestonlinescore.com, need to read more specs
1 parent c6867ea commit 05fe044

12 files changed

Lines changed: 541 additions & 17 deletions

File tree

.github/workflows/ci-build-ubuntu-22.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
sudo dpkg-reconfigure man-db
2727
#
2828
sudo apt-get -qq update
29-
sudo apt-get install -y libhamlib-dev libxmlrpc-core-c3-dev libglib2.0-dev libcmocka-dev python3-pexpect python3-dev astyle
29+
sudo apt-get install -y libcurl4-openssl-dev libhamlib-dev libxmlrpc-core-c3-dev libglib2.0-dev libcmocka-dev python3-pexpect python3-dev astyle
3030
- name: Set up datadir
3131
run: mkdir datadir && ln -s $PWD/share datadir/tlf
3232
- name: Check source formatting

.github/workflows/ci-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
sudo dpkg-reconfigure man-db
2727
#
2828
sudo apt-get -qq update
29-
sudo apt-get install -y libhamlib-dev libxmlrpc-core-c3-dev libglib2.0-dev libcmocka-dev python3-pexpect python3-dev astyle
29+
sudo apt-get install -y libcurl4-openssl-dev libhamlib-dev libxmlrpc-core-c3-dev libglib2.0-dev libcmocka-dev python3-pexpect python3-dev astyle
3030
- name: Set up datadir
3131
run: mkdir datadir && ln -s $PWD/share datadir/tlf
3232
- name: Check source formatting

configure.ac

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ CPPFLAGS=$tlf_saved_CPPFLAGS
124124
CFLAGS=$tlf_saved_CFLAGS
125125

126126

127+
LIBCURL_CHECK_CONFIG([], [7], [wantlibcurl=true], [wantlibcurl=false])
128+
127129
dnl Check if we want to use xmlrpc to read carrier from Fldigi
128130
AC_MSG_CHECKING([whether to build Fldigi XML RPC support])
129131
AC_ARG_ENABLE([fldigi-xmlrpc],
@@ -245,6 +247,7 @@ echo \
245247

246248
Package features:
247249

250+
With CURL $wantlibcurl
248251
With XML RPC $wantfldigixmlrpc
249252
With Python plugin $wantpythonplugin
250253

macros/libcurl.m4

Lines changed: 273 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,273 @@
1+
#***************************************************************************
2+
# _ _ ____ _
3+
# Project ___| | | | _ \| |
4+
# / __| | | | |_) | |
5+
# | (__| |_| | _ <| |___
6+
# \___|\___/|_| \_\_____|
7+
#
8+
# Copyright (C) David Shaw <dshaw@jabberwocky.com>
9+
#
10+
# This software is licensed as described in the file COPYING, which
11+
# you should have received as part of this distribution. The terms
12+
# are also available at https://curl.se/docs/copyright.html.
13+
#
14+
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
15+
# copies of the Software, and permit persons to whom the Software is
16+
# furnished to do so, under the terms of the COPYING file.
17+
#
18+
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19+
# KIND, either express or implied.
20+
#
21+
# SPDX-License-Identifier: curl
22+
#
23+
###########################################################################
24+
# LIBCURL_CHECK_CONFIG([DEFAULT-ACTION], [MINIMUM-VERSION],
25+
# [ACTION-IF-YES], [ACTION-IF-NO])
26+
# ----------------------------------------------------------
27+
# David Shaw <dshaw@jabberwocky.com> May-09-2006
28+
#
29+
# Checks for libcurl. DEFAULT-ACTION is the string yes or no to
30+
# specify whether to default to --with-libcurl or --without-libcurl.
31+
# If not supplied, DEFAULT-ACTION is yes. MINIMUM-VERSION is the
32+
# minimum version of libcurl to accept. Pass the version as a regular
33+
# version number like 7.10.1. If not supplied, any version is
34+
# accepted. ACTION-IF-YES is a list of shell commands to run if
35+
# libcurl was successfully found and passed the various tests.
36+
# ACTION-IF-NO is a list of shell commands that are run otherwise.
37+
# Note that using --without-libcurl does run ACTION-IF-NO.
38+
#
39+
# This macro #defines HAVE_LIBCURL if a working libcurl setup is
40+
# found, and sets @LIBCURL@ and @LIBCURL_CPPFLAGS@ to the necessary
41+
# values. Other useful defines are LIBCURL_FEATURE_xxx where xxx are
42+
# the various features supported by libcurl, and LIBCURL_PROTOCOL_yyy
43+
# where yyy are the various protocols supported by libcurl. Both xxx
44+
# and yyy are capitalized. See the list of AH_TEMPLATE macros at the top
45+
# of the macro for the complete list of possible defines. Shell
46+
# variables $libcurl_feature_xxx and $libcurl_protocol_yyy are also
47+
# defined to 'yes' for those features and protocols that were found.
48+
# Note that xxx and yyy keep the same capitalization as in the
49+
# curl-config list (e.g. it's "HTTP" and not "http").
50+
#
51+
# Users may override the detected values by doing something like:
52+
# LIBCURL="-lcurl" LIBCURL_CPPFLAGS="-I/usr/myinclude" ./configure
53+
#
54+
# For the sake of sanity, this macro assumes that any libcurl that is found is
55+
# after version 7.7.2, the first version that included the curl-config script.
56+
# Note that it is important for people packaging binary versions of libcurl to
57+
# include this script! Without curl-config, we can only guess what protocols
58+
# are available, or use curl_version_info to figure it out at runtime.
59+
60+
AC_DEFUN([LIBCURL_CHECK_CONFIG],
61+
[
62+
AH_TEMPLATE([LIBCURL_FEATURE_SSL],[Defined if libcurl supports SSL])
63+
AH_TEMPLATE([LIBCURL_FEATURE_KRB4],[Defined if libcurl supports KRB4])
64+
AH_TEMPLATE([LIBCURL_FEATURE_IPV6],[Defined if libcurl supports IPv6])
65+
AH_TEMPLATE([LIBCURL_FEATURE_LIBZ],[Defined if libcurl supports libz])
66+
AH_TEMPLATE([LIBCURL_FEATURE_ASYNCHDNS],[Defined if libcurl supports AsynchDNS])
67+
AH_TEMPLATE([LIBCURL_FEATURE_IDN],[Defined if libcurl supports IDN])
68+
AH_TEMPLATE([LIBCURL_FEATURE_SSPI],[Defined if libcurl supports SSPI])
69+
AH_TEMPLATE([LIBCURL_FEATURE_NTLM],[Defined if libcurl supports NTLM])
70+
71+
AH_TEMPLATE([LIBCURL_PROTOCOL_HTTP],[Defined if libcurl supports HTTP])
72+
AH_TEMPLATE([LIBCURL_PROTOCOL_HTTPS],[Defined if libcurl supports HTTPS])
73+
AH_TEMPLATE([LIBCURL_PROTOCOL_FTP],[Defined if libcurl supports FTP])
74+
AH_TEMPLATE([LIBCURL_PROTOCOL_FTPS],[Defined if libcurl supports FTPS])
75+
AH_TEMPLATE([LIBCURL_PROTOCOL_FILE],[Defined if libcurl supports FILE])
76+
AH_TEMPLATE([LIBCURL_PROTOCOL_TELNET],[Defined if libcurl supports TELNET])
77+
AH_TEMPLATE([LIBCURL_PROTOCOL_LDAP],[Defined if libcurl supports LDAP])
78+
AH_TEMPLATE([LIBCURL_PROTOCOL_DICT],[Defined if libcurl supports DICT])
79+
AH_TEMPLATE([LIBCURL_PROTOCOL_TFTP],[Defined if libcurl supports TFTP])
80+
AH_TEMPLATE([LIBCURL_PROTOCOL_RTSP],[Defined if libcurl supports RTSP])
81+
AH_TEMPLATE([LIBCURL_PROTOCOL_POP3],[Defined if libcurl supports POP3])
82+
AH_TEMPLATE([LIBCURL_PROTOCOL_IMAP],[Defined if libcurl supports IMAP])
83+
AH_TEMPLATE([LIBCURL_PROTOCOL_SMTP],[Defined if libcurl supports SMTP])
84+
85+
AC_ARG_WITH(libcurl,
86+
AS_HELP_STRING([--with-libcurl=PREFIX],[look for the curl library in PREFIX/lib and headers in PREFIX/include]),
87+
[_libcurl_with=$withval],[_libcurl_with=ifelse([$1],,[yes],[$1])])
88+
89+
if test "$_libcurl_with" != "no"; then
90+
91+
AC_PROG_AWK
92+
93+
_libcurl_version_parse="eval $AWK '{split(\$NF,A,\".\"); X=256*256*A[[1]]+256*A[[2]]+A[[3]]; print X;}'"
94+
95+
_libcurl_try_link=yes
96+
97+
if test -d "$_libcurl_with"; then
98+
LIBCURL_CPPFLAGS="-I$withval/include"
99+
_libcurl_ldflags="-L$withval/lib"
100+
AC_PATH_PROG([_libcurl_config],[curl-config],[],["$withval/bin"])
101+
else
102+
AC_PATH_PROG([_libcurl_config],[curl-config],[],[$PATH])
103+
fi
104+
105+
if test x$_libcurl_config != "x"; then
106+
AC_CACHE_CHECK([for the version of libcurl],
107+
[libcurl_cv_lib_curl_version],
108+
[libcurl_cv_lib_curl_version=`$_libcurl_config --version | $AWK '{print $[]2}'`])
109+
110+
_libcurl_version=`echo $libcurl_cv_lib_curl_version | $_libcurl_version_parse`
111+
_libcurl_wanted=`echo ifelse([$2],,[0],[$2]) | $_libcurl_version_parse`
112+
113+
if test $_libcurl_wanted -gt 0; then
114+
AC_CACHE_CHECK([for libcurl >= version $2],
115+
[libcurl_cv_lib_version_ok],
116+
[
117+
if test $_libcurl_version -ge $_libcurl_wanted; then
118+
libcurl_cv_lib_version_ok=yes
119+
else
120+
libcurl_cv_lib_version_ok=no
121+
fi
122+
])
123+
fi
124+
125+
if test $_libcurl_wanted -eq 0 || test x$libcurl_cv_lib_version_ok = xyes; then
126+
if test x"$LIBCURL_CPPFLAGS" = "x"; then
127+
LIBCURL_CPPFLAGS=`$_libcurl_config --cflags`
128+
fi
129+
if test x"$LIBCURL" = "x"; then
130+
LIBCURL=`$_libcurl_config --libs`
131+
132+
# This is so silly, but Apple actually has a bug in their
133+
# curl-config script. Fixed in Tiger, but there are still
134+
# lots of Panther installs around.
135+
case "${host}" in
136+
powerpc-apple-darwin7*)
137+
LIBCURL=`echo $LIBCURL | sed -e 's|-arch i386||g'`
138+
;;
139+
esac
140+
fi
141+
142+
# All curl-config scripts support --feature
143+
_libcurl_features=`$_libcurl_config --feature`
144+
145+
# Is it modern enough to have --protocols? (7.12.4)
146+
if test $_libcurl_version -ge 461828; then
147+
_libcurl_protocols=`$_libcurl_config --protocols`
148+
fi
149+
else
150+
_libcurl_try_link=no
151+
fi
152+
153+
unset _libcurl_wanted
154+
fi
155+
156+
if test $_libcurl_try_link = yes; then
157+
158+
# we did not find curl-config, so let's see if the user-supplied
159+
# link line (or failing that, "-lcurl") is enough.
160+
LIBCURL=${LIBCURL-"$_libcurl_ldflags -lcurl"}
161+
162+
AC_CACHE_CHECK([whether libcurl is usable],
163+
[libcurl_cv_lib_curl_usable],
164+
[
165+
_libcurl_save_cppflags=$CPPFLAGS
166+
CPPFLAGS="$LIBCURL_CPPFLAGS $CPPFLAGS"
167+
_libcurl_save_libs=$LIBS
168+
LIBS="$LIBCURL $LIBS"
169+
170+
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <curl/curl.h>]],[[
171+
/* Try to use a few common options to force a failure if we are
172+
missing symbols or cannot link. */
173+
int x;
174+
curl_easy_setopt(NULL,CURLOPT_URL,NULL);
175+
x=CURL_ERROR_SIZE;
176+
x=CURLOPT_WRITEFUNCTION;
177+
x=CURLOPT_WRITEDATA;
178+
x=CURLOPT_ERRORBUFFER;
179+
x=CURLOPT_STDERR;
180+
x=CURLOPT_VERBOSE;
181+
if(x) {;}
182+
]])],libcurl_cv_lib_curl_usable=yes,libcurl_cv_lib_curl_usable=no)
183+
184+
CPPFLAGS=$_libcurl_save_cppflags
185+
LIBS=$_libcurl_save_libs
186+
unset _libcurl_save_cppflags
187+
unset _libcurl_save_libs
188+
])
189+
190+
if test $libcurl_cv_lib_curl_usable = yes; then
191+
192+
# Does curl_free() exist in this version of libcurl?
193+
# If not, fake it with free()
194+
195+
_libcurl_save_cppflags=$CPPFLAGS
196+
CPPFLAGS="$CPPFLAGS $LIBCURL_CPPFLAGS"
197+
_libcurl_save_libs=$LIBS
198+
LIBS="$LIBS $LIBCURL"
199+
200+
AC_CHECK_DECL([curl_free],[],
201+
[AC_DEFINE([curl_free],[free],
202+
[Define curl_free() as free() if our version of curl lacks curl_free.])],
203+
[[#include <curl/curl.h>]])
204+
205+
CPPFLAGS=$_libcurl_save_cppflags
206+
LIBS=$_libcurl_save_libs
207+
unset _libcurl_save_cppflags
208+
unset _libcurl_save_libs
209+
210+
AC_DEFINE(HAVE_LIBCURL,1,
211+
[Define to 1 if you have a functional curl library.])
212+
AC_SUBST(LIBCURL_CPPFLAGS)
213+
AC_SUBST(LIBCURL)
214+
215+
for _libcurl_feature in $_libcurl_features; do
216+
AC_DEFINE_UNQUOTED(AS_TR_CPP(libcurl_feature_$_libcurl_feature),[1])
217+
eval AS_TR_SH(libcurl_feature_$_libcurl_feature)=yes
218+
done
219+
220+
if test "x$_libcurl_protocols" = "x"; then
221+
222+
# We do not have --protocols, so just assume that all
223+
# protocols are available
224+
_libcurl_protocols="HTTP FTP FILE TELNET LDAP DICT TFTP"
225+
226+
if test x$libcurl_feature_SSL = xyes; then
227+
_libcurl_protocols="$_libcurl_protocols HTTPS"
228+
229+
# FTPS was not standards-compliant until version
230+
# 7.11.0 (0x070b00 == 461568)
231+
if test $_libcurl_version -ge 461568; then
232+
_libcurl_protocols="$_libcurl_protocols FTPS"
233+
fi
234+
fi
235+
236+
# RTSP, IMAP, POP3 and SMTP were added in
237+
# 7.20.0 (0x071400 == 463872)
238+
if test $_libcurl_version -ge 463872; then
239+
_libcurl_protocols="$_libcurl_protocols RTSP IMAP POP3 SMTP"
240+
fi
241+
fi
242+
243+
for _libcurl_protocol in $_libcurl_protocols; do
244+
AC_DEFINE_UNQUOTED(AS_TR_CPP(libcurl_protocol_$_libcurl_protocol),[1])
245+
eval AS_TR_SH(libcurl_protocol_$_libcurl_protocol)=yes
246+
done
247+
else
248+
unset LIBCURL
249+
unset LIBCURL_CPPFLAGS
250+
fi
251+
fi
252+
253+
unset _libcurl_try_link
254+
unset _libcurl_version_parse
255+
unset _libcurl_config
256+
unset _libcurl_feature
257+
unset _libcurl_features
258+
unset _libcurl_protocol
259+
unset _libcurl_protocols
260+
unset _libcurl_version
261+
unset _libcurl_ldflags
262+
fi
263+
264+
if test x$_libcurl_with = xno || test x$libcurl_cv_lib_curl_usable != xyes; then
265+
# This is the IF-NO path
266+
ifelse([$4],,:,[$4])
267+
else
268+
# This is the IF-YES path
269+
ifelse([$3],,:,[$3])
270+
fi
271+
272+
unset _libcurl_with
273+
])

share/logcfg.dat

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,17 @@ CABRILLO-SOAPBOX(3)= -
252252
#
253253
#################################
254254
# #
255+
# Online Score Submission #
256+
# #
257+
#################################
258+
#
259+
ONLINESCORE
260+
#ONLINESCORE_URL=https://contestonlinescore.com/post/
261+
#ONLINESCORE_USER=
262+
#ONLINESCORE_PASS=
263+
#
264+
#################################
265+
# #
255266
# CONDX (info for muf calc.) #
256267
# #
257268
#################################

src/Makefile.am

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ tlf_SOURCES = \
2323
logit.c logview.c \
2424
main.c makelogline.c messagechange.c muf.c \
2525
nicebox.c note.c netkeyer.c\
26+
onlinescore.c \
2627
paccdx.c parse_logcfg.c plugin.c printcall.c \
2728
qrb.c qsonr_to_str.c qtc_log.c qtcwin.c qtcutil.c readcabrillo.c \
2829
readcalls.c readqtccalls.c readctydata.c recall_exchange.c rules.c \
@@ -38,7 +39,7 @@ tlf_SOURCES = \
3839

3940
tlf_LDADD = @LIBM_LIB@ @PTHREAD_LIBS@ @GLIB_LIBS@ @PANEL_LIBS@ @CURSES_LIBS@ \
4041
@HAMLIB_LIBS@ @LIBXMLRPC_LIB@ @LIBXMLRPC_CLIENT_LIB@ \
41-
@LIBXMLRPC_UTIL_LIB@ @PYTHON_LIBS@
42+
@LIBXMLRPC_UTIL_LIB@ @PYTHON_LIBS@ -lcurl
4243

4344
noinst_HEADERS = \
4445
addcall.h addmult.h addpfx.h addspot.h audio.h autocq.h \
@@ -60,6 +61,7 @@ noinst_HEADERS = \
6061
log_to_disk.h logit.h logview.h \
6162
makelogline.h math_utils.h messagechange.h muf.h \
6263
nicebox.h note.h netkeyer.h\
64+
onlinescore.h \
6365
paccdx.h parse_logcfg.h printcall.h \
6466
paccdx.h parse_logcfg.h plugin.h printcall.h \
6567
qrb.h qsonr_to_str.h qtc_log.h qtcvars.h qtcwin.h qtcutil.h \

src/background_process.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "gettxinfo.h"
3333
#include "lancode.h"
3434
#include "log_to_disk.h"
35+
#include "onlinescore.h"
3536
#include "qsonr_to_str.h"
3637
#include "qtc_log.h"
3738
#include "qtcutil.h"

0 commit comments

Comments
 (0)