1 // ----------------------------------------------------------------------------
2 // Copyright (C) 2015
3 //              Robert Stiles
4 //
5 // This file is part of fldigi
6 //
7 // fldigi 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 3 of the License, or
10 // (at your option) any later version.
11 //
12 // fldigi 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, see <http://www.gnu.org/licenses/>.
19 // ----------------------------------------------------------------------------
20 
21 #include <cstdlib>
22 #include <cstdarg>
23 #include <string>
24 #include <fstream>
25 #include <algorithm>
26 #include <map>
27 #include <unistd.h>
28 #include <iostream>
29 #include <fstream>
30 #include <sstream>
31 #include <cstring>
32 #include <ctime>
33 #include <vector>
34 #include <sys/types.h>
35 #include <sys/stat.h>
36 #include <stdio.h>
37 #include <errno.h>
38 #include <time.h>
39 #include <pthread.h>
40 #include <libgen.h>
41 #include <ctype.h>
42 #include <sys/time.h>
43 
44 #include "config.h"
45 
46 #include <sys/types.h>
47 
48 #ifdef __WOE32__
49 #  ifdef __CYGWIN__
50 #    include <w32api/windows.h>
51 #  else
52 #    include <windows.h>
53 #  endif
54 #endif
55 
56 #include <cstdlib>
57 #include <cstdarg>
58 #include <string>
59 #include <fstream>
60 #include <algorithm>
61 #include <map>
62 
63 #ifndef __WOE32__
64 #include <sys/wait.h>
65 #endif
66 
67 #include "gettext.h"
68 #include "fl_digi.h"
69 
70 #include <FL/Fl.H>
71 #include <FL/fl_ask.H>
72 #include <FL/Fl_Pixmap.H>
73 #include <FL/Fl_Image.H>
74 //#include <FL/Fl_Tile.H>
75 #include <FL/x.H>
76 #include <FL/Fl_Help_Dialog.H>
77 #include <FL/Fl_Progress.H>
78 #include <FL/Fl_Tooltip.H>
79 #include <FL/Fl_Tabs.H>
80 #include <FL/Fl_Multiline_Input.H>
81 #include <FL/Fl_Menu_Bar.H>
82 #include <FL/Fl_Pack.H>
83 #include <FL/filename.H>
84 #include <FL/fl_ask.H>
85 
86 #include "waterfall.h"
87 #include "raster.h"
88 #include "progress.h"
89 #include "Panel.h"
90 
91 #include "main.h"
92 #include "threads.h"
93 #include "trx.h"
94 #if USE_HAMLIB
95 #include "hamlib.h"
96 #endif
97 #include "timeops.h"
98 #include "rigio.h"
99 #include "nullmodem.h"
100 #include "psk.h"
101 #include "cw.h"
102 #include "mfsk.h"
103 #include "wefax.h"
104 #include "wefax-pic.h"
105 #include "navtex.h"
106 #include "mt63.h"
107 #include "view_rtty.h"
108 #include "olivia.h"
109 #include "contestia.h"
110 #include "thor.h"
111 #include "dominoex.h"
112 #include "feld.h"
113 #include "throb.h"
114 //#include "pkt.h"
115 #include "wwv.h"
116 #include "analysis.h"
117 #include "ssb.h"
118 
119 #include "smeter.h"
120 #include "pwrmeter.h"
121 
122 #include "ascii.h"
123 #include "globals.h"
124 #include "misc.h"
125 #include "FTextRXTX.h"
126 
127 #include "confdialog.h"
128 #include "configuration.h"
129 #include "status.h"
130 
131 #include "macros.h"
132 #include "macroedit.h"
133 #include "logger.h"
134 #include "lookupcall.h"
135 
136 #include "font_browser.h"
137 
138 #include "icons.h"
139 #include "pixmaps.h"
140 
141 #include "rigsupport.h"
142 
143 #include "qrunner.h"
144 
145 #include "Viewer.h"
146 #include "soundconf.h"
147 
148 #include "htmlstrings.h"
149 #	include "xmlrpc.h"
150 #if BENCHMARK_MODE
151 #	include "benchmark.h"
152 #endif
153 
154 #include "debug.h"
155 #include "re.h"
156 #include "network.h"
157 #include "spot.h"
158 #include "dxcc.h"
159 #include "locator.h"
160 #include "notify.h"
161 
162 #include "logbook.h"
163 
164 #include "rx_extract.h"
165 #include "speak.h"
166 #include "flmisc.h"
167 
168 #include "arq_io.h"
169 #include "data_io.h"
170 #include "kmlserver.h"
171 
172 #include "notifydialog.h"
173 #include "macroedit.h"
174 #include "rx_extract.h"
175 #include "wefax-pic.h"
176 #include "charsetdistiller.h"
177 #include "charsetlist.h"
178 #include "outputencoder.h"
179 #include "record_loader.h"
180 #include "record_browse.h"
181 #include "fileselect.h"
182 
183 #include "script_parsing.h"
184 #include "run_script.h"
185 
186 pthread_mutex_t mutex_script_io = PTHREAD_MUTEX_INITIALIZER;
187 
188 extern std::string ScriptsDir;
189 
190 void script_execute(void *);
191 static void script_execute(const char *filename, bool queue_flag);
192 
193 /** ********************************************************
194  * \brief Template for assigning bool values to various widget types.
195  * \param sp Access to ScritpParsing members.
196  * \param sc Access to SCRIPT_COMMANDS structure variables.
197  * \return 0 (no error) Other (error)
198  ***********************************************************/
199 template <typename widget_type>
assign_bool(widget_type * widget,ScriptParsing * sp,SCRIPT_COMMANDS * sc,bool & data)200 static int assign_bool(widget_type * widget, ScriptParsing *sp, SCRIPT_COMMANDS *sc, bool &data)
201 {
202 	if(!sp || !sc)
203 		return script_function_parameter_error;
204 
205 	bool value = 0;
206 
207 	int error = sp->check_bool(sc->args[0], value);
208 
209 	if(error != script_no_errors)
210 		return error;
211 
212 	if(!widget)
213 		return script_no_errors;
214 
215 	widget->value(value);
216 	widget->do_callback();
217 
218 	data = value;
219 
220 	return script_no_errors;
221 }
222 
223 /** ********************************************************
224  * \brief Template for assigning bool values to various widget types.
225  * \param sp Access to ScritpParsing members.
226  * \param sc Access to SCRIPT_COMMANDS structure variables.
227  * \return 0 (no error) Other (error)
228  ***********************************************************/
229 template <typename widget_type>
assign_bool(widget_type * widget,ScriptParsing * sp,SCRIPT_COMMANDS * sc)230 static int assign_bool(widget_type * widget, ScriptParsing *sp, SCRIPT_COMMANDS *sc)
231 {
232 	bool data = false;
233 	return assign_bool(widget, sp, sc, data);
234 }
235 
236 /** ********************************************************
237  * \brief Template for assigning integer values to various widget types.
238  * \param sp Access to ScritpParsing members.
239  * \param sc Access to SCRIPT_COMMANDS structure variables.
240  * \return 0 (no error) Other (error)
241  ***********************************************************/
242 template <typename widget_type>
assign_integer(widget_type * widget,ScriptParsing * sp,SCRIPT_COMMANDS * sc,int & data)243 static int assign_integer(widget_type * widget, ScriptParsing *sp, SCRIPT_COMMANDS *sc, int &data)
244 {
245 	if(!sp || !sc)
246 		return script_function_parameter_error;
247 
248 	std::string str_data = "";
249 
250 	if(sc->argc > 0)
251 		str_data.assign(sc->args[0]);
252 
253 	if(str_data.empty())
254 		return script_invalid_parameter;
255 
256 	int value = 0;
257 	int cnt = sscanf(str_data.c_str(), "%d", &value);
258 
259 	if(cnt < 1)
260 		return script_invalid_parameter;
261 
262 	if(!widget)
263 		return script_no_errors;
264 
265 	int min = (int) widget->minimum();
266 	int max = (int) widget->maximum();
267 
268 	if((value < min) || (value > max))
269 		return script_invalid_parameter;
270 
271 	widget->value(value);
272 	widget->do_callback();
273 
274 	data = value;
275 
276 	return script_no_errors;
277 }
278 
279 /** ********************************************************
280  * \brief Template for assigning integer values to various widget types.
281  * \param sp Access to ScritpParsing members.
282  * \param sc Access to SCRIPT_COMMANDS structure variables.
283  * \return 0 (no error) Other (error)
284  ***********************************************************/
285 template <typename widget_type>
assign_integer(widget_type * widget,ScriptParsing * sp,SCRIPT_COMMANDS * sc)286 static int assign_integer(widget_type * widget, ScriptParsing *sp, SCRIPT_COMMANDS *sc)
287 {
288 	int data = 0.0;
289 	return assign_integer(widget, sp, sc, data);
290 }
291 
292 /** ********************************************************
293  * \brief Template for assigning double values to various widget types.
294  * \param sp Access to ScritpParsing members.
295  * \param sc Access to SCRIPT_COMMANDS structure variables.
296  * \return 0 (no error) Other (error)
297  ***********************************************************/
298 template <typename widget_type>
assign_double(widget_type * widget,ScriptParsing * sp,SCRIPT_COMMANDS * sc,double & data)299 static int assign_double(widget_type * widget, ScriptParsing *sp, SCRIPT_COMMANDS *sc, double &data)
300 {
301 	if(!sp || !sc)
302 		return script_function_parameter_error;
303 
304 	std::string str_data = "";
305 
306 	if(sc->argc > 0)
307 		str_data.assign(sc->args[0]);
308 
309 	if(str_data.empty())
310 		return script_invalid_parameter;
311 
312 	double value = 0;
313 	int cnt = sscanf(str_data.c_str(), "%lf", &value);
314 
315 	if(cnt < 1)
316 		return script_invalid_parameter;
317 
318 	if(!widget)
319 		return script_no_errors;
320 
321 	double min = (double) widget->minimum();
322 	double max = (double) widget->maximum();
323 
324 	if((value < min) || (value > max))
325 		return script_invalid_parameter;
326 
327 	widget->value(value);
328 	widget->do_callback();
329 
330 	data = value;
331 
332 	return script_no_errors;
333 }
334 
335 /** ********************************************************
336  * \brief Template for assigning double values to various widget types.
337  * \param sp Access to ScritpParsing members.
338  * \param sc Access to SCRIPT_COMMANDS structure variables.
339  * \return 0 (no error) Other (error)
340  ***********************************************************/
341 template <typename widget_type>
assign_double(widget_type * widget,ScriptParsing * sp,SCRIPT_COMMANDS * sc)342 static int assign_double(widget_type * widget, ScriptParsing *sp, SCRIPT_COMMANDS *sc)
343 {
344 	double data = 0.0;
345 	return assign_double(widget, sp, sc, data);
346 }
347 
348 /** ********************************************************
349  * \brief Template for assigning string values to various widget types.
350  * \param sp Access to ScritpParsing members.
351  * \param sc Access to SCRIPT_COMMANDS structure variables.
352  * \return 0 (no error) Other (error)
353  ***********************************************************/
354 template <typename widget_type>
assign_string(widget_type * widget,ScriptParsing * sp,SCRIPT_COMMANDS * sc,std::string & data)355 static int assign_string(widget_type * widget, ScriptParsing *sp, SCRIPT_COMMANDS *sc, std::string &data)
356 {
357 	if(!sp || !sc)
358 		return script_function_parameter_error;
359 
360 	std::string str_data = "";
361 
362 	if(sc->argc > 0)
363 		str_data.assign(sc->args[0]);
364 
365 	if(str_data.empty())
366 		return script_invalid_parameter;
367 
368 	if(!widget)
369 		return script_no_errors;
370 
371 	widget->value(str_data.c_str());
372 	widget->do_callback();
373 
374 	data.assign(str_data);
375 
376 	return script_no_errors;
377 }
378 
379 /** ********************************************************
380  * \brief Template for assigning string values to various widget types.
381  * \param sp Access to ScritpParsing members.
382  * \param sc Access to SCRIPT_COMMANDS structure variables.
383  * \return 0 (no error) Other (error)
384  ***********************************************************/
385 template <typename widget_type>
assign_string(widget_type * widget,ScriptParsing * sp,SCRIPT_COMMANDS * sc)386 static int assign_string(widget_type * widget, ScriptParsing *sp, SCRIPT_COMMANDS *sc)
387 {
388 	std::string data = "";
389 	return assign_string(widget, sp, sc, data);
390 }
391 
392 /** ********************************************************
393  * \brief Template for assigning index values to various widget types.
394  * \param sp Access to ScritpParsing members.
395  * \param sc Access to SCRIPT_COMMANDS structure variables.
396  * \return 0 (no error) Other (error)
397  ***********************************************************/
398 template <typename widget_type>
assign_index(widget_type * widget,ScriptParsing * sp,SCRIPT_COMMANDS * sc,int & data)399 static int assign_index(widget_type * widget, ScriptParsing *sp, SCRIPT_COMMANDS *sc, int &data)
400 {
401 	if(!sp || !sc)
402 		return script_function_parameter_error;
403 
404 	std::string str_data = "";
405 
406 	if(sc->argc > 0)
407 		str_data.assign(sc->args[0]);
408 
409 	if(str_data.empty())
410 		return script_invalid_parameter;
411 
412 	if(!widget)
413 		return script_no_errors;
414 
415 	int index = widget->find_index(str_data.c_str());
416 	if(index < 0)
417 		return script_invalid_parameter;
418 
419 	widget->index(index);
420 	widget->do_callback();
421 
422 	data = index;
423 
424 	return script_no_errors;
425 }
426 
427 /** ********************************************************
428  * \brief Template for assigning index values to various widget types.
429  * \param sp Access to ScritpParsing members.
430  * \param sc Access to SCRIPT_COMMANDS structure variables.
431  * \return 0 (no error) Other (error)
432  ***********************************************************/
433 template <typename widget_type>
assign_index(widget_type * widget,ScriptParsing * sp,SCRIPT_COMMANDS * sc)434 static int assign_index(widget_type * widget, ScriptParsing *sp, SCRIPT_COMMANDS *sc)
435 {
436 	int data = 0;
437 	return assign_index(widget, sp, sc, data);
438 }
439 
440 
441 /** ********************************************************
442  * \brief
443  * \param sp Access to ScritpParsing members.
444  * \param sc Access to SCRIPT_COMMANDS structure variables.
445  * \return 0 (no error) Other (error)
446  ***********************************************************/
process_rsid_notify(ScriptParsing * sp,SCRIPT_COMMANDS * sc)447 int process_rsid_notify(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
448 {
449 	return assign_bool(chkRSidNotifyOnly, sp, sc);
450 }
451 
452 /** ********************************************************
453  * \brief
454  * \param sp Access to ScritpParsing members.
455  * \param sc Access to SCRIPT_COMMANDS structure variables.
456  * \return 0 (no error) Other (error)
457  ***********************************************************/
process_rsid_search_bp(ScriptParsing * sp,SCRIPT_COMMANDS * sc)458 int process_rsid_search_bp(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
459 {
460 	return assign_bool(chkRSidWideSearch, sp, sc);
461 }
462 
463 /** ********************************************************
464  * \brief
465  * \param sp Access to ScritpParsing members.
466  * \param sc Access to SCRIPT_COMMANDS structure variables.
467  * \return 0 (no error) Other (error)
468  ***********************************************************/
process_rsid_mark_prev(ScriptParsing * sp,SCRIPT_COMMANDS * sc)469 int process_rsid_mark_prev(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
470 {
471 	return assign_bool(chkRSidMark, sp, sc);
472 }
473 
474 /** ********************************************************
475  * \brief
476  * \param sp Access to ScritpParsing members.
477  * \param sc Access to SCRIPT_COMMANDS structure variables.
478  * \return 0 (no error) Other (error)
479  ***********************************************************/
process_rsid_detector(ScriptParsing * sp,SCRIPT_COMMANDS * sc)480 int process_rsid_detector(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
481 {
482 	return assign_bool(chkRSidAutoDisable, sp, sc);
483 }
484 
485 /** ********************************************************
486  * \brief
487  * \param sp Access to ScritpParsing members.
488  * \param sc Access to SCRIPT_COMMANDS structure variables.
489  * \return 0 (no error) Other (error)
490  ***********************************************************/
process_rsid_alert_dialog(ScriptParsing * sp,SCRIPT_COMMANDS * sc)491 int process_rsid_alert_dialog(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
492 {
493 	return assign_bool(chkRSidShowAlert, sp, sc);
494 }
495 
496 /** ********************************************************
497  * \brief
498  * \param sp Access to ScritpParsing members.
499  * \param sc Access to SCRIPT_COMMANDS structure variables.
500  * \return 0 (no error) Other (error)
501  ***********************************************************/
process_rsid_tx_freq_lock(ScriptParsing * sp,SCRIPT_COMMANDS * sc)502 int process_rsid_tx_freq_lock(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
503 {
504 	return assign_bool(chkRetainFreqLock, sp, sc);
505 }
506 
507 /** ********************************************************
508  * \brief
509  * \param sp Access to ScritpParsing members.
510  * \param sc Access to SCRIPT_COMMANDS structure variables.
511  * \return 0 (no error) Other (error)
512  ***********************************************************/
process_rsid_freq_change(ScriptParsing * sp,SCRIPT_COMMANDS * sc)513 int process_rsid_freq_change(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
514 {
515 	return assign_bool(chkDisableFreqChange, sp, sc);
516 }
517 
518 /** ********************************************************
519  * \brief
520  * \param sp Access to ScritpParsing members.
521  * \param sc Access to SCRIPT_COMMANDS structure variables.
522  * \return 0 (no error) Other (error)
523  ***********************************************************/
process_rsid_allow_errors(ScriptParsing * sp,SCRIPT_COMMANDS * sc)524 int process_rsid_allow_errors(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
525 {
526 	return assign_index(listbox_rsid_errors, sp, sc);
527 }
528 
529 /** ********************************************************
530  * \brief
531  * \param sp Access to ScritpParsing members.
532  * \param sc Access to SCRIPT_COMMANDS structure variables.
533  * \return 0 (no error) Other (error)
534  ***********************************************************/
process_rsid_sql_open(ScriptParsing * sp,SCRIPT_COMMANDS * sc)535 int process_rsid_sql_open(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
536 {
537 	return assign_integer(val_RSIDsquelch, sp, sc);
538 }
539 
540 /** ********************************************************
541  * \brief
542  * \param sp Access to ScritpParsing members.
543  * \param sc Access to SCRIPT_COMMANDS structure variables.
544  * \return 0 (no error) Other (error)
545  ***********************************************************/
process_rsid_pretone(ScriptParsing * sp,SCRIPT_COMMANDS * sc)546 int process_rsid_pretone(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
547 {
548 	return assign_double(val_pretone, sp, sc);
549 }
550 
551 /** ********************************************************
552  * \brief
553  * \param sp Access to ScritpParsing members.
554  * \param sc Access to SCRIPT_COMMANDS structure variables.
555  * \return 0 (no error) Other (error)
556  ***********************************************************/
process_rsid_char_per_row(ScriptParsing * sp,SCRIPT_COMMANDS * sc)557 int process_rsid_char_per_row(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
558 {
559 	return assign_integer(sldrVideowidth, sp, sc);
560 }
561 
562 /** ********************************************************
563  * \brief
564  * \param sp Access to ScritpParsing members.
565  * \param sc Access to SCRIPT_COMMANDS structure variables.
566  * \return 0 (no error) Other (error)
567  ***********************************************************/
process_rsid_end_xmt_id(ScriptParsing * sp,SCRIPT_COMMANDS * sc)568 int process_rsid_end_xmt_id(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
569 {
570 	return assign_bool(btn_post_rsid, sp, sc);
571 }
572 
573 /** ********************************************************
574  * \brief
575  * \param sp Access to ScritpParsing members.
576  * \param sc Access to SCRIPT_COMMANDS structure variables.
577  * \return 0 (no error) Other (error)
578  ***********************************************************/
process_video_tx_id_mode(ScriptParsing * sp,SCRIPT_COMMANDS * sc)579 int process_video_tx_id_mode(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
580 {
581 	return assign_bool(btnsendid, sp, sc);
582 }
583 
584 /** ********************************************************
585  * \brief
586  * \param sp Access to ScritpParsing members.
587  * \param sc Access to SCRIPT_COMMANDS structure variables.
588  * \return 0 (no error) Other (error)
589  ***********************************************************/
process_video_tx_vid_txt(ScriptParsing * sp,SCRIPT_COMMANDS * sc)590 int process_video_tx_vid_txt(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
591 {
592 	return assign_bool(btnsendvideotext, sp, sc);
593 }
594 
595 /** ********************************************************
596  * \brief
597  * \param sp Access to ScritpParsing members.
598  * \param sc Access to SCRIPT_COMMANDS structure variables.
599  * \return 0 (no error) Other (error)
600  ***********************************************************/
process_video_txt_input(ScriptParsing * sp,SCRIPT_COMMANDS * sc)601 int process_video_txt_input(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
602 {
603 	return assign_string(valVideotext, sp, sc);
604 }
605 
606 /** ********************************************************
607  * \brief
608  * \param sp Access to ScritpParsing members.
609  * \param sc Access to SCRIPT_COMMANDS structure variables.
610  * \return 0 (no error) Other (error)
611  ***********************************************************/
process_video_small_font(ScriptParsing * sp,SCRIPT_COMMANDS * sc)612 int process_video_small_font(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
613 {
614 	return assign_bool(chkID_SMALL, sp, sc);
615 }
616 
617 /** ********************************************************
618  * \brief
619  * \param sp Access to ScritpParsing members.
620  * \param sc Access to SCRIPT_COMMANDS structure variables.
621  * \return 0 (no error) Other (error)
622  ***********************************************************/
process_video_500hz(ScriptParsing * sp,SCRIPT_COMMANDS * sc)623 int process_video_500hz(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
624 {
625 	return assign_bool(btn_vidlimit, sp, sc);
626 }
627 
628 /** ********************************************************
629  * \brief
630  * \param sp Access to ScritpParsing members.
631  * \param sc Access to SCRIPT_COMMANDS structure variables.
632  * \return 0 (no error) Other (error)
633  ***********************************************************/
process_video_width_limit(ScriptParsing * sp,SCRIPT_COMMANDS * sc)634 int process_video_width_limit(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
635 {
636 	return assign_bool(btn_vidmodelimit, sp, sc);
637 }
638 
639 /** ********************************************************
640  * \brief
641  * \param sp Access to ScritpParsing members.
642  * \param sc Access to SCRIPT_COMMANDS structure variables.
643  * \return 0 (no error) Other (error)
644  ***********************************************************/
process_cw_callsign(ScriptParsing * sp,SCRIPT_COMMANDS * sc)645 int process_cw_callsign(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
646 {
647 	return assign_bool(btnCWID, sp, sc);
648 }
649 
650 /** ********************************************************
651  * \brief
652  * \param sp Access to ScritpParsing members.
653  * \param sc Access to SCRIPT_COMMANDS structure variables.
654  * \return 0 (no error) Other (error)
655  ***********************************************************/
process_cw_speed(ScriptParsing * sp,SCRIPT_COMMANDS * sc)656 int process_cw_speed(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
657 {
658 	return assign_integer(sldrCWIDwpm, sp, sc);
659 }
660 
661 /** ********************************************************
662  * \brief
663  * \param sp Access to ScritpParsing members.
664  * \param sc Access to SCRIPT_COMMANDS structure variables.
665  * \return 0 (no error) Other (error)
666  ***********************************************************/
process_misc_nbems_state(ScriptParsing * sp,SCRIPT_COMMANDS * sc)667 int process_misc_nbems_state(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
668 {
669 	return assign_bool(chkAutoExtract, sp, sc);
670 }
671 
672 /** ********************************************************
673  * \brief
674  * \param sp Access to ScritpParsing members.
675  * \param sc Access to SCRIPT_COMMANDS structure variables.
676  * \return 0 (no error) Other (error)
677  ***********************************************************/
process_misc_nbems_open_flmsg(ScriptParsing * sp,SCRIPT_COMMANDS * sc)678 int process_misc_nbems_open_flmsg(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
679 {
680 	return assign_bool(chk_open_flmsg, sp, sc);
681 }
682 
683 /** ********************************************************
684  * \brief
685  * \param sp Access to ScritpParsing members.
686  * \param sc Access to SCRIPT_COMMANDS structure variables.
687  * \return 0 (no error) Other (error)
688  ***********************************************************/
process_misc_nbems_open_msg(ScriptParsing * sp,SCRIPT_COMMANDS * sc)689 int process_misc_nbems_open_msg(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
690 {
691 	return assign_bool(chk_open_wrap_folder, sp, sc);
692 }
693 
694 /** ********************************************************
695  * \brief
696  * \param sp Access to ScritpParsing members.
697  * \param sc Access to SCRIPT_COMMANDS structure variables.
698  * \return 0 (no error) Other (error)
699  ***********************************************************/
process_misc_nbems_open_brwsr(ScriptParsing * sp,SCRIPT_COMMANDS * sc)700 int process_misc_nbems_open_brwsr(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
701 {
702 	return assign_bool(chk_open_flmsg_print, sp, sc);
703 }
704 
705 /** ********************************************************
706  * \brief
707  * \param sp Access to ScritpParsing members.
708  * \param sc Access to SCRIPT_COMMANDS structure variables.
709  * \return 0 (no error) Other (error)
710  ***********************************************************/
process_misc_nbems_flmsg_path(ScriptParsing * sp,SCRIPT_COMMANDS * sc)711 int process_misc_nbems_flmsg_path(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
712 {
713 	return assign_string(txt_flmsg_pathname, sp, sc);
714 }
715 
716 /** ********************************************************
717  * \brief
718  * \param sp Access to ScritpParsing members.
719  * \param sc Access to SCRIPT_COMMANDS structure variables.
720  * \return 0 (no error) Other (error)
721  ***********************************************************/
process_misc_nbems_timeout(ScriptParsing * sp,SCRIPT_COMMANDS * sc)722 int process_misc_nbems_timeout(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
723 {
724 	return assign_integer(sldr_extract_timeout, sp, sc);
725 }
726 
727 /** ********************************************************
728  * \brief
729  * \param sp Access to ScritpParsing members.
730  * \param sc Access to SCRIPT_COMMANDS structure variables.
731  * \return 0 (no error) Other (error)
732  ***********************************************************/
process_rig_freq(ScriptParsing * sp,SCRIPT_COMMANDS * sc)733 int process_rig_freq(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
734 {
735 	// Not suitable for assign_xxxx
736 	if(!sp || !sc)
737 		return script_function_parameter_error;
738 
739 	std::string str_data = "";
740 
741 	if(sc->argc > 0)
742 		str_data.assign(sc->args[0]);
743 
744 	if(str_data.empty())
745 		return script_invalid_parameter;
746 
747 	if(!qsoFreqDisp)
748 		return script_no_errors;
749 
750 	double value = 0;
751 	double max = (double) qsoFreqDisp->maximum();
752 
753 	int cnt = sscanf(str_data.c_str(), "%lf", &value);
754 
755 	if(cnt < 1 || value < 0.0 || value > max)
756 		return script_invalid_parameter;
757 
758 	qsy((long int) value, active_modem ? active_modem->get_freq() : 1500);
759 
760 	return script_no_errors;
761 }
762 
763 /** ********************************************************
764  * \brief
765  * \param sp Access to ScritpParsing members.
766  * \param sc Access to SCRIPT_COMMANDS structure variables.
767  * \return 0 (no error) Other (error)
768  ***********************************************************/
process_rig_mode(ScriptParsing * sp,SCRIPT_COMMANDS * sc)769 int process_rig_mode(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
770 {
771 	return assign_index(qso_opMODE, sp, sc);
772 }
773 
774 /** ********************************************************
775  * \brief
776  * \param sp Access to ScritpParsing members.
777  * \param sc Access to SCRIPT_COMMANDS structure variables.
778  * \return 0 (no error) Other (error)
779  ***********************************************************/
process_wf_hz_offset(ScriptParsing * sp,SCRIPT_COMMANDS * sc)780 int process_wf_hz_offset(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
781 {
782 	// Not suitable for assign_xxxx
783 	if(!sp || !sc)
784 		return script_function_parameter_error;
785 
786 	std::string str_data = "";
787 
788 	if(sc->argc > 0)
789 		str_data.assign(sc->args[0]);
790 
791 	if(str_data.empty())
792 		return script_invalid_parameter;
793 
794 	if(!cntrWfwidth)
795 		return script_no_errors;
796 
797 	int value = 0;
798 	int cnt = sscanf(str_data.c_str(), "%d", &value);
799 
800 	int min = 0;
801 	int max = cntrWfwidth->maximum();
802 
803 	if(cnt < 1 || value < min || value > max)
804 		return script_invalid_parameter;
805 
806 	active_modem->set_freq(value);
807 
808 	return script_no_errors;
809 }
810 
811 /** ********************************************************
812  * \brief
813  * \param sp Access to ScritpParsing members.
814  * \param sc Access to SCRIPT_COMMANDS structure variables.
815  * \return 0 (no error) Other (error)
816  ***********************************************************/
process_rx_rsid(ScriptParsing * sp,SCRIPT_COMMANDS * sc)817 int process_rx_rsid(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
818 {
819 	return assign_bool(btnRSID, sp, sc);
820 }
821 
822 /** ********************************************************
823  * \brief
824  * \param sp Access to ScritpParsing members.
825  * \param sc Access to SCRIPT_COMMANDS structure variables.
826  * \return 0 (no error) Other (error)
827  ***********************************************************/
process_tx_rsid(ScriptParsing * sp,SCRIPT_COMMANDS * sc)828 int process_tx_rsid(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
829 {
830 	return assign_bool(btnTxRSID, sp, sc);
831 }
832 
833 /** ********************************************************
834  * \brief
835  * \param sp Access to ScritpParsing members.
836  * \param sc Access to SCRIPT_COMMANDS structure variables.
837  * \return 0 (no error) Other (error)
838  ***********************************************************/
process_spot(ScriptParsing * sp,SCRIPT_COMMANDS * sc)839 int process_spot(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
840 {
841 	return assign_bool(btnAutoSpot, sp, sc);
842 }
843 
844 /** ********************************************************
845  * \brief
846  * \param sp Access to ScritpParsing members.
847  * \param sc Access to SCRIPT_COMMANDS structure variables.
848  * \return 0 (no error) Other (error)
849  ***********************************************************/
process_rev(ScriptParsing * sp,SCRIPT_COMMANDS * sc)850 int process_rev(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
851 {
852 	if(!wf)	return script_no_errors;
853 	return assign_bool(wf->btnRev, sp, sc);
854 }
855 
856 /** ********************************************************
857  * \brief
858  * \param sp Access to ScritpParsing members.
859  * \param sc Access to SCRIPT_COMMANDS structure variables.
860  * \return 0 (no error) Other (error)
861  ***********************************************************/
process_afc(ScriptParsing * sp,SCRIPT_COMMANDS * sc)862 int process_afc(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
863 {
864 	return assign_bool(btnAFC, sp, sc);
865 }
866 
867 /** ********************************************************
868  * \brief
869  * \param sp Access to ScritpParsing members.
870  * \param sc Access to SCRIPT_COMMANDS structure variables.
871  * \return 0 (no error) Other (error)
872  ***********************************************************/
process_lock(ScriptParsing * sp,SCRIPT_COMMANDS * sc)873 int process_lock(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
874 {
875 	if(!wf)	return script_no_errors;
876 	return assign_bool(wf->xmtlock, sp, sc);
877 }
878 
879 /** ********************************************************
880  * \brief
881  * \param sp Access to ScritpParsing members.
882  * \param sc Access to SCRIPT_COMMANDS structure variables.
883  * \return 0 (no error) Other (error)
884  ***********************************************************/
process_sql(ScriptParsing * sp,SCRIPT_COMMANDS * sc)885 int process_sql(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
886 {
887 	return assign_bool(btnSQL, sp, sc);
888 }
889 
890 /** ********************************************************
891  * \brief
892  * \param sp Access to ScritpParsing members.
893  * \param sc Access to SCRIPT_COMMANDS structure variables.
894  * \return 0 (no error) Other (error)
895  ***********************************************************/
process_kpsql(ScriptParsing * sp,SCRIPT_COMMANDS * sc)896 int process_kpsql(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
897 {
898 	return assign_bool(btnPSQL, sp, sc);
899 }
900 
901 /** ********************************************************
902  * \brief
903  * \param sp Access to ScritpParsing members.
904  * \param sc Access to SCRIPT_COMMANDS structure variables.
905  * \return 0 (no error) Other (error)
906  **********************************************************/
process_modem(ScriptParsing * sp,SCRIPT_COMMANDS * sc)907 int process_modem(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
908 {
909 	// Not suitable for assign_xxxx
910 	if(!sp || !sc)
911 		return script_function_parameter_error;
912 
913 	bool modem_found = false;
914 	int index = 0;
915 
916 	std::string value;
917 	value.assign(sc->args[0]);
918 
919 	if(value.empty())
920 		return script_parameter_error;
921 
922 	sp->to_uppercase(value);
923 
924 	for(index = 0; index < NUM_MODES; index++) {
925 		if(strncmp(value.c_str(), mode_info[index].sname, 32) == 0) {
926 			modem_found = true;
927 			break;
928 		}
929 	}
930 
931 	if(modem_found == false)
932 		return script_invalid_parameter;
933 
934 	if((data_io_enabled == KISS_IO) && (!(mode_info[index].iface_io & KISS_IO))) {
935 		LOG_INFO(_("Invalid Modem for KISS IO"));
936 		return script_invalid_parameter;
937 	}
938 
939 	REQ_SYNC(init_modem_sync, index, 0);
940 
941 	return script_no_errors;
942 }
943 
944 /** ********************************************************
945  * \brief
946  * \param sp Access to ScritpParsing members.
947  * \param sc Access to SCRIPT_COMMANDS structure variables.
948  * \return 0 (no error) Other (error)
949  ***********************************************************/
process_io_kiss_ip_address(ScriptParsing * sp,SCRIPT_COMMANDS * sc)950 int process_io_kiss_ip_address(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
951 {
952 	// Not suitable for assign_xxxx
953 	if(!sp || !sc)
954 		return script_function_parameter_error;
955 
956 	std::string str_data = "";
957 
958 	if(sc->argc > 0)
959 		str_data.assign(sc->args[0]);
960 
961 	if(str_data.empty())
962 		return script_invalid_parameter;
963 
964 	if(!txtKiss_ip_address)
965 		return script_no_errors;
966 
967 	if(strncmp((const char *)str_data.c_str(), (const char *)txtKiss_ip_address->value(), 32) != 0) {
968 		txtKiss_ip_address->value(str_data.c_str());
969 		txtKiss_ip_address->do_callback();
970 		sp->restart_flag(true);
971 	}
972 
973 	return script_no_errors;
974 }
975 
976 /** ********************************************************
977  * \brief
978  * \param sp Access to ScritpParsing members.
979  * \param sc Access to SCRIPT_COMMANDS structure variables.
980  * \return 0 (no error) Other (error)
981  ***********************************************************/
process_io_kiss_io_port_no(ScriptParsing * sp,SCRIPT_COMMANDS * sc)982 int process_io_kiss_io_port_no(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
983 {
984 	// Not suitable for assign_xxxx
985 	if(!sp || !sc)
986 		return script_function_parameter_error;
987 
988 	std::string str_data = "";
989 
990 	if(sc->argc > 0)
991 		str_data.assign(sc->args[0]);
992 
993 	if(str_data.empty())
994 		return script_invalid_parameter;
995 
996 	if(!txtKiss_ip_io_port_no)
997 		return script_no_errors;
998 
999 	if(strncmp((const char *)str_data.c_str(), (const char *)txtKiss_ip_io_port_no->value(), 32) != 0) {
1000 		txtKiss_ip_io_port_no->value(str_data.c_str());
1001 		txtKiss_ip_io_port_no->do_callback();
1002 		sp->restart_flag(true);
1003 	}
1004 
1005 	return script_no_errors;
1006 }
1007 
1008 /** ********************************************************
1009  * \brief
1010  * \param sp Access to ScritpParsing members.
1011  * \param sc Access to SCRIPT_COMMANDS structure variables.
1012  * \return 0 (no error) Other (error)
1013  ***********************************************************/
process_io_kiss_o_port_no(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1014 int process_io_kiss_o_port_no(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1015 {
1016 	// Not suitable for assign_xxxx
1017 	if(!sp || !sc)
1018 		return script_function_parameter_error;
1019 
1020 	std::string str_data = "";
1021 
1022 	if(sc->argc > 0)
1023 		str_data.assign(sc->args[0]);
1024 
1025 	if(str_data.empty())
1026 		return script_invalid_parameter;
1027 
1028 	if(!txtKiss_ip_out_port_no)
1029 		return script_no_errors;
1030 
1031 	if(strncmp((const char *)str_data.c_str(), (const char *)txtKiss_ip_out_port_no->value(), 32) != 0) {
1032 		txtKiss_ip_out_port_no->value(str_data.c_str());
1033 		txtKiss_ip_out_port_no->do_callback();
1034 		sp->restart_flag(true);
1035 	}
1036 
1037 	return script_no_errors;
1038 }
1039 
1040 /** ********************************************************
1041  * \brief
1042  * \param sp Access to ScritpParsing members.
1043  * \param sc Access to SCRIPT_COMMANDS structure variables.
1044  * \return 0 (no error) Other (error)
1045  ***********************************************************/
process_io_kiss_dual_port(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1046 int process_io_kiss_dual_port(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1047 {
1048 	return assign_bool(btnEnable_dual_port, sp, sc);
1049 }
1050 
1051 /** ********************************************************
1052  * \brief
1053  * \param sp Access to ScritpParsing members.
1054  * \param sc Access to SCRIPT_COMMANDS structure variables.
1055  * \return 0 (no error) Other (error)
1056  ***********************************************************/
process_io_kiss_busy_channel(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1057 int process_io_kiss_busy_channel(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1058 {
1059 	return assign_bool(btnEnableBusyChannel, sp, sc);
1060 }
1061 
1062 /** ********************************************************
1063  * \brief
1064  * \param sp Access to ScritpParsing members.
1065  * \param sc Access to SCRIPT_COMMANDS structure variables.
1066  * \return 0 (no error) Other (error)
1067  ***********************************************************/
process_io_kiss_continue_after(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1068 int process_io_kiss_continue_after(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1069 {
1070 	return assign_integer(cntBusyChannelSeconds, sp, sc);
1071 }
1072 
1073 /** ********************************************************
1074  * \brief
1075  * \param sp Access to ScritpParsing members.
1076  * \param sc Access to SCRIPT_COMMANDS structure variables.
1077  * \return 0 (no error) Other (error)
1078  ***********************************************************/
process_io_kiss_kpsql_atten(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1079 int process_io_kiss_kpsql_atten(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1080 {
1081 	return assign_integer(cntKPSQLAttenuation, sp, sc);
1082 }
1083 
1084 /** ********************************************************
1085  * \brief
1086  * \param sp Access to ScritpParsing members.
1087  * \param sc Access to SCRIPT_COMMANDS structure variables.
1088  * \return 0 (no error) Other (error)
1089  ***********************************************************/
process_io_arq_ip_address(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1090 int process_io_arq_ip_address(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1091 {
1092 	// Not suitable for assign_xxxx
1093 	if(!sp || !sc)
1094 		return script_function_parameter_error;
1095 
1096 	std::string str_data = "";
1097 
1098 	if(sc->argc > 0)
1099 		str_data.assign(sc->args[0]);
1100 
1101 	if(str_data.empty())
1102 		return script_invalid_parameter;
1103 
1104 	if(!txtArq_ip_address)
1105 		return script_no_errors;
1106 
1107 	if(strncmp((const char *)str_data.c_str(), (const char *)txtArq_ip_address->value(), 32) != 0) {
1108 		txtArq_ip_address->value(str_data.c_str());
1109 		txtArq_ip_address->do_callback();
1110 		sp->restart_flag(true);
1111 	}
1112 
1113 	return script_no_errors;
1114 }
1115 
1116 /** ********************************************************
1117  * \brief
1118  * \param sp Access to ScritpParsing members.
1119  * \param sc Access to SCRIPT_COMMANDS structure variables.
1120  * \return 0 (no error) Other (error)
1121  ***********************************************************/
process_io_arq_io_port_no(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1122 int process_io_arq_io_port_no(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1123 {
1124 	// Not suitable for assign_xxxx
1125 	if(!sp || !sc)
1126 		return script_function_parameter_error;
1127 
1128 	std::string str_data = "";
1129 
1130 	if(sc->argc > 0)
1131 		str_data.assign(sc->args[0]);
1132 
1133 	if(str_data.empty())
1134 		return script_invalid_parameter;
1135 
1136 	if(!txtArq_ip_address)
1137 		return script_no_errors;
1138 
1139 	if(strncmp((const char *)str_data.c_str(), (const char *)txtArq_ip_port_no->value(), 32) != 0) {
1140 		txtArq_ip_port_no->value(str_data.c_str());
1141 		txtArq_ip_port_no->do_callback();
1142 		sp->restart_flag(true);
1143 	}
1144 
1145 	return script_no_errors;
1146 }
1147 
1148 /** ********************************************************
1149  * \brief
1150  * \param sp Access to ScritpParsing members.
1151  * \param sc Access to SCRIPT_COMMANDS structure variables.
1152  * \return 0 (no error) Other (error)
1153  ***********************************************************/
process_io_xmlrpc_ip_address(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1154 int process_io_xmlrpc_ip_address(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1155 {
1156 	// Not suitable for assign_xxxx
1157 	if(!sp || !sc)
1158 		return script_function_parameter_error;
1159 
1160 	std::string str_data = "";
1161 
1162 	if(sc->argc > 0)
1163 		str_data.assign(sc->args[0]);
1164 
1165 	if(str_data.empty())
1166 		return script_invalid_parameter;
1167 
1168 	if(!txtXmlrpc_ip_address)
1169 		return script_no_errors;
1170 
1171 	if(strncmp((const char *)str_data.c_str(), (const char *)txtXmlrpc_ip_address->value(), 32) != 0) {
1172 		txtXmlrpc_ip_address->value(str_data.c_str());
1173 		txtXmlrpc_ip_address->do_callback();
1174 		sp->restart_flag(true);
1175 	}
1176 
1177 	return script_no_errors;
1178 }
1179 
1180 /** ********************************************************
1181  * \brief
1182  * \param sp Access to ScritpParsing members.
1183  * \param sc Access to SCRIPT_COMMANDS structure variables.
1184  * \return 0 (no error) Other (error)
1185  ***********************************************************/
process_io_xmlrpc_io_port_no(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1186 int process_io_xmlrpc_io_port_no(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1187 {
1188 	// Not suitable for assign_xxxx
1189 	if(!sp || !sc)
1190 		return script_function_parameter_error;
1191 
1192 	std::string str_data = "";
1193 
1194 	if(sc->argc > 0)
1195 		str_data.assign(sc->args[0]);
1196 
1197 	if(str_data.empty())
1198 		return script_invalid_parameter;
1199 
1200 	if(!txtXmlrpc_ip_port_no)
1201 		return script_no_errors;
1202 
1203 	if(strncmp((const char *)str_data.c_str(), (const char *)txtXmlrpc_ip_port_no->value(), 32) != 0) {
1204 		txtXmlrpc_ip_port_no->value(str_data.c_str());
1205 		txtXmlrpc_ip_port_no->do_callback();
1206 		sp->restart_flag(true);
1207 	}
1208 
1209 	return script_no_errors;
1210 }
1211 
1212 /** ********************************************************
1213  * \brief
1214  * \param sp Access to ScritpParsing members.
1215  * \param sc Access to SCRIPT_COMMANDS structure variables.
1216  * \return 0 (no error) Other (error)
1217  ***********************************************************/
process_io_lock(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1218 int process_io_lock(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1219 {
1220 	return assign_bool(btnDisable_p2p_io_widgets, sp, sc);
1221 }
1222 
1223 /** ********************************************************
1224  * \brief
1225  * \param sp Access to ScritpParsing members.
1226  * \param sc Access to SCRIPT_COMMANDS structure variables.
1227  * \return 0 (no error) Other (error)
1228  ***********************************************************/
process_io_active_port(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1229 int process_io_active_port(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1230 {
1231 	// Not suitable for assign_xxxx
1232 	if(!sp || !sc)
1233 		return script_function_parameter_error;
1234 
1235 	std::string value;
1236 	value.assign(sc->args[0]);
1237 
1238 	if(value.empty())
1239 		return script_parameter_error;
1240 
1241 	sp->to_uppercase(value);
1242 
1243 	if(!btnEnable_kiss || !btnEnable_arq)
1244 		return script_no_errors;
1245 
1246 	if(value.find(PARM_KISS) != std::string::npos) {
1247         enable_kiss();
1248 	} else if(value.find(PARM_ARQ) != std::string::npos) {
1249         enable_arq();
1250 	} else {
1251 		return script_invalid_parameter;
1252 	}
1253 
1254 	return script_no_errors;
1255 }
1256 
1257 /** ********************************************************
1258  * \brief
1259  * \param sp Access to ScritpParsing members.
1260  * \param sc Access to SCRIPT_COMMANDS structure variables.
1261  * \return 0 (no error) Other (error)
1262  ***********************************************************/
process_io_ax25_decode(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1263 int process_io_ax25_decode(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1264 {
1265 	return assign_bool(btnEnable_ax25_decode, sp, sc);
1266 }
1267 
1268 /** ********************************************************
1269  * \brief
1270  * \param sp Access to ScritpParsing members.
1271  * \param sc Access to SCRIPT_COMMANDS structure variables.
1272  * \return 0 (no error) Other (error)
1273  ***********************************************************/
process_io_csma(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1274 int process_io_csma(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1275 {
1276 	return assign_bool(btnEnable_csma, sp, sc);
1277 }
1278 
1279 /** ********************************************************
1280  * \brief Assign Call Sign.
1281  * \param sp Access to ScritpParsing members.
1282  * \param sc Access to SCRIPT_COMMANDS structure variables.
1283  * \return 0 (no error) Other (error)
1284  * \par Note:
1285  * This string storage can be assigned to anything. User
1286  * should follow the limitations imposed by the rules
1287  * of the host country.
1288  ***********************************************************/
process_callsign_info(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1289 int process_callsign_info(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1290 {
1291 	return assign_string(inpMyCallsign, sp, sc);
1292 }
1293 
1294 /** ********************************************************
1295  * \brief Operator Name
1296  * \param sp Access to ScritpParsing members.
1297  * \param sc Access to SCRIPT_COMMANDS structure variables.
1298  * \return 0 (no error) Other (error)
1299  ***********************************************************/
process_name_info(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1300 int process_name_info(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1301 {
1302 	return assign_string(inpMyName, sp, sc);
1303 }
1304 
1305 /** ********************************************************
1306  * \brief QTH Location of Operator
1307  * \param sp Access to ScritpParsing members.
1308  * \param sc Access to SCRIPT_COMMANDS structure variables.
1309  * \return 0 (no error) Other (error)
1310  ***********************************************************/
process_qth_info(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1311 int process_qth_info(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1312 {
1313 	return assign_string(inpMyQth, sp, sc);
1314 }
1315 
1316 /** ********************************************************
1317  * \brief Assign Locator
1318  * \param sp Access to ScritpParsing members.
1319  * \param sc Access to SCRIPT_COMMANDS structure variables.
1320  * \return 0 (no error) Other (error)
1321  ***********************************************************/
process_locator_info(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1322 int process_locator_info(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1323 {
1324 	return assign_string(inpMyLocator, sp, sc);
1325 }
1326 
1327 /** ********************************************************
1328  * \brief Assign Antenna information
1329  * \param sp Access to ScritpParsing members.
1330  * \param sc Access to SCRIPT_COMMANDS structure variables.
1331  * \return 0 (no error) Other (error)
1332  ***********************************************************/
process_antenna_info(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1333 int process_antenna_info(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1334 {
1335 	return assign_string(inpMyAntenna, sp, sc);
1336 }
1337 
1338 /** ********************************************************
1339  * \brief
1340  * \param sp Access to ScritpParsing members.
1341  * \param sc Access to SCRIPT_COMMANDS structure variables.
1342  * \return 0 (no error) Other (error)
1343  ***********************************************************/
process_use_oss_audio_device(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1344 int process_use_oss_audio_device(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1345 {
1346 #if USE_OSS
1347 	return assign_bool(btnAudioIO[0], sp, sc);
1348 #else
1349 	return script_no_errors;
1350 #endif // USE_OSS
1351 }
1352 
1353 /** ********************************************************
1354  * \brief
1355  * \param sp Access to ScritpParsing members.
1356  * \param sc Access to SCRIPT_COMMANDS structure variables.
1357  * \return 0 (no error) Other (error)
1358  ***********************************************************/
process_oss_audio_device_path(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1359 int process_oss_audio_device_path(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1360 {
1361 	// Not suitable for assign_xxxx
1362 #if USE_OSS
1363 	if(!sp || !sc)
1364 		return script_function_parameter_error;
1365 
1366 	std::string str_data;
1367 	std::string valid_data;
1368 
1369 	str_data.assign(sc->args[0]);
1370 	if(str_data.empty())
1371 		return script_invalid_parameter;
1372 
1373 	if(!menuOSSDev)
1374 		return script_no_errors;
1375 
1376 	if(sp->check_dev_path(str_data.c_str()))
1377 		return script_device_path_not_found;
1378 
1379 	int index = 0;
1380 	bool found = false;
1381 	int count = menuOSSDev->menubutton()->size();
1382 
1383 	for (index = 0; index < count; index++ ) {
1384 		const Fl_Menu_Item &item = menuOSSDev->menubutton()->menu()[index];
1385 		valid_data.assign(item.label());
1386 		if(!valid_data.empty()) {
1387 			if(strncmp(valid_data.c_str(), str_data.c_str(), FL_PATH_MAX) == 0) {
1388 				found = true;
1389 				break;
1390 			}
1391 		}
1392 	}
1393 
1394 	if(!found)
1395 		return script_invalid_parameter;
1396 
1397 	menuOSSDev->value(index);
1398 	menuOSSDev->do_callback();
1399 	return script_no_errors;
1400 
1401 #else
1402 	return script_no_errors;
1403 #endif // USE_OSS
1404 }
1405 
1406 /** ********************************************************
1407  * \brief
1408  * \param sp Access to ScritpParsing members.
1409  * \param sc Access to SCRIPT_COMMANDS structure variables.
1410  * \return 0 (no error) Other (error)
1411  ***********************************************************/
process_use_port_audio_device(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1412 int process_use_port_audio_device(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1413 {
1414 #if USE_PORTAUDIO
1415 	return assign_bool(btnAudioIO[1], sp, sc);
1416 #else
1417 	return script_no_errors;
1418 #endif // USE_PORTAUDIO
1419 }
1420 
1421 /** ********************************************************
1422  * \brief
1423  * \param sp Access to ScritpParsing members.
1424  * \param sc Access to SCRIPT_COMMANDS structure variables.
1425  * \return 0 (no error) Other (error)
1426  ***********************************************************/
process_capture_path(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1427 int process_capture_path(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1428 {
1429 	// Not suitable for assign_xxxx
1430 #if USE_PORTAUDIO
1431 	if(!sp || !sc)
1432 		return script_function_parameter_error;
1433 
1434 	int value = 0;
1435 	std::string str_data = "";
1436 
1437 	if(sc->argc < 2)
1438 		return script_invalid_parameter;
1439 
1440 	int cnt = sscanf(sc->args[0], "%d", &value);
1441 
1442 	if(cnt < 1 || value < 0)
1443 		return script_invalid_parameter;
1444 
1445 	str_data.assign(sc->args[1]);
1446 	if(str_data.empty())
1447 		return script_invalid_parameter;
1448 
1449 	if(!menuPortInDev)
1450 		return script_no_errors;
1451 
1452 	cnt = pa_set_dev(menuPortInDev, str_data, value);
1453 
1454 	if(cnt == PA_DEV_NOT_FOUND)
1455 		return script_invalid_parameter;
1456 
1457 #endif // USE_PORTAUDIO
1458 
1459 	return script_no_errors;
1460 }
1461 
1462 /** ********************************************************
1463  * \brief
1464  * \param sp Access to ScritpParsing members.
1465  * \param sc Access to SCRIPT_COMMANDS structure variables.
1466  * \return 0 (no error) Other (error)
1467  ***********************************************************/
process_playback_path(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1468 int process_playback_path(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1469 {
1470 	// Not suitable for assign_xxxx
1471 #if USE_PORTAUDIO
1472 
1473 	if(!sp || !sc)
1474 		return script_function_parameter_error;
1475 
1476 	int value = 0;
1477 	std::string str_data = "";
1478 
1479 	if(sc->argc < 2)
1480 		return script_invalid_parameter;
1481 
1482 	int cnt = sscanf(sc->args[0], "%d", &value);
1483 
1484 	if(cnt < 1 || value < 0)
1485 		return script_invalid_parameter;
1486 
1487 	str_data.assign(sc->args[1]);
1488 	if(str_data.empty())
1489 		return script_invalid_parameter;
1490 
1491 	if(!menuPortOutDev)
1492 		return script_no_errors;
1493 
1494 	cnt = pa_set_dev(menuPortOutDev, str_data, value);
1495 
1496 	if(cnt == PA_DEV_NOT_FOUND)
1497 		return script_invalid_parameter;
1498 
1499 #endif
1500 
1501 	return script_no_errors;
1502 }
1503 
1504 /** ********************************************************
1505  * \brief
1506  * \param sp Access to ScritpParsing members.
1507  * \param sc Access to SCRIPT_COMMANDS structure variables.
1508  * \return 0 (no error) Other (error)
1509  ***********************************************************/
process_use_pulse_audio_device(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1510 int process_use_pulse_audio_device(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1511 {
1512 #if USE_PULSEAUDIO
1513 	return assign_bool(btnAudioIO[2], sp, sc);
1514 #else
1515 	return script_no_errors;
1516 #endif // USE_PULSEAUDIO
1517 }
1518 
1519 /** ********************************************************
1520  * \brief
1521  * \param sp Access to ScritpParsing members.
1522  * \param sc Access to SCRIPT_COMMANDS structure variables.
1523  * \return 0 (no error) Other (error)
1524  ***********************************************************/
process_pulse_audio_device_path(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1525 int process_pulse_audio_device_path(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1526 {
1527 #if USE_PULSEAUDIO
1528 	return assign_string(inpPulseServer, sp, sc);
1529 #else
1530 	return script_no_errors;
1531 #endif // USE_PULSEAUDIO
1532 }
1533 
1534 /** ********************************************************
1535  * \brief
1536  * \param sp Access to ScritpParsing members.
1537  * \param sc Access to SCRIPT_COMMANDS structure variables.
1538  * \return 0 (no error) Other (error)
1539  ***********************************************************/
process_audio_device_sample_rate_capture(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1540 int process_audio_device_sample_rate_capture(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1541 {
1542 	// Not suitable for assign_xxxx
1543 	if(!sp || !sc)
1544 		return script_function_parameter_error;
1545 
1546 	std::string str_data = "";
1547 
1548 	if(sc->argc > 0)
1549 		str_data.assign(sc->args[0]);
1550 
1551 	if(str_data.empty())
1552 		return script_invalid_parameter;
1553 
1554 	if(!menuInSampleRate)
1555 		return script_no_errors;
1556 
1557 	int index = menuInSampleRate->find_index(str_data.c_str());
1558 	if(index < 0) {
1559 		str_data.append(" (native)");
1560 		index = menuInSampleRate->find_index(str_data.c_str());
1561 	}
1562 
1563 	if(index < 0)
1564 		return script_invalid_parameter;
1565 
1566 	menuInSampleRate->index(index);
1567 	menuInSampleRate->do_callback();
1568 
1569 	return script_no_errors;
1570 }
1571 
1572 /** ********************************************************
1573  * \brief
1574  * \param sp Access to ScritpParsing members.
1575  * \param sc Access to SCRIPT_COMMANDS structure variables.
1576  * \return 0 (no error) Other (error)
1577  ***********************************************************/
process_audio_device_sample_rate_playback(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1578 int process_audio_device_sample_rate_playback(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1579 {
1580 	// Not suitable for assign_xxxx
1581 	if(!sp || !sc)
1582 		return script_function_parameter_error;
1583 
1584 	std::string str_data = "";
1585 
1586 	if(sc->argc > 0)
1587 		str_data.assign(sc->args[0]);
1588 
1589 	if(str_data.empty())
1590 		return script_invalid_parameter;
1591 
1592 	if(!menuOutSampleRate)
1593 		return script_no_errors;
1594 
1595 	int index = menuOutSampleRate->find_index(str_data.c_str());
1596 	if(index < 0) {
1597 		str_data.append(" (native)");
1598 		index = menuOutSampleRate->find_index(str_data.c_str());
1599 	}
1600 
1601 	if(index < 0)
1602 		return script_invalid_parameter;
1603 
1604 	menuOutSampleRate->index(index);
1605 	menuOutSampleRate->do_callback();
1606 
1607 	return script_no_errors;
1608 
1609 }
1610 
1611 /** ********************************************************
1612  * \brief
1613  * \param sp Access to ScritpParsing members.
1614  * \param sc Access to SCRIPT_COMMANDS structure variables.
1615  * \return 0 (no error) Other (error)
1616  ***********************************************************/
process_audio_device_converter(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1617 int process_audio_device_converter(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1618 {
1619 	// Not suitable for assign_xxxx
1620 	if(!sp || !sc)
1621 		return script_function_parameter_error;
1622 
1623 	std::string str_data;
1624 	std::string append_string;
1625 
1626 	if(sc->argc > 0)
1627 		str_data.assign(sc->args[0]);
1628 
1629 	if(str_data.empty())
1630 		return script_invalid_parameter;
1631 
1632 	append_string.assign(" Sinc Interpolator");
1633 	if(str_data.find(append_string) != std::string::npos)
1634 		append_string.clear();
1635 
1636 	if(append_string.empty()) {
1637 		append_string.assign(" Interpolator");
1638 		if(str_data.find(append_string) != std::string::npos) {
1639 			append_string.clear();
1640 		}
1641 	}
1642 
1643 	str_data.append(append_string);
1644 
1645 	if(!menuSampleConverter)
1646 		return script_no_errors;
1647 
1648 	int index = menuSampleConverter->find_index(str_data.c_str());
1649 	if(index < 0)
1650 		return script_invalid_parameter;
1651 
1652 	menuSampleConverter->index(index);
1653 	menuSampleConverter->do_callback();
1654 
1655 	return script_no_errors;
1656 }
1657 
1658 /** ********************************************************
1659  * \brief
1660  * \param sp Access to ScritpParsing members.
1661  * \param sc Access to SCRIPT_COMMANDS structure variables.
1662  * \return 0 (no error) Other (error)
1663  ***********************************************************/
process_rx_ppm(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1664 int process_rx_ppm(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1665 {
1666 	return assign_integer(cntRxRateCorr, sp, sc);
1667 }
1668 
1669 /** ********************************************************
1670  * \brief
1671  * \param sp Access to ScritpParsing members.
1672  * \param sc Access to SCRIPT_COMMANDS structure variables.
1673  * \return 0 (no error) Other (error)
1674  ***********************************************************/
process_tx_ppm(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1675 int process_tx_ppm(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1676 {
1677 	return assign_integer(cntTxRateCorr, sp, sc);
1678 }
1679 
1680 /** ********************************************************
1681  * \brief
1682  * \param sp Access to ScritpParsing members.
1683  * \param sc Access to SCRIPT_COMMANDS structure variables.
1684  * \return 0 (no error) Other (error)
1685  ***********************************************************/
process_tx_offset(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1686 int process_tx_offset(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1687 {
1688 	return assign_integer(cntTxOffset, sp, sc);
1689 }
1690 
1691 /** ********************************************************
1692  * \brief
1693  * \param sp Access to ScritpParsing members.
1694  * \param sc Access to SCRIPT_COMMANDS structure variables.
1695  * \return 0 (no error) Other (error)
1696  ***********************************************************/
process_modem_signal_left_right(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1697 int process_modem_signal_left_right(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1698 {
1699 	return assign_bool(chkAudioStereoOut, sp, sc);
1700 }
1701 
1702 /** ********************************************************
1703  * \brief
1704  * \param sp Access to ScritpParsing members.
1705  * \param sc Access to SCRIPT_COMMANDS structure variables.
1706  * \return 0 (no error) Other (error)
1707  ***********************************************************/
process_reverse_left_right(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1708 int process_reverse_left_right(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1709 {
1710 	return assign_bool(chkReverseAudio, sp, sc);
1711 }
1712 
1713 /** ********************************************************
1714  * \brief
1715  * \param sp Access to ScritpParsing members.
1716  * \param sc Access to SCRIPT_COMMANDS structure variables.
1717  * \return 0 (no error) Other (error)
1718  ***********************************************************/
process_ptt_tone_right_channel(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1719 int process_ptt_tone_right_channel(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1720 {
1721 	return assign_bool(btnPTTrightchannel2, sp, sc);
1722 }
1723 
1724 /** ********************************************************
1725  * \brief
1726  * \param sp Access to ScritpParsing members.
1727  * \param sc Access to SCRIPT_COMMANDS structure variables.
1728  * \return 0 (no error) Other (error)
1729  ***********************************************************/
process_cw_qsk_right_channel(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1730 int process_cw_qsk_right_channel(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1731 {
1732 	return assign_bool(btnQSK2, sp, sc);
1733 }
1734 
1735 /** ********************************************************
1736  * \brief
1737  * \param sp Access to ScritpParsing members.
1738  * \param sc Access to SCRIPT_COMMANDS structure variables.
1739  * \return 0 (no error) Other (error)
1740  ***********************************************************/
process_pseudo_fsk_right_channel(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1741 int process_pseudo_fsk_right_channel(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1742 {
1743 	return assign_bool(chkPseudoFSK2, sp, sc);
1744 }
1745 
1746 /** ********************************************************
1747  * \brief
1748  * \param sp Access to ScritpParsing members.
1749  * \param sc Access to SCRIPT_COMMANDS structure variables.
1750  * \return 0 (no error) Other (error)
1751  ***********************************************************/
process_wave_file_sample_rate(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1752 int process_wave_file_sample_rate(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1753 {
1754 	// Not suitable for assign_xxxx
1755 	if(!sp || !sc)
1756 		return script_function_parameter_error;
1757 
1758 	std::string str_data = "";
1759 	char buffer[32];
1760 
1761 	if(sc->argc > 0)
1762 		str_data.assign(sc->args[0]);
1763 
1764 	if(str_data.empty())
1765 		return script_invalid_parameter;
1766 
1767 	int value = 0;
1768 	int cnt = sscanf(str_data.c_str(), "%d", &value);
1769 
1770 	if(cnt < 1)
1771 		return script_invalid_parameter;
1772 
1773 	if((value < 8000) || (value > 48000))
1774 		return script_invalid_parameter;
1775 
1776 	memset(buffer, 0, sizeof(buffer));
1777 	snprintf(buffer, sizeof(buffer) - 1, "%d", value);
1778 
1779 	if(!listbox_wav_samplerate)
1780 		return script_no_errors;
1781 
1782 	int index = listbox_wav_samplerate->find_index(buffer);
1783 	if(index < 0)
1784 		return script_invalid_parameter;
1785 
1786 	listbox_wav_samplerate->index(index);
1787 	listbox_wav_samplerate->do_callback();
1788 
1789 	return script_no_errors;
1790 }
1791 
1792 /** ********************************************************
1793  * \brief
1794  * \param sp Access to ScritpParsing members.
1795  * \param sc Access to SCRIPT_COMMANDS structure variables.
1796  * \return 0 (no error) Other (error)
1797  ***********************************************************/
process_hrdw_ptt_right_audio_channel(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1798 int process_hrdw_ptt_right_audio_channel(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1799 {
1800 	return assign_bool(btnPTTrightchannel, sp, sc);
1801 }
1802 
1803 /** ********************************************************
1804  * \brief
1805  * \param sp Access to ScritpParsing members.
1806  * \param sc Access to SCRIPT_COMMANDS structure variables.
1807  * \return 0 (no error) Other (error)
1808  ***********************************************************/
process_hrdw_ptt_sep_serial_port(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1809 int process_hrdw_ptt_sep_serial_port(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1810 {
1811 	return assign_bool(btnTTYptt, sp, sc);
1812 }
1813 
1814 /** ********************************************************
1815  * \brief
1816  * \param sp Access to ScritpParsing members.
1817  * \param sc Access to SCRIPT_COMMANDS structure variables.
1818  * \return 0 (no error) Other (error)
1819  * \par NOTE:
1820  * Fl_ComboBox (custom widget)
1821  * find_index() located in combo.cxx and used here returns -1
1822  * on non-matching.
1823  ***********************************************************/
process_hrdw_ptt_sep_serial_port_path(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1824 int process_hrdw_ptt_sep_serial_port_path(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1825 {
1826 	return assign_index(inpTTYdev, sp, sc);
1827 }
1828 
1829 /** ********************************************************
1830  * \brief
1831  * \param sp Access to ScritpParsing members.
1832  * \param sc Access to SCRIPT_COMMANDS structure variables.
1833  * \return 0 (no error) Other (error)
1834  ***********************************************************/
process_hrdw_ptt_sep_serial_port_rts(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1835 int process_hrdw_ptt_sep_serial_port_rts(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1836 {
1837 	return assign_bool(btnRTSptt, sp, sc);
1838 }
1839 
1840 /** ********************************************************
1841  * \brief
1842  * \param sp Access to ScritpParsing members.
1843  * \param sc Access to SCRIPT_COMMANDS structure variables.
1844  * \return 0 (no error) Other (error)
1845  ***********************************************************/
process_hrdw_ptt_sep_serial_port_dtr(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1846 int process_hrdw_ptt_sep_serial_port_dtr(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1847 {
1848 	return assign_bool(btnDTRptt, sp, sc);
1849 }
1850 
1851 /** ********************************************************
1852  * \brief
1853  * \param sp Access to ScritpParsing members.
1854  * \param sc Access to SCRIPT_COMMANDS structure variables.
1855  * \return 0 (no error) Other (error)
1856  ***********************************************************/
process_hrdw_ptt_sep_serial_port_rts_v(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1857 int process_hrdw_ptt_sep_serial_port_rts_v(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1858 {
1859 	return assign_bool(btnRTSplusV, sp, sc);
1860 }
1861 
1862 /** ********************************************************
1863  * \brief
1864  * \param sp Access to ScritpParsing members.
1865  * \param sc Access to SCRIPT_COMMANDS structure variables.
1866  * \return 0 (no error) Other (error)
1867  ***********************************************************/
process_hrdw_ptt_sep_serial_port_dtr_v(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1868 int process_hrdw_ptt_sep_serial_port_dtr_v(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1869 {
1870 	return assign_bool(btnDTRplusV, sp, sc);
1871 }
1872 
1873 /** ********************************************************
1874  * \brief
1875  * \param sp Access to ScritpParsing members.
1876  * \param sc Access to SCRIPT_COMMANDS structure variables.
1877  * \return 0 (no error) Other (error)
1878  ***********************************************************/
process_hrdw_ptt_start_delay(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1879 int process_hrdw_ptt_start_delay(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1880 {
1881 	return assign_integer(cntPTT_on_delay, sp, sc);
1882 }
1883 
1884 /** ********************************************************
1885  * \brief
1886  * \param sp Access to ScritpParsing members.
1887  * \param sc Access to SCRIPT_COMMANDS structure variables.
1888  * \return 0 (no error) Other (error)
1889  ***********************************************************/
process_hrdw_ptt_end_delay(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1890 int process_hrdw_ptt_end_delay(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1891 {
1892 	return assign_integer(cntPTT_off_delay, sp, sc);
1893 }
1894 
1895 /** ********************************************************
1896  * \brief
1897  * \param sp Access to ScritpParsing members.
1898  * \param sc Access to SCRIPT_COMMANDS structure variables.
1899  * \return 0 (no error) Other (error)
1900  ***********************************************************/
process_hrdw_ptt_uhrouter(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1901 int process_hrdw_ptt_uhrouter(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1902 {
1903 #if HAVE_UHROUTER
1904 	return assign_bool(btnUseUHrouterPTT, sp, sc);
1905 #else
1906 	return script_no_errors;
1907 #endif // HAVE_UHROUTER
1908 }
1909 
1910 /** ********************************************************
1911  * \brief
1912  * \param sp Access to ScritpParsing members.
1913  * \param sc Access to SCRIPT_COMMANDS structure variables.
1914  * \return 0 (no error) Other (error)
1915  ***********************************************************/
process_hrdw_ptt_parallel(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1916 int process_hrdw_ptt_parallel(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1917 {
1918 	return assign_bool(btnUsePPortPTT, sp, sc);
1919 }
1920 
1921 /** ********************************************************
1922  * \brief
1923  * \param sp Access to ScritpParsing members.
1924  * \param sc Access to SCRIPT_COMMANDS structure variables.
1925  * \return 0 (no error) Other (error)
1926  ***********************************************************/
process_hrdw_ptt_initialize(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1927 int process_hrdw_ptt_initialize(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1928 {
1929 
1930 	if(!btnInitHWPTT)
1931 		return script_no_errors;
1932 
1933 	btnInitHWPTT->do_callback();
1934 
1935 	return script_no_errors;
1936 }
1937 
1938 /** ********************************************************
1939  * \brief
1940  * \param sp Access to ScritpParsing members.
1941  * \param sc Access to SCRIPT_COMMANDS structure variables.
1942  * \return 0 (no error) Other (error)
1943  ***********************************************************/
process_use_rigcat(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1944 int process_use_rigcat(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1945 {
1946 	return assign_bool(chkUSERIGCAT, sp, sc);
1947 }
1948 
1949 extern void loadRigXmlFile(void);
1950 /** ********************************************************
1951  * \brief
1952  * \param sp Access to ScritpParsing members.
1953  * \param sc Access to SCRIPT_COMMANDS structure variables.
1954  * \return 0 (no error) Other (error)
1955  ***********************************************************/
process_rigcat_desc_file(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1956 int process_rigcat_desc_file(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1957 {
1958 	// Not suitable for assign_xxxx
1959 	if(!sp || !sc)
1960 		return script_function_parameter_error;
1961 
1962 	std::string str_data = "";
1963 
1964 	if(sc->argc > 0)
1965 		str_data.assign(sc->args[0]);
1966 
1967 	if(str_data.empty())
1968 		return script_invalid_parameter;
1969 
1970 	if(str_data.find(DEFAULT_RIGXML_FILENAME) != std::string::npos)
1971 		return script_no_errors;
1972 
1973 	if(sp->check_filename((char *) str_data.c_str()))
1974 		return script_file_not_found;
1975 
1976 	if(!txtXmlRigFilename)
1977 		return script_no_errors;
1978 
1979 	progdefaults.XmlRigFilename.assign(str_data);
1980 	txtXmlRigFilename->value(fl_filename_name(progdefaults.XmlRigFilename.c_str()));
1981 	loadRigXmlFile();
1982 
1983 	return script_no_errors;
1984 }
1985 
1986 /** ********************************************************
1987  * \brief
1988  * \param sp Access to ScritpParsing members.
1989  * \param sc Access to SCRIPT_COMMANDS structure variables.
1990  * \return 0 (no error) Other (error)
1991  ***********************************************************/
process_rigcat_device_path(ScriptParsing * sp,SCRIPT_COMMANDS * sc)1992 int process_rigcat_device_path(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
1993 {
1994 	return assign_index(inpXmlRigDevice, sp, sc);
1995 }
1996 
1997 /** ********************************************************
1998  * \brief
1999  * \param sp Access to ScritpParsing members.
2000  * \param sc Access to SCRIPT_COMMANDS structure variables.
2001  * \return 0 (no error) Other (error)
2002  ***********************************************************/
process_rigcat_retries(ScriptParsing * sp,SCRIPT_COMMANDS * sc)2003 int process_rigcat_retries(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
2004 {
2005 	int value = 0;
2006 	int error = assign_integer(cntRigCatRetries, sp, sc, value);
2007 
2008 	if(!error && cntRigCatRetries) {
2009 		progdefaults.RigCatRetries = value;
2010 		progdefaults.changed = true;
2011 	}
2012 	return error;
2013 }
2014 
2015 /** ********************************************************
2016  * \brief
2017  * \param sp Access to ScritpParsing members.
2018  * \param sc Access to SCRIPT_COMMANDS structure variables.
2019  * \return 0 (no error) Other (error)
2020  ***********************************************************/
process_rigcat_retry_interval(ScriptParsing * sp,SCRIPT_COMMANDS * sc)2021 int process_rigcat_retry_interval(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
2022 {
2023 	int value = 0;
2024 	int error = assign_integer(cntRigCatTimeout, sp, sc, value);
2025 
2026 	if(!error && cntRigCatTimeout) {
2027 		progdefaults.RigCatTimeout = value;
2028 		progdefaults.changed = true;
2029 	}
2030 
2031 	return error;
2032 }
2033 
2034 /** ********************************************************
2035  * \brief
2036  * \param sp Access to ScritpParsing members.
2037  * \param sc Access to SCRIPT_COMMANDS structure variables.
2038  * \return 0 (no error) Other (error)
2039  ***********************************************************/
process_rigcat_write_delay(ScriptParsing * sp,SCRIPT_COMMANDS * sc)2040 int process_rigcat_write_delay(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
2041 {
2042 	int value = 0;
2043 	int error = assign_integer(cntRigCatWait, sp, sc, value);
2044 
2045 	if(!error && cntRigCatWait) {
2046 		progdefaults.RigCatTimeout = value;
2047 		progdefaults.changed = true;
2048 	}
2049 
2050 	return error;
2051 }
2052 
2053 /** ********************************************************
2054  * \brief
2055  * \param sp Access to ScritpParsing members.
2056  * \param sc Access to SCRIPT_COMMANDS structure variables.
2057  * \return 0 (no error) Other (error)
2058  ***********************************************************/
process_rigcat_init_delay(ScriptParsing * sp,SCRIPT_COMMANDS * sc)2059 int process_rigcat_init_delay(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
2060 {
2061 	int value = 0;
2062 	int error = assign_integer(cntRigCatInitDelay, sp, sc, value);
2063 
2064 	if(!error && cntRigCatInitDelay) {
2065 		progdefaults.RigCatInitDelay = value;
2066 		progdefaults.changed = true;
2067 	}
2068 	return error;
2069 }
2070 
2071 /** ********************************************************
2072  * \brief
2073  * \param sp Access to ScritpParsing members.
2074  * \param sc Access to SCRIPT_COMMANDS structure variables.
2075  * \return 0 (no error) Other (error)
2076  ***********************************************************/
process_rigcat_baud_rate(ScriptParsing * sp,SCRIPT_COMMANDS * sc)2077 int process_rigcat_baud_rate(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
2078 {
2079 	int index = 0;
2080 	int error = assign_index(listbox_xml_rig_baudrate, sp, sc, index);
2081 
2082 	if(!error && listbox_xml_rig_baudrate) {
2083 		progdefaults.XmlRigBaudrate = index;
2084 		progdefaults.changed = true;
2085 	}
2086 
2087 	return error;
2088 }
2089 
2090 /** ********************************************************
2091  * \brief
2092  * \param sp Access to ScritpParsing members.
2093  * \param sc Access to SCRIPT_COMMANDS structure variables.
2094  * \return 0 (no error) Other (error)
2095  ***********************************************************/
process_rigcat_cat_command_ptt(ScriptParsing * sp,SCRIPT_COMMANDS * sc)2096 int process_rigcat_cat_command_ptt(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
2097 {
2098 	return assign_bool(btnRigCatCMDptt, sp, sc);
2099 }
2100 
2101 /** ********************************************************
2102  * \brief
2103  * \param sp Access to ScritpParsing members.
2104  * \param sc Access to SCRIPT_COMMANDS structure variables.
2105  * \return 0 (no error) Other (error)
2106  ***********************************************************/
process_rigcat_stop_bits(ScriptParsing * sp,SCRIPT_COMMANDS * sc)2107 int process_rigcat_stop_bits(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
2108 {
2109 	int value = 0;
2110 	int error = assign_integer(valRigCatStopbits, sp, sc, value);
2111 
2112 	if(!error && valRigCatStopbits) {
2113 		progdefaults.RigCatStopbits = value;
2114 		progdefaults.changed = true;
2115 	}
2116 
2117 	return error;
2118 }
2119 
2120 /** ********************************************************
2121  * \brief
2122  * \param sp Access to ScritpParsing members.
2123  * \param sc Access to SCRIPT_COMMANDS structure variables.
2124  * \return 0 (no error) Other (error)
2125  ***********************************************************/
process_rigcat_commands_echoed(ScriptParsing * sp,SCRIPT_COMMANDS * sc)2126 int process_rigcat_commands_echoed(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
2127 {
2128 	bool value = 0;
2129 	int error = assign_bool(btnRigCatEcho, sp, sc, value);
2130 
2131 	if(!error && btnRigCatEcho) {
2132 		progdefaults.RigCatECHO = value;
2133 		progdefaults.changed = true;
2134 	}
2135 
2136 	return error;
2137 }
2138 
2139 /** ********************************************************
2140  * \brief
2141  * \param sp Access to ScritpParsing members.
2142  * \param sc Access to SCRIPT_COMMANDS structure variables.
2143  * \return 0 (no error) Other (error)
2144  ***********************************************************/
process_rigcat_toggle_rts_ptt(ScriptParsing * sp,SCRIPT_COMMANDS * sc)2145 int process_rigcat_toggle_rts_ptt(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
2146 {
2147 	bool value = 0;
2148 	int error = assign_bool(btnRigCatRTSptt, sp, sc, value);
2149 
2150 	if(!error && btnRigCatRTSptt) {
2151 		progdefaults.RigCatRTSptt = value;
2152 		progdefaults.changed = true;
2153 	}
2154 
2155 	return error;
2156 }
2157 
2158 /** ********************************************************
2159  * \brief
2160  * \param sp Access to ScritpParsing members.
2161  * \param sc Access to SCRIPT_COMMANDS structure variables.
2162  * \return 0 (no error) Other (error)
2163  ***********************************************************/
process_rigcat_restore_on_close(ScriptParsing * sp,SCRIPT_COMMANDS * sc)2164 int process_rigcat_restore_on_close(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
2165 {
2166 	bool value = 0;
2167 	int error = assign_bool(chk_restore_tio, sp, sc, value);
2168 
2169 	if(!error && chk_restore_tio) {
2170 		progdefaults.RigCatRestoreTIO = value;
2171 		progdefaults.changed = true;
2172 	}
2173 
2174 	return error;
2175 }
2176 
2177 /** ********************************************************
2178  * \brief
2179  * \param sp Access to ScritpParsing members.
2180  * \param sc Access to SCRIPT_COMMANDS structure variables.
2181  * \return 0 (no error) Other (error)
2182  ***********************************************************/
process_rigcat_rts_12v(ScriptParsing * sp,SCRIPT_COMMANDS * sc)2183 int process_rigcat_rts_12v(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
2184 {
2185 	bool value = 0;
2186 	int error = assign_bool(btnRigCatRTSplus, sp, sc, value);
2187 
2188 	if(!error && btnRigCatRTSplus) {
2189 		progdefaults.RigCatRTSplus = value;
2190 		progdefaults.changed = true;
2191 	}
2192 
2193 	return error;
2194 }
2195 
2196 /** ********************************************************
2197  * \brief
2198  * \param sp Access to ScritpParsing members.
2199  * \param sc Access to SCRIPT_COMMANDS structure variables.
2200  * \return 0 (no error) Other (error)
2201  ***********************************************************/
process_rigcat_dtr_12v(ScriptParsing * sp,SCRIPT_COMMANDS * sc)2202 int process_rigcat_dtr_12v(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
2203 {
2204 	bool value = 0;
2205 	int error = assign_bool(btnRigCatDTRplus, sp, sc, value);
2206 
2207 	if(!error && btnRigCatDTRplus) {
2208 		progdefaults.RigCatDTRplus = value;
2209 		progdefaults.changed = true;
2210 	}
2211 
2212 	return error;
2213 }
2214 
2215 /** ********************************************************
2216  * \brief
2217  * \param sp Access to ScritpParsing members.
2218  * \param sc Access to SCRIPT_COMMANDS structure variables.
2219  * \return 0 (no error) Other (error)
2220  ***********************************************************/
process_rigcat_hrdwr_flow(ScriptParsing * sp,SCRIPT_COMMANDS * sc)2221 int process_rigcat_hrdwr_flow(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
2222 {
2223 	bool value = 0;
2224 	int error = assign_bool(chkRigCatRTSCTSflow, sp, sc, value);
2225 
2226 	if(!error && chkRigCatRTSCTSflow) {
2227 		progdefaults.RigCatRTSCTSflow = value;
2228 		progdefaults.changed = true;
2229 	}
2230 
2231 	return error;
2232 }
2233 
2234 /** ********************************************************
2235  * \brief
2236  * \param sp Access to ScritpParsing members.
2237  * \param sc Access to SCRIPT_COMMANDS structure variables.
2238  * \return 0 (no error) Other (error)
2239  ***********************************************************/
process_rigcat_vsp_enable(ScriptParsing * sp,SCRIPT_COMMANDS * sc)2240 int process_rigcat_vsp_enable(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
2241 {
2242 	bool value = 0;
2243 	int error = assign_bool(chkRigCatVSP, sp, sc, value);
2244 
2245 	if(!error && chkRigCatVSP) {
2246 		progdefaults.RigCatVSP = value;
2247 		progdefaults.changed = true;
2248 	}
2249 
2250 	return error;
2251 }
2252 
2253 /** ********************************************************
2254  * \brief
2255  * \param sp Access to ScritpParsing members.
2256  * \param sc Access to SCRIPT_COMMANDS structure variables.
2257  * \return 0 (no error) Other (error)
2258  ***********************************************************/
process_rigcat_initialize(ScriptParsing * sp,SCRIPT_COMMANDS * sc)2259 int process_rigcat_initialize(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
2260 {
2261 	if(!btnInitRIGCAT)
2262 		return script_no_errors;
2263 
2264 	btnInitRIGCAT->do_callback();
2265 
2266 	return script_no_errors;
2267 }
2268 
2269 /** ********************************************************
2270  * \brief
2271  * \param sp Access to ScritpParsing members.
2272  * \param sc Access to SCRIPT_COMMANDS structure variables.
2273  * \return 0 (no error) Other (error)
2274  ***********************************************************/
process_use_hamlib(ScriptParsing * sp,SCRIPT_COMMANDS * sc)2275 int process_use_hamlib(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
2276 {
2277 #if USE_HAMLIB
2278 	return assign_bool(chkUSEHAMLIB, sp, sc);
2279 #endif // USE_HAMLIB
2280 
2281 	return script_no_errors;
2282 }
2283 
2284 /** ********************************************************
2285  * \brief
2286  * \param sp Access to ScritpParsing members.
2287  * \param sc Access to SCRIPT_COMMANDS structure variables.
2288  * \return 0 (no error) Other (error)
2289  ***********************************************************/
process_hamlib_rig(ScriptParsing * sp,SCRIPT_COMMANDS * sc)2290 int process_hamlib_rig(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
2291 {
2292 #if USE_HAMLIB
2293 	return assign_index(cboHamlibRig, sp, sc);
2294 #else
2295 	return script_no_errors;
2296 #endif // USE_HAMLIB
2297 }
2298 
2299 /** ********************************************************
2300  * \brief
2301  * \param sp Access to ScritpParsing members.
2302  * \param sc Access to SCRIPT_COMMANDS structure variables.
2303  * \return 0 (no error) Other (error)
2304  ***********************************************************/
process_hamlib_retries(ScriptParsing * sp,SCRIPT_COMMANDS * sc)2305 int process_hamlib_retries(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
2306 {
2307 #if USE_HAMLIB
2308 	int value = 0;
2309 	int error = assign_integer(cntHamlibRetries, sp, sc, value);
2310 
2311 	if(!error && cntHamlibRetries) {
2312 		progdefaults.HamlibRetries = value;
2313 		progdefaults.changed = true;
2314 	}
2315 
2316 	return error;
2317 
2318 #else
2319 	return script_no_errors;
2320 #endif // USE_HAMLIB
2321 
2322 }
2323 
2324 /** ********************************************************
2325  * \brief
2326  * \param sp Access to ScritpParsing members.
2327  * \param sc Access to SCRIPT_COMMANDS structure variables.
2328  * \return 0 (no error) Other (error)
2329  ***********************************************************/
process_hamlib_retry_interval(ScriptParsing * sp,SCRIPT_COMMANDS * sc)2330 int process_hamlib_retry_interval(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
2331 {
2332 #if USE_HAMLIB
2333 	int value = 0;
2334 	int error = assign_integer(cntHamlibTimeout, sp, sc, value);
2335 
2336 	if(!error && cntHamlibTimeout) {
2337 		progdefaults.HamlibTimeout = value;
2338 		progdefaults.changed = true;
2339 	}
2340 
2341 	return error;
2342 #else
2343 	return script_no_errors;
2344 #endif // USE_HAMLIB
2345 }
2346 
2347 /** ********************************************************
2348  * \brief
2349  * \param sp Access to ScritpParsing members.
2350  * \param sc Access to SCRIPT_COMMANDS structure variables.
2351  * \return 0 (no error) Other (error)
2352  ***********************************************************/
process_hamlib_write_delay(ScriptParsing * sp,SCRIPT_COMMANDS * sc)2353 int process_hamlib_write_delay(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
2354 {
2355 #if USE_HAMLIB
2356 	int value = 0;
2357 	int error = assign_integer(cntHamlibWriteDelay, sp, sc, value);
2358 
2359 	if(!error && cntHamlibWriteDelay) {
2360 		progdefaults.HamlibWriteDelay = value;
2361 		progdefaults.changed = true;
2362 	}
2363 
2364 	return error;
2365 #else
2366 	return script_no_errors;
2367 #endif // USE_HAMLIB
2368 }
2369 
2370 /** ********************************************************
2371  * \brief
2372  * \param sp Access to ScritpParsing members.
2373  * \param sc Access to SCRIPT_COMMANDS structure variables.
2374  * \return 0 (no error) Other (error)
2375  ***********************************************************/
process_hamlib_post_write_delay(ScriptParsing * sp,SCRIPT_COMMANDS * sc)2376 int process_hamlib_post_write_delay(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
2377 {
2378 #if USE_HAMLIB
2379 	int value = 0;
2380 	int error = assign_integer(cntHamlibWait, sp, sc, value);
2381 
2382 	if(!error && cntHamlibWait) {
2383 		progdefaults.HamlibWait = value;
2384 		progdefaults.changed = true;
2385 	}
2386 
2387 	return error;
2388 #else
2389 	return script_no_errors;
2390 #endif // USE_HAMLIB
2391 }
2392 
2393 /** ********************************************************
2394  * \brief
2395  * \param sp Access to ScritpParsing members.
2396  * \param sc Access to SCRIPT_COMMANDS structure variables.
2397  * \return 0 (no error) Other (error)
2398  * \par Note:
2399  * This string storage can be assigned to anything. User
2400  * should follow the limitations imposed by the rules
2401  * of the host country.
2402  ***********************************************************/
process_hamlib_device_path(ScriptParsing * sp,SCRIPT_COMMANDS * sc)2403 int process_hamlib_device_path(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
2404 {
2405 #if USE_HAMLIB
2406 	// Not suitable for assign_xxxx
2407 	if(!sp || !sc)
2408 		return script_function_parameter_error;
2409 
2410 	std::string str_data = "";
2411 
2412 	if(sc->argc > 0)
2413 		str_data.assign(sc->args[0]);
2414 
2415 	if(str_data.empty())
2416 		return script_invalid_parameter;
2417 
2418 	if(!inpRIGdev)
2419 		return script_no_errors;
2420 
2421 	int index = inpRIGdev->find_index(str_data.c_str());
2422 	if(index < 0)
2423 		return script_invalid_parameter;
2424 
2425 	progdefaults.HamRigDevice.assign(str_data);
2426 	progdefaults.changed = true;
2427 
2428 	inpRIGdev->value(str_data.c_str());
2429 	inpRIGdev->do_callback();
2430 
2431 #endif // USE_HAMLIB
2432 
2433 	return script_no_errors;
2434 }
2435 
2436 /** ********************************************************
2437  * \brief
2438  * \param sp Access to ScritpParsing members.
2439  * \param sc Access to SCRIPT_COMMANDS structure variables.
2440  * \return 0 (no error) Other (error)
2441  ***********************************************************/
process_hamlib_baud_rate(ScriptParsing * sp,SCRIPT_COMMANDS * sc)2442 int process_hamlib_baud_rate(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
2443 {
2444 #if USE_HAMLIB
2445 	int index = 0;
2446 	int error = assign_index(listbox_baudrate, sp, sc, index);
2447 
2448 	if(!error && listbox_baudrate) {
2449 		progdefaults.HamRigBaudrate = index;
2450 		progdefaults.changed = true;
2451 	}
2452 	return error;
2453 #else
2454 	return script_no_errors;
2455 #endif // USE_HAMLIB
2456 }
2457 
2458 /** ********************************************************
2459  * \brief
2460  * \param sp Access to ScritpParsing members.
2461  * \param sc Access to SCRIPT_COMMANDS structure variables.
2462  * \return 0 (no error) Other (error)
2463  ***********************************************************/
process_hamlib_stop_bits(ScriptParsing * sp,SCRIPT_COMMANDS * sc)2464 int process_hamlib_stop_bits(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
2465 {
2466 #if USE_HAMLIB
2467 	int value = 0;
2468 	int error = assign_integer(valHamRigStopbits, sp, sc, value);
2469 
2470 	if(!error && valHamRigStopbits) {
2471 		progdefaults.HamRigStopbits = value;
2472 		progdefaults.changed = true;
2473 	}
2474 	return error;
2475 #else
2476 	return script_no_errors;
2477 #endif // USE_HAMLIB
2478 }
2479 
2480 /** ********************************************************
2481  * \brief
2482  * \param sp Access to ScritpParsing members.
2483  * \param sc Access to SCRIPT_COMMANDS structure variables.
2484  * \return 0 (no error) Other (error)
2485  ***********************************************************/
process_hamlib_poll_rate(ScriptParsing * sp,SCRIPT_COMMANDS * sc)2486 int process_hamlib_poll_rate(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
2487 {
2488 #if USE_HAMLIB
2489 	int value = 0;
2490 	int error = assign_integer(valHamRigPollrate, sp, sc, value);
2491 
2492 	if(!error && valHamRigPollrate) {
2493 		progdefaults.HamRigPollrate = value;
2494 		progdefaults.changed = true;
2495 	}
2496 	return error;
2497 #else
2498 	return script_no_errors;
2499 #endif // USE_HAMLIB
2500 }
2501 
2502 /** ********************************************************
2503  * \brief
2504  * \param sp Access to ScritpParsing members.
2505  * \param sc Access to SCRIPT_COMMANDS structure variables.
2506  * \return 0 (no error) Other (error)
2507  ***********************************************************/
process_hamlib_sideband(ScriptParsing * sp,SCRIPT_COMMANDS * sc)2508 int process_hamlib_sideband(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
2509 {
2510 #if USE_HAMLIB
2511 	int index = 0;
2512 	int error = assign_index(listbox_sideband, sp, sc, index);
2513 
2514 	if(!error && listbox_sideband) {
2515 		progdefaults.HamlibSideband = index;
2516 		progdefaults.changed = true;
2517 	}
2518 	return error;
2519 #else
2520 	return script_no_errors;
2521 #endif // USE_HAMLIB
2522 }
2523 
2524 /** ********************************************************
2525  * \brief
2526  * \param sp Access to ScritpParsing members.
2527  * \param sc Access to SCRIPT_COMMANDS structure variables.
2528  * \return 0 (no error) Other (error)
2529  ***********************************************************/
process_hamlib_ptt_hl_command(ScriptParsing * sp,SCRIPT_COMMANDS * sc)2530 int process_hamlib_ptt_hl_command(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
2531 {
2532 #if USE_HAMLIB
2533 	bool value = 0;
2534 	int error = assign_bool(btnHamlibCMDptt, sp, sc, value);
2535 
2536 	if(!error && btnHamlibCMDptt) {
2537 		progdefaults.HamlibCMDptt = value;
2538 		progdefaults.changed = true;
2539 	}
2540 	return error;
2541 #else
2542 	return script_no_errors;
2543 #endif // USE_HAMLIB
2544 }
2545 
2546 /** ********************************************************
2547  * \brief
2548  * \param sp Access to ScritpParsing members.
2549  * \param sc Access to SCRIPT_COMMANDS structure variables.
2550  * \return 0 (no error) Other (error)
2551  ***********************************************************/
process_hamlib_dtr_12(ScriptParsing * sp,SCRIPT_COMMANDS * sc)2552 int process_hamlib_dtr_12(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
2553 {
2554 #if USE_HAMLIB
2555 	bool value = 0;
2556 	int error = assign_bool(btnHamlibDTRplus, sp, sc, value);
2557 
2558 	if(!error && btnHamlibDTRplus) {
2559 		progdefaults.HamlibDTRplus = value;
2560 		progdefaults.changed = true;
2561 	}
2562 	return error;
2563 #else
2564 	return script_no_errors;
2565 #endif // USE_HAMLIB
2566 }
2567 
2568 /** ********************************************************
2569  * \brief
2570  * \param sp Access to ScritpParsing members.
2571  * \param sc Access to SCRIPT_COMMANDS structure variables.
2572  * \return 0 (no error) Other (error)
2573  ***********************************************************/
process_hamlib_rts_12(ScriptParsing * sp,SCRIPT_COMMANDS * sc)2574 int process_hamlib_rts_12(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
2575 {
2576 #if USE_HAMLIB
2577 	// Not suitable for assign_xxxx
2578 	if(!sp || !sc)
2579 		return script_function_parameter_error;
2580 
2581 	bool value = 0;
2582 	int error = sp->check_bool(sc->args[0], value);
2583 
2584 	if(error != script_no_errors)
2585 		return error;
2586 
2587 	if(!chkHamlibRTSCTSflow || !chkHamlibRTSplus)
2588 		return script_no_errors;
2589 
2590 	if(chkHamlibRTSCTSflow->value())
2591 		value = false;
2592 
2593 	progdefaults.HamlibRTSplus = value;
2594 	progdefaults.changed = true;
2595 
2596 	chkHamlibRTSplus->value(value);
2597 	chkHamlibRTSplus->do_callback();
2598 
2599 #endif // USE_HAMLIB
2600 
2601 	return script_no_errors;
2602 }
2603 
2604 /** ********************************************************
2605  * \brief
2606  * \param sp Access to ScritpParsing members.
2607  * \param sc Access to SCRIPT_COMMANDS structure variables.
2608  * \return 0 (no error) Other (error)
2609  ***********************************************************/
process_hamlib_rts_cts_flow(ScriptParsing * sp,SCRIPT_COMMANDS * sc)2610 int process_hamlib_rts_cts_flow(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
2611 {
2612 #if USE_HAMLIB
2613 	bool value = 0;
2614 	int error = assign_bool(chkHamlibRTSCTSflow, sp, sc, value);
2615 
2616 	if(!error && chkHamlibRTSCTSflow) {
2617 		progdefaults.HamlibRTSCTSflow = value;
2618 		progdefaults.changed = true;
2619 	}
2620 	return error;
2621 #else
2622 	return script_no_errors;
2623 #endif // USE_HAMLIB
2624 }
2625 
2626 /** ********************************************************
2627  * \brief
2628  * \param sp Access to ScritpParsing members.
2629  * \param sc Access to SCRIPT_COMMANDS structure variables.
2630  * \return 0 (no error) Other (error)
2631  ***********************************************************/
process_hamlib_xon_xoff_flow(ScriptParsing * sp,SCRIPT_COMMANDS * sc)2632 int process_hamlib_xon_xoff_flow(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
2633 {
2634 #if USE_HAMLIB
2635 	bool value = 0;
2636 	int error = assign_bool(chkHamlibXONXOFFflow, sp, sc, value);
2637 
2638 	if(!error && chkHamlibXONXOFFflow) {
2639 		progdefaults.HamlibXONXOFFflow = value;
2640 		progdefaults.changed = true;
2641 	}
2642 	return error;
2643 #else
2644 	return script_no_errors;
2645 #endif // USE_HAMLIB
2646 }
2647 
2648 /** ********************************************************
2649  * \brief
2650  * \param sp Access to ScritpParsing members.
2651  * \param sc Access to SCRIPT_COMMANDS structure variables.
2652  * \return 0 (no error) Other (error)
2653  ***********************************************************/
process_hamlib_advanced_config(ScriptParsing * sp,SCRIPT_COMMANDS * sc)2654 int process_hamlib_advanced_config(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
2655 {
2656 #if USE_HAMLIB
2657 	std::string value = "";
2658 	int error = assign_string(inpHamlibConfig, sp, sc, value);
2659 
2660 	if(!error && inpHamlibConfig) {
2661 		progdefaults.HamConfig.assign(value);
2662 		progdefaults.changed = true;
2663 	}
2664 	return error;
2665 #else
2666 	return script_no_errors;
2667 #endif // USE_HAMLIB
2668 }
2669 
2670 /** ********************************************************
2671  * \brief Initialize HAMLIB Parameters
2672  * \param sp Access to ScritpParsing members.
2673  * \param sc Access to SCRIPT_COMMANDS structure variables.
2674  * \return 0 (no error) Other (error)
2675  ***********************************************************/
process_hamlib_initialize(ScriptParsing * sp,SCRIPT_COMMANDS * sc)2676 int process_hamlib_initialize(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
2677 {
2678 #if USE_HAMLIB
2679 
2680 	if(!btnInitHAMLIB)
2681 		return script_no_errors;
2682 
2683 	btnInitHAMLIB->do_callback();
2684 
2685 #endif // USE_HAMLIB
2686 
2687 	return script_no_errors;
2688 }
2689 
2690 /** ********************************************************
2691  * \brief Assign Macro information to there respective
2692  * macro button.
2693  * \param sp Access to ScritpParsing members.
2694  * \param sc Access to SCRIPT_COMMANDS structure variables.
2695  * \return 0 (no error) Other (error)
2696  ***********************************************************/
process_load_macro(ScriptParsing * sp,SCRIPT_COMMANDS * sc)2697 int process_load_macro(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
2698 {
2699 	// Not suitable for assign_xxxx
2700 	if(!sp || !sc)
2701 		return script_function_parameter_error;
2702 
2703 	std::string macro_data = sp->macro_command();
2704 	std::string macro_label = "";
2705 
2706 	int col = 0;
2707 	int row = 0;
2708 	int index = 0;
2709 
2710 	if(sc->argc < 3) return script_invalid_parameter;
2711 
2712 	if((!sc->args[0]) || (!sc->args[1]) || (!sc->args[2]))
2713 		return script_invalid_parameter;
2714 
2715 	index = sscanf(sc->args[0], "%d", &col);
2716 	if(index < 1)
2717 		return script_invalid_parameter;
2718 
2719 	index = sscanf(sc->args[1], "%d", &row);
2720 	if(index < 1)
2721 		return script_invalid_parameter;
2722 
2723 	macro_label.assign(sc->args[2]);
2724 	if(macro_label.empty())
2725 		return script_invalid_parameter;
2726 
2727 	if(col > 0) col--;
2728 	if(row > 0) row--;
2729 
2730 	index = (col * NUMMACKEYS) + row;
2731 
2732 	if((index < 0) || (index > MAXMACROS))
2733 		return script_invalid_parameter;
2734 
2735 	if((col == 0) || ((col == altMacros) && (progdefaults.mbar_scheme > MACRO_SINGLE_BAR_MAX))) {
2736 		update_macro_button(index, macro_data.c_str(), macro_label.c_str());
2737 	} else {
2738 		macros.text[index].assign(macro_data);
2739 		macros.name[index].assign(macro_label);
2740 	}
2741 
2742 	return script_no_errors;
2743 }
2744 
2745 /** ********************************************************
2746  * \brief Reset Configuration panel attributes
2747  * \param sp Access to ScritpParsing members.
2748  * \param sc Access to SCRIPT_COMMANDS structure variables.
2749  * \return 0 (no error) Other (error)
2750  ***********************************************************/
process_reset(ScriptParsing * sp,SCRIPT_COMMANDS * sc)2751 int process_reset(ScriptParsing *sp, SCRIPT_COMMANDS *sc)
2752 {
2753 	return script_no_errors;
2754 }
2755 
2756 /** ********************************************************
2757  * \brief Pass script file name to script passing class
2758  * for execution.
2759  * Called from the File->Execute Config Script menu item.
2760  * \param void
2761  ***********************************************************/
script_execute(const char * filename,bool queue_flag)2762 static void script_execute(const char *filename, bool queue_flag)
2763 {
2764 
2765 	ScriptParsing *sp = 0;
2766 	static std::string script_filename = "";
2767 
2768 	if(!filename) {
2769 		LOG_INFO(_("Script file name (path) null pointer"));
2770 		return;
2771 	}
2772 
2773 	script_filename.assign(filename);
2774 
2775 	if(script_filename.empty()) {
2776 		LOG_INFO(_("Script file name (path) invalid"));
2777 		return;
2778 	}
2779 
2780 	sp = new ScriptParsing;
2781 
2782 	if(!sp) {
2783 		LOG_INFO(_("Script Parsing Class Allocation Fail (%s)"), script_filename.c_str());
2784 		return;
2785 	}
2786 
2787 	LOG_INFO(_("Executing script file: %s"), script_filename.c_str());
2788 
2789 	sp->parse_commands((char *) script_filename.c_str());
2790 
2791 	if(sp->script_errors()) {
2792 		LOG_INFO(_("Issues reported in processing script file: %s"), script_filename.c_str());
2793 		fl_alert("%s", _("Script file contains potential issues\nSee documentation and/or Log file for details."));
2794 	}
2795 
2796 	if(sp->restart_flag()) {
2797 		fl_alert("%s", _("Some changes made by the script requires program\nrestart before they become active."));
2798 	}
2799 
2800 	if(sp)
2801 		delete sp;
2802 }
2803 
2804 /** ********************************************************
2805  * \brief Call back function when executing a configuration script.
2806  * Called from the File->Execute Config Script menu item.
2807  * \param void
2808  ***********************************************************/
cb_scripts(bool reset_path=false)2809 void cb_scripts(bool reset_path = false)
2810 {
2811 	pthread_mutex_lock(&mutex_script_io);
2812 
2813 	static bool first_time = true;
2814 	static char script_filename[FL_PATH_MAX + 1];
2815 	std::string new_path = "";
2816 
2817 	if(reset_path || first_time) {
2818 		memset(script_filename, 0, sizeof(script_filename));
2819 		strncpy(script_filename, ScriptsDir.c_str(), FL_PATH_MAX);
2820 		int len = strnlen(script_filename, FL_PATH_MAX);
2821 
2822 		if(len > 0) {
2823 			len--;
2824 			if(script_filename[len] == PATH_CHAR_SEPERATOR);
2825 			else strncat(script_filename, PATH_SEPERATOR, FL_PATH_MAX);
2826 		} else {
2827 			return;
2828 		}
2829 
2830 		first_time = false;
2831 	}
2832 
2833 	const char *p = FSEL::select((char *)_("Script Files"), (char *)_("*.txt"), \
2834 								 script_filename);
2835 
2836 	if(p) {
2837 		memset(script_filename, 0, sizeof(script_filename));
2838 		strncpy(script_filename, p, FL_PATH_MAX);
2839 
2840 		Fl::lock();
2841 		script_execute(script_filename, false);
2842 		Fl::unlock();
2843 
2844 	}
2845 
2846 	pthread_mutex_unlock(&mutex_script_io);
2847 }
2848