Skip to content

Commit

Permalink
Merge new startup code for better readability by user.
Browse files Browse the repository at this point in the history
- 'verbose' startup mode does no longer slow down display of messages but requires a
  key press before clearing the screen. That gives a better chance to read all the messages
  and sort out possible problems.

- If started in empty directory (new contest or first start by new user) it switches
  automatically to verbose mode.
  • Loading branch information
dl1jbe committed Sep 30, 2019
2 parents 0524cf5 + ddc2350 commit 766e0f4
Show file tree
Hide file tree
Showing 14 changed files with 194 additions and 173 deletions.
6 changes: 0 additions & 6 deletions src/checkparameters.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,11 @@


int checkparameters(void) {

extern int emptydir;

FILE *fp;

if ((fp = fopen(".paras", "r")) == NULL) {
writeparas_file();
emptydir = 1;

} else {

fclose(fp);
}

Expand Down
47 changes: 7 additions & 40 deletions src/getmessages.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "ignore_unused.h"
#include "tlf_curses.h"


/* get countrynumber, QTH, CQ zone and continent for myself */
void getstationinfo() {
extern char call[];
Expand All @@ -57,7 +58,8 @@ void getstationinfo() {
QTH_Long = mydx->lon;
}

int getmessages(void) {

void getmessages(void) {

extern char call[];
extern char mycqzone[];
Expand All @@ -66,7 +68,6 @@ int getmessages(void) {
extern int qsonum;
extern char qsonrstr[];
extern char backgrnd_str[];
extern int emptydir;

FILE *fp;

Expand All @@ -91,6 +92,7 @@ int getmessages(void) {
printw("\nError opening logfile.\nExiting...\n");
refreshp();
sleep(5);
endwin();
exit(1);
}

Expand All @@ -99,7 +101,6 @@ int getmessages(void) {
ii = 5 - i;

if (fseek(fp, -1L * i * LOGLINELEN, SEEK_END) == 0) {

IGNORE(fgets(logline[ii], 85, fp));;
} else {
strncpy(logline[ii], backgrnd_str, 81);
Expand All @@ -110,6 +111,9 @@ int getmessages(void) {
logline[ii][79] = 32;
}

fclose(fp);


strncpy(qsonrstr, logline[4] + 23, 4);
qsonrstr[4] = '\0';

Expand Down Expand Up @@ -146,41 +150,4 @@ int getmessages(void) {
strncpy(logline4, logline[4], 80);
else
strcpy(logline4, backgrnd_str);

refreshp();

fclose(fp);

if (emptydir == 1) {

printw("\n");
printw(" TTTTT L FFFFF\n");
printw(" T L F \n");
printw(" T L FFFFF\n");
printw(" T L F \n");
printw(" T LLLLL F \n");
printw
("\n\n This program is copyright 2002, 2003, 2004 by Rein Couperus, PA0R\n\n");
printw
(" It is free software; you can redistribute it and/or modify");
printw
(" it under the terms of the GNU General Public License as published by");
printw
(" the Free Software Foundation; either version 2 of the License, or");
printw(" (at your option) any later version.\n\n");
printw
(" This program is distributed in the hope that it will be useful,");
printw
(" but WITHOUT ANY WARRANTY; without even the implied warranty of");
printw
(" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. �See the");
printw(" GNU General Public License for more details.\n");

refreshp();

sleep(5);
}

return (0);

}
2 changes: 1 addition & 1 deletion src/getmessages.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
#define GETMESSAGES_H

void getstationinfo(void);
int getmessages(void);
void getmessages(void);

#endif /* GETMESSAGES_H */
6 changes: 3 additions & 3 deletions src/getwwv.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ int getwwv(void) {
strftime(timebuff, 80, "%H:%M", ptr1);

mvprintw(LINES - 1, LINELENGTH - 17, " local time %s", timebuff);
}

printcall();
refreshp();
}
}
return (0);
return 0;
}
86 changes: 63 additions & 23 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ int isdupe = 0; // 0 if nodupe -- for auto qso b4 (LZ3NY)
int nob4 = 0; // allow auto b4
int ignoredupe = 0;
int noautocq = 0;
int emptydir = 0;
int verbose = 0;
int no_rst = 0; /* 1 - do not use RS/RST */
char myqra[7] = "";
Expand Down Expand Up @@ -571,26 +570,25 @@ void ui_init() {
char c;

showmsg("!! TLF needs at least 25 lines and 80 columns !!");
showmsg(" Continue anyway? Y/(N)");
showmsg(" Continue anyway? Y/(N) ");
c = toupper(key_get());
if (c != 'Y') {
showmsg("73 es cuagn");
sleep(1);
endwin();
exit(EXIT_FAILURE);
}
showmsg("");
clearmsg();
}

if (!has_colors() || (start_color() == ERR)) {
showmsg("Sorry, terminal does not support color");
showmsg("Try TERM=linux or use a text console !!");
sleep(2);
sleep(1);
endwin();
exit(EXIT_FAILURE);
}


refreshp();

noecho();
Expand Down Expand Up @@ -642,10 +640,10 @@ void ui_color_init() {
int databases_load() {
int status;

showmsg("reading country data");
showmsg("Reading country data");
readctydata(); /* read ctydb.dat */

showmsg("reading configuration data");
showmsg("Reading configuration data");
status = read_logcfg(); /* read the configuration file */
status |= read_rules(); /* read the additional contest rules
in "rules/contestname" */
Expand All @@ -659,27 +657,25 @@ int databases_load() {

if (*call == '\0') {
showmsg
("WARNING: No callsign defined in logcfg.dat! exiting...\n\n\n");
("WARNING: No callsign defined in logcfg.dat! exiting...\n");
return EXIT_FAILURE;
}


if (multlist == 1) {
showmsg("reading multiplier data ");
showmsg("Reading multiplier data ");
if (strlen(multsfile) == 0) {
mvprintw(9, 0, "No multiplier file specified, exiting.. !!\n");
refreshp();
sleep(5);
exit(1);
showmsg("No multiplier file specified, exiting.. !!");
return EXIT_FAILURE;
}
}
init_and_load_multipliers();

showmsg("reading callmaster data");
showmsg("Reading callmaster data");
load_callmaster();

if (*exchange_list != '\0') {
showmsg("reading initial exchange file");
showmsg("Reading initial exchange file");
main_ie_list = make_ie_list(exchange_list);

if (main_ie_list == NULL) {
Expand Down Expand Up @@ -834,6 +830,44 @@ void keyer_init() {
}


void show_GPL() {
printw("\n\n\n");
printw(" TTTTT L FFFFF\n");
printw(" T L F \n");
printw(" T L FFFFF\n");
printw(" T L F \n");
printw(" T LLLLL F \n");
printw
("\n\nThis program is copyright 2002, 2003, 2004 by Rein Couperus, PA0R\n\n");
printw
("It is free software; you can redistribute it and/or modify it under the terms\n");
printw
("of the GNU General Public License as published by the Free Software Foundation;\n");
printw
("either version 2 of the License, or (at your option) any later version.\n\n");
printw
("This program is distributed in the hope that it will be useful, but\n");
printw
("WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\n");
printw
("or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License\n");
printw
("for more details.\n");

refreshp();
}


int isFirstStart() {
FILE *fp;

if ((fp = fopen(".paras", "r")) == NULL) {
return 1;
}
fclose(fp);

return 0;
}

/** cleanup function
*
Expand Down Expand Up @@ -898,6 +932,15 @@ int main(int argc, char *argv[]) {
hiscall[0] = '\0';


if (isFirstStart()) {
/* first time called in this directory */
verbose = 1;
printw(welcome);
show_GPL();
sleep(5);
clear();
}

showmsg(welcome);
showmsg("");

Expand Down Expand Up @@ -935,19 +978,15 @@ int main(int argc, char *argv[]) {
lan_init();
keyer_init();

clear();
mvprintw(0, 0, welcome);
refreshp();
nr_qsos = readcalls(); /* read the logfile for score and dupe */

checkparameters(); /* check .paras file */
getmessages(); /* read .paras file */

packet_init();
getwwv(); /* get the latest wwv info from packet */

scroll_log(); /* read the last 5 log lines and set the qso number */

nr_qsos = readcalls(); /* read the logfile for score and dupe */
clearmsg_wait();

packet_init();

clear_display(); /* tidy up the display */
attron(COLOR_PAIR(C_LOG) | A_STANDOUT);
Expand All @@ -956,6 +995,7 @@ int main(int argc, char *argv[]) {
}
refreshp();

getwwv(); /* get the latest wwv info from packet */
bm_init(); /* initialize bandmap */

atexit(tlf_cleanup); /* register cleanup function */
Expand Down
Loading

0 comments on commit 766e0f4

Please sign in to comment.