1 /*
2  * Tlf - contest logging program for amateur radio operators
3  * Copyright (C) 2001-2002-2003 Rein Couperus <pa0r@eudxf.org>
4  *                    2010-2014 Thomas Beierlein <tb@forth-ev.de>
5  *                    2013-2016 Ervin Hegedus - HA2OS <airween@gmail.com>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  */
21 
22 #include <stdbool.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include "../src/globalvars.h"
26 #include "../src/tlf.h"
27 
28 #include "test.h"
29 
30 
31 int lan_active = 0;
32 char lastqsonr[5];
33 
34 int prsock = 0;
35 char pr_hostaddress[48] = "111.222.111.222";
36 char *config_file = NULL;
37 int portnum = 0;
38 
39 int use_rxvt = 0;
40 int use_xterm = 0;
41 
42 int debugflag = 0;
43 char *editor_name = NULL;
44 char rttyoutput[120];
45 int tune_val = 0;
46 int use_bandoutput = 0;
47 int no_arrows = 0;
48 int bandindexarray[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
49 int cqwwm2 = 0;
50 
51 /* predefined contests */
52 int cqww = 0;
53 int wpx = 0;
54 int dxped = 0;
55 int sprint = 0;
56 int arrldx_usa = 0;
57 int arrl_fd = 0;
58 int arrlss = 0;
59 int pacc_pa_flg = 0;
60 int stewperry_flg = 0;
61 int focm = 0;
62 
63 int universal = 0;
64 int addcallarea;
65 int pfxmult = 0;
66 int pfxmultab = 0;
67 int exc_cont = 0;
68 int manise80;
69 int one_point = 0;
70 int two_point = 0;
71 int three_point = 0;
72 int ssbpoints;
73 int cwpoints;
74 int lowband_point_mult = 0;
75 int sc_sidetone;
76 char sc_volume[4] = "";
77 /* LZ3NY mods */
78 int my_country_points = -1;
79 int my_cont_points = -1;
80 int dx_cont_points = -1;
81 char countrylist[255][6];
82 bool countrylist_only = false;
83 int countrylist_points = -1;
84 char continent_multiplier_list[7][3]; // SA, NA, EU, AF, AS and OC
85 int continentlist_points = -1;
86 bool continentlist_only = false;
87 int exclude_multilist_type = EXCLUDE_NONE;
88 bool mult_side = false;
89 /* end LZ3NY mods */
90 
91 int portable_x2 = 0;
92 int recall_mult = 0;
93 int exchange_serial = 0;
94 int wysiwyg_once = 0;
95 int wysiwyg_multi = 0;
96 int country_mult = 0;
97 float fixedmult = 0.0;
98 int sectn_mult = 0;
99 int dx_arrlsections = 0;
100 int serial_section_mult = 0;
101 int serial_or_section = 0;	/* exchange is serial OR section, like HA-DX */
102 int serial_grid4_mult = 0;
103 int qso_once = 0;
104 int addcallarea_once = 0;
105 int noleadingzeros;
106 int ctcomp = 0;
107 int isdupe = 0;			// 0 if nodupe -- for auto qso b4 (LZ3NY)
108 int nob4 = 0;			// allow auto b4
109 int ignoredupe = 0;
110 int noautocq = 0;
111 int emptydir = 0;
112 int verbose = 0;
113 int no_rst = 0;			/* 1 - do not use RS/RST */
114 char myqra[7] = "";
115 
116 int pacc_qsos[10][10];
117 int ve_cty;
118 int w_cty;
119 int zl_cty;
120 int ja_cty;
121 int py_cty;
122 int ce_cty;
123 int lu_cty;
124 int vk_cty;
125 int zs_cty;
126 int ua9_cty;
127 
128 t_pfxnummulti pfxnummulti[MAXPFXNUMMULT];
129 int pfxnummultinr = 0;
130 
131 char multsfile[80] = "";	/* name of file with a list of allowed
132 				   multipliers */
133 char exchange_list[40] = "";
134 int timeoffset = 0;
135 int multi = 0;			/* 0 = SO , 1 = MOST, 2 = MM */
136 int trxmode = CWMODE;
137 /* RIG_MODE_NONE in hamlib/rig.h, but if hamlib not compiled, then no dependecy */
138 rmode_t rigmode = 0;
139 int mixedmode = 0;
140 char his_rst[4] = "599";
141 char my_rst[4] = "599";
142 char last_rst[4] = "599";       /* Report for last QSO */
143 int mults_per_band = 1;		/* mults count per band */
144 int shortqsonr = LONGCW;	/* 1  =  short  cw char in exchange */
145 int cluster = NOCLUSTER;	/* 0 = OFF, 1 = FOLLOW, 2  = spots  3 = all */
146 int clusterlog = 0;		/* clusterlog on/off */
147 int searchflg = 0;		/* 1  = display search  window */
148 int show_time = 0;
149 cqmode_t cqmode = CQ;
150 int demode = 0;			/* 1 =  send DE  before s&p call  */
151 int contest = 0;		/* 0 =  General,  1  = contest */
152 int announcefilter = FILTER_ANN; /*  filter cluster  announcements */
153 int showscore_flag = 0;		/* show  score window */
154 int change_rst = 0;
155 char exchange[40];
156 char whichcontest[40] = "qso";
157 int defer_store = 0;
158 char call[20];
159 char logfile[120] = "general.log";
160 char *cabrillo = NULL;		/*< Name of the cabrillo format definition */
161 char synclogfile[120];
162 char markerfile[120] = "";
163 int xplanet = 0;
164 
165 char sp_return[80] = " \n";
166 char cq_return[80] = " \n";
167 char message[25][80] = /**< Array of CW/DigiMode messages
168  			*
169  			* message[0]..[11] activated by F1..F12 key
170  			* message[12] - TU message S&P mode
171  			* message[13] - TU message CQ mode
172  			* message[14]..[23] activated by Alt-0..9
173 			* message[24] - S&P call message
174  			*
175  			* special use:
176 			*
177  			* message[0]  (F1)  - 'cq message' in CQ mode,
178 			*                     'de <call>' in S&P
179 			* message[2]  (F3)  - send rapport
180 			* message[4]  (F5)  - hiscall (used if '?' entered
181 			* 		      in call field
182 			* message[6]  (F7)  - 'worked before' message
183  			* message[11] (F12) - used for auto-cq
184 			*
185 			* additional use if in CTCOMP mode
186 			* message[1]  (F2)  - insert pressed
187  			*/
188 {
189     "TEST %\n", "@ DE %\n", "@ [\n", "TU 73\n", " @\n", "%\n",
190     "@ SRI QSO B4 GL\n", "AGN\n",
191     " ?\n", " QRZ?\n", " PSE K\n", "TEST % %\n", "@ [\n", "TU %\n",
192     "", "", "", "", "", "", "", "", "", "", ""
193 };
194 
195 char *digi_message[sizeof(message) / sizeof(message[0])];
196 
197 char ph_message[14][80] = /**< Array of file names for voice keyer messages
198 			   * See description of message[]
199 			   */
200 { "", "", "", "", "", "", "", "", "", "", "", "", "", "" };
201 
202 char qtc_recv_msgs[12][80] = {"QTC?\n", "QRV\n", "R\n", "", "TIME?\n", "CALL?\n", "NR?\n", "AGN\n", "", "QSL ALL\n", "", ""}; // QTC receive windowS Fx messages
203 char qtc_send_msgs[12][80] = {"QRV?\n", "QTC sr/nr\n", "", "", "TIME\n", "CALL\n", "NR\n", "", "", "", "", ""}; // QTC send window Fx messages
204 char qtc_phrecv_message[14][80] = { "", "", "", "", "", "", "", "", "", "", "", "" };	// voice keyer file names when receives QTC's
205 char qtc_phsend_message[14][80] = { "", "", "", "", "", "", "", "", "", "", "", "" };	// voice keyer file names when send QTC's
206 int qtcrec_record = 0;
207 char qtcrec_record_command[2][50] = {"rec -q 8000", "-q &"};
208 char qtcrec_record_command_shutdown[50] = "pkill -SIGINT -n rec";
209 char qtc_cap_calls[40] = "";
210 int qtc_auto_filltime = 0;
211 
212 int qtcdirection = 0;
213 
214 int minitest = 0;
215 
216 char hiscall[20];			/**< call of other station */
217 char hiscall_sent[20] = "";		/**< part which was sent during early
218 					  start */
219 int cwstart = 0;			/**< number characters after which
220 					   sending call started automatically,
221 					   0 - off, -1 - manual start */
222 int sending_call = 0;
223 int early_started = 0;			/**< 1 if sending call started early,
224 					   strlen(hiscall)>cwstart or 'space' */
225 char lastcall[20];
226 char qsonrstr[5] = "0001";
227 char band[NBANDS][4] =
228 { "160", " 80", " 40", " 30", " 20", " 17", " 15", " 12", " 10" };
229 char comment[80];
230 char mode[20] = "Log     ";
231 char cqzone[3] = "";
232 char mycqzone[3] = "";
233 char ituzone[3] = "";
234 char continent[3] = "";
235 char mycontinent[3] = "";
236 char pxstr[11] = "";
237 int bandindex = 0;
238 int totalmults = 0;
239 int totalcountries = 0;
240 int totalzones = 0;
241 int secs = 0;
242 int countrynr;
243 int mycountrynr = 215;
244 int total = 0; 		/**< total number of qso points */
245 int band_score[NBANDS];
246 int dupe = 0;
247 int callfound = 0;
248 int partials = 0;	/**< show partial calls */
249 int use_part = 0;	/**< if 1 use automatically found partial call */
250 int block_part = 0; 	/**< if 1 block the call autocompletion
251 			  for these QSO */
252 char para_word[80] =
253     "LODNCFS:3C\n";	/* longcw, cluster, search,  DE, contest, filter,  speed,  delay */
254 char lastmsg[1000] = "";
255 int scale_values[20] = {
256     40, 38, 36, 34, 32, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6,
257     4, 2
258 };
259 char sc_device[40] = "/dev/dsp";
260 
261 /*-------------------------------------keyer------------------------------*/
262 int keyerport = NO_KEYER;
263 int txdelay = 0;
264 int weight = 0;
265 char weightbuf[4];
266 char tonestr[5] = "600";
267 int cqdelay = 8;
268 char wkeyerbuffer[400];
269 int data_ready = 0;
270 char keyer_device[10] = "";	// ttyS0, ttyS1, lp0-2
271 int k_tune;
272 int k_pin14;
273 int k_ptt;
274 char controllerport[80] = "/dev/ttyS0";
275 int miniterm = 0;		/* is miniterm for digimode active? */
276 char modem_mode[8];
277 int commentfield = 0;		/* 1 if we are in comment/excahnge input */
278 
279 /*-------------------------------------packet-------------------------------*/
280 char spot_ptr[MAX_SPOTS][82];		/* Array of cluster spot lines */
281 int nr_of_spots;			/* Anzahl Lines in spot_ptr array */
282 int packetinterface = 0;
283 int fdSertnc = 0;
284 int fdFIFO = 0;
285 int tncport = 1;
286 char tncportname[40];
287 char rigconf[80];
288 int in_packetclient;
289 int tnc_serial_rate = 2400;
290 char clusterlogin[80] = "";
291 int bmautoadd = 0;
292 int bmautograb = 0;
293 
294 /*-------------------------------------rigctl-------------------------------*/
295 #ifdef HAVE_LIBHAMLIB
296 rig_model_t myrig_model = 351;
297 RIG *my_rig;			/* handle to rig (instance) */
298 freq_t outfreq;			/* output  to rig */
299 rmode_t rmode;			/* radio mode of operation */
300 pbwidth_t width;
301 vfo_t vfo;			/* vfo selection */
302 port_t myport;
303 #else
304 int outfreq;			/* output  to rig */
305 #endif
306 int ssb_bandwidth = 3000;
307 int cw_bandwidth = 0;
308 int serial_rate = 2400;
309 char rigportname[40];
310 int rignumber = 0;
311 int rig_comm_error = 0;
312 int rig_comm_success = 0;
313 
314 /*---------------------------------simulator-------------------------------*/
315 int simulator = 0;
316 int simulator_mode = 0;
317 int simulator_seed = 8327;
318 int system_secs;
319 char tonecpy[5];
320 char simulator_tone[5];
321 
322 /*-------------------------------the log lines-----------------------------*/
323 char qsos[MAX_QSOS][LOGLINELEN + 1];
324 int nr_qsos = 0;
325 
326 /*------------------------------dupe array---------------------------------*/
327 int nr_worked = 0;		/*< number of calls in worked[] */
328 struct worked_t worked[MAX_CALLS]; /*< worked stations */
329 
330 /*----------------------statistic of worked countries,zones ... -----------*/
331 int countries[MAX_DATALINES];	/* per country bit fieldwith worked bands set */
332 int zones[MAX_ZONES];		/* same for cq zones or itu zones;
333 				   using 1 - 40 or 1 - 90 */
334 char mults[MAX_MULTS][12];
335 int mult_bands[MAX_MULTS];
336 int multarray_nr = 0;
337 
338 int multlist = 0;
339 
340 int callareas[20];
341 int multscore[NBANDS];
342 
343 struct ie_list *main_ie_list;	/* head of initial exchange list */
344 
345 int zonescore[NBANDS];
346 int countryscore[NBANDS];
347 int zonedisplay = 0;
348 char zone_fix[3] = "";
349 int addzone = 0;		/* flag for new zone */
350 int addcty = 0;			/* flag for new country */
351 int shownewmult = -1;
352 int minute_timer = 0;
353 
354 int bandinx = BANDINDEX_40;	/* start with 40m */
355 int qsonum = 1;			/* nr of next QSO */
356 int ymax, xmax;			/* screen size */
357 
358 char zone_export[3] = "  ";
359 
360 pid_t pid;
361 struct tm *time_ptr;
362 
363 freq_t freq;
364 freq_t mem;
365 int logfrequency = 0;
366 int rit;
367 int trx_control = 0;
368 int showfreq = 0;
369 freq_t bandfrequency[10] = {
370     1830000.0, 3525000.0, 5352000.0, 7010000.0, 10105000.0, 14025000.0, 18070000.0, 21025000.0, 24900000.0,
371     28025000.0
372 };
373 
374 char headerline[81] =
375     "   1=CQ  2=DE  3=RST 4=73  5=HIS  6=MY  7=B4   8=AGN  9=?  \n";
376 const char *backgrnd_str =
377     "                                                                                ";
378 
379 char logline_edit[5][LOGLINELEN + 1];
380 
381 char terminal1[88] = "";
382 char terminal2[88] = "";
383 char terminal3[88] = "";
384 char terminal4[88] = "";
385 char termbuf[88] = "";
386 int termbufcount = 0;
387 
388 double QTH_Lat = 51.;
389 double QTH_Long = -7.;
390 double DEST_Lat = 51.;
391 double DEST_Long = 1.;
392 
393 char hiscountry[40];
394 
395 int this_second;
396 int stop_backgrnd_process = 1;	/* dont start until we know what we are doing */
397 
398 int wazmult = 0;		/* to add the ability of WAZ zones to be multiplier */
399 int itumult = 0;		/* to add the ability of ITU zones to be multiplier */
400 char itustr[3];
401 
402 int nopacket = 0;		/* set if tlf is called with '-n' */
403 int no_trx_control = 0;		/* set if tlf is called with '-r' */
404 
405 int bandweight_points[NBANDS] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
406 int bandweight_multis[NBANDS] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
407 
408 struct mults_t multis[MAX_MULTS]; /**< worked multis */
409 int nr_multis = 0;      /**< number of multis in multis[] */
410 
411 int unique_call_multi = 0;          /* do we count calls as multiplier */
412 
413 //////////////////
414 char ssexchange[30] = "";   // defined in getexchange.c
415 char section[8] = "";       // defined in getexchange.c
416 char lan_logline[256];      // defined in lancode.c
417 
418 //////////////////
419 
send_lan_message(int opcode,char * message)420 int send_lan_message(int opcode, char *message) {
421     return 0;
422 }
423 
424 #include <curses.h>
425 NCURSES_EXPORT_VAR(WINDOW *) stdscr = NULL;
wattr_on(WINDOW * win,attr_t attrs,void * opts)426 int wattr_on(WINDOW *win, attr_t attrs, void *opts) {
427     return 0;
428 }
429 
displayit()430 void displayit() {
431 }
432 
netkeyer(int cw_op,char * cwmessage)433 int netkeyer(int cw_op, char *cwmessage) {
434     return 0;
435 }
436 
437 char mvprintw_history[NLAST][LINESZ];
438 
clear_mvprintw_history()439 void clear_mvprintw_history() {
440     for (int i = 0; i < NLAST; ++i) {
441 	mvprintw_history[i][0] = 0;
442     }
443 }
444 
mvprintw(int y,int x,const char * fmt,...)445 int mvprintw(int y, int x, const char *fmt, ...) {
446 
447     // shift history
448     for (int i = NLAST - 1; i >= 1; --i) {
449 	strcpy(mvprintw_history[i], mvprintw_history[i - 1]);
450     }
451 
452     va_list args;
453     va_start(args, fmt);
454     sprintf(mvprintw_history[0], "%02d|%02d|", y, x);
455     vsnprintf(mvprintw_history[0] + 6, 100 - 6, fmt, args);
456     va_end(args);
457 
458     return 0;
459 }
460 
mvwprintw(WINDOW * win,int y,int x,const char * fmt,...)461 int mvwprintw(WINDOW *win, int y, int x, const char *fmt, ...) {
462     va_list args;
463     va_start(args, fmt);
464     mvprintw(y, x, fmt, args);
465     va_end(args);
466 
467     return 0;
468 }
469