Пример #1
0
Файл: main.c Проект: airween/tlf
int main(int argc, char *argv[]) {
    int j;
    int ret;
    char tlfversion[80] = "";

    parse_options(argc, argv);

    ui_init();


    strcat(logline0, backgrnd_str);
    strcat(logline1, backgrnd_str);
    strcat(logline2, backgrnd_str);
    strcat(logline3, backgrnd_str);
    strcat(logline4, backgrnd_str);

    strcat(terminal1, backgrnd_str);
    strcat(terminal2, backgrnd_str);
    strcat(terminal3, backgrnd_str);
    strcat(terminal4, backgrnd_str);

    termbuf[0] = '\0';
    hiscall[0] = '\0';


    sprintf(tlfversion,
	    "        Welcome to tlf-%s by PA0R!!", VERSION);
    showmsg(tlfversion);
    showmsg("");

    total = 0;
    if (databases_load() == EXIT_FAILURE) {
	sleep(2);
	endwin();
	exit(EXIT_FAILURE);
    }

    if (convert_cabrillo == 1) {
	char tstring[100] = "";
	sprintf(tstring, "Converting cabrillo for contest %s from file %s.cbr",
		whichcontest, g_strstrip(call));
	showmsg(tstring);
	showmsg("");
	getstationinfo();
	if (0 != readcabrillo(READCAB_MODE_CLI))
	    showmsg("Sorry. Conversion failed....");
	else
	    showmsg("Done...");
	sleep(2);
	endwin();
	exit(EXIT_SUCCESS);
    }

    /* now setup colors */
    ui_color_init();

//              if (strlen(synclogfile) > 0)
//                      synclog(synclogfile);

    hamlib_init();
    fldigi_init();
    lan_init();
    keyer_init();

    clear();
    mvprintw(0, 0, "        Welcome to tlf-%s by PA0R!!\n\n", VERSION);
    refreshp();

    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 */

    clear_display();		/* tidy up the display */
    attron(COLOR_PAIR(C_LOG) | A_STANDOUT);
    for (j = 13; j <= 23; j++) {	/* wipe lower window */
	mvprintw(j, 0, backgrnd_str);
    }
    refreshp();

    bm_init();			/* initialize bandmap */

    atexit(tlf_cleanup); 	/* register cleanup function */

    /* Create the background thread */
    ret = pthread_create(&background_thread, NULL, background_process, NULL);
    if (ret) {
	perror("pthread_create: backgound_process");
	endwin();
	exit(EXIT_FAILURE);
    }

    /* now start logging  !! Does never return */
    logit();

    return 0;
}
Пример #2
0
int changepars(void)
{
    extern int use_rxvt;
    extern int cluster;
    extern int shortqsonr;
    extern int searchflg;
    extern int demode;
    extern int contest;
    extern int announcefilter;
    extern int showscore_flag;
    extern int zonedisplay;
    extern int trxmode;
    extern char hiscall[];
    extern int rit;
    extern int trx_control;
    extern int editor;
    extern int packetinterface;
    extern int nopacket;
    extern int cqdelay;
    extern int ctcomp;
    extern SCREEN *mainscreen;
    extern char *config_file;
    extern int miniterm;
    extern char buffer[];

#ifdef HAVE_LIBHAMLIB
    extern freq_t outfreq;
#else
    extern int outfreq;
#endif

    extern int simulator;
    extern int keyerport;
    extern char synclogfile[];
    extern char sc_volume[];
    extern int cwstart;

    char parameterstring[20];
    char parameters[51][19];
    char cmdstring[80];
    int i, k, x, nopar = 0;
    int maxpar = 50;
    int volumebuffer;
    int currentmode = 0;
    int rc;

    strcpy(parameters[0], "SPOT");
    strcpy(parameters[1], "MAP");
    strcpy(parameters[2], "CLOFF");
    strcpy(parameters[3], "CLUSTER");
    strcpy(parameters[4], "SHORT");
    strcpy(parameters[5], "LONG");
    strcpy(parameters[6], "MESSAGE");
    strcpy(parameters[7], "LIST");
    strcpy(parameters[8], "CHECK");
    strcpy(parameters[9], "NOCHECK");
    strcpy(parameters[10], "TONE");
    strcpy(parameters[11], "EDIT");
    strcpy(parameters[12], "VIEW");
    strcpy(parameters[13], "HELP");
    strcpy(parameters[14], "DEMODE");
    strcpy(parameters[15], "CONTEST");
    strcpy(parameters[16], "FILTER");
    strcpy(parameters[17], "SCORE");
    strcpy(parameters[18], "WRITE");
    strcpy(parameters[19], "EXIT");
    strcpy(parameters[20], "TXFILE");
    strcpy(parameters[21], "ZONES");
    strcpy(parameters[22], "CTY");
    strcpy(parameters[23], "MODE");
    strcpy(parameters[24], "SET");
    strcpy(parameters[25], "MULTI");
    strcpy(parameters[26], "PROP");
    strcpy(parameters[27], "RITCLEAR");
    strcpy(parameters[28], "TRXCONTROL");
    strcpy(parameters[29], "CFG");
    //strcpy(parameters[30],  "CWMODE");
    strcpy(parameters[30], "CW");
    strcpy(parameters[31], "SSBMODE");
    strcpy(parameters[32], "DIGIMODE");
    strcpy(parameters[33], "PACKET");
    strcpy(parameters[34], "SIMULATOR");
    strcpy(parameters[35], "INFO");
    strcpy(parameters[36], "FREQ");
    strcpy(parameters[37], "RECONNECT");
    strcpy(parameters[38], "QUIT");
    strcpy(parameters[39], "CQDELAY");
    strcpy(parameters[40], "ADIF");
    strcpy(parameters[41], "SYNC");
    strcpy(parameters[42], "RESCORE");
    strcpy(parameters[43], "SCVOLUME");
    strcpy(parameters[44], "SCAN");
    strcpy(parameters[45], "DEBUG");
    strcpy(parameters[46], "MINITERM");
    strcpy(parameters[47], "RTTY");
    strcpy(parameters[48], "SOUND");
    strcpy(parameters[49], "CWMODE");
    strcpy(parameters[50], "CHARS");

    nopar = 0;

    attroff(A_STANDOUT);
    attron(COLOR_PAIR(C_HEADER));
    mvprintw(12, 29, "PARAMETER?  ");
    refreshp();

    mvprintw(12, 29, "            ");
    mvprintw(12, 29, "");
    refreshp();

    echo();
    getstr(parameterstring);
    noecho();

    for (k = 0; parameterstring[k]; k++)
	parameterstring[k] = toupper(parameterstring[k]);

    for (i = 0; i <= maxpar; i++) {
	if (strncmp(parameterstring, parameters[i], 3) == 0) {
	    break;
	}
    }

    switch (i) {
    case 0:			/* SPOTS) */
	{
	    /* SPOTS not supported anymore
	     * - default to MAP*/
	    cluster = MAP;
	    break;
	}
    case 1:			/* BANDMAP */
	{
	    cluster = MAP;
	    break;
	}
    case 2:			/* CLOFF  */
	{
	    cluster = NOCLUSTER;
	    break;
	}
    case 3:			/* CLUSTER  */
	{
	    cluster = CLUSTER;
	    announcefilter = FILTER_ALL;
	    break;
	}
    case 4:			/* SHORTNR  */
	{
	    shortqsonr = SHORTCW;
	    break;
	}
    case 5:			/* LONGNR  */
	{
	    shortqsonr = LONGCW;
	    break;
	}
    case 6:			/* MESSAGE  */
	{
	    message_change(i);
	    break;
	}

    case 7:			/* LIST  */
	{
	    listmessages();
	    break;
	}
    case 8:			/* CHECK  */
	{
	    searchflg = SEARCHWINDOW;
	    break;
	}
    case 9:			/* NOCHECK  */
	{
	    searchflg = 0;
	    break;
	}
    case 10:			/*  TONE   */
	{
	    set_tone();
	    break;
	}
    case 11:			/*  EDIT   */
	{
	    logedit();
	    break;
	}
    case 12:			/*  VIEW   */
	{
	    logview();
	    break;
	}
    case 13:			/*  HELP   */
	{
	    show_help();
	    break;
	}
    case 14:			/*  DEMODE   */
	{
	    if (demode == SEND_DE)
		demode = 0;
	    else
		demode = SEND_DE;
	    mvprintw(13, 29, "DE-mode is %d", demode);
	    refreshp();
	    sleep(1);

	    break;
	}
    case 15:			/*  CONTEST   */
	{
	    if (contest == CONTEST)
		contest = 0;
	    else {
		contest = CONTEST;
		searchflg = SEARCHWINDOW;
	    }
	    mvprintw(13, 29, "CONTEST-mode is %d", contest);
	    refreshp();
	    sleep(1);

	    break;
	}
    case 16:			/*  FILTER   */
	{
	    announcefilter++;
	    if (announcefilter > 3)
		announcefilter = 0;
	    mvprintw(13, 29, "FILTER-mode is %d", announcefilter);
	    refreshp();
	    sleep(1);

	    break;
	}
    case 17:			/*  SCORE   */
	{
	    if (showscore_flag == 0)
		showscore_flag = 1;
	    else {
		showscore_flag = 0;

	    }
	    mvprintw(13, 29, "Show score-mode is %d", showscore_flag);
	    refreshp();
	    sleep(1);

	    break;
	}
    case 18:			/*  WRITE CABRILLO FILE   */
	{
	    int old_cluster = cluster;
	    cluster = NOCLUSTER;

	    write_cabrillo();

	    cluster = old_cluster;


	    break;
	}
    case 19:			/* EXIT */
	{
	    writeparas();
	    clear();
	    cleanup_telnet();
	    endwin();
	    puts("\n\nThanks for using TLF.. 73\n");
	    exit(0);
	    break;
	}
    case 20:			/*  TXFILE   */
	{
	    break;
	}
    case 21:			/*  ZONES   */
	{
	    if (zonedisplay == 0)
		zonedisplay = 1;
	    else {
		zonedisplay = 0;

	    }

	    break;
	}
    case 22:			/* COUNTRIES */
	{
	    show_mults();
	    refreshp();
	    sleep(1);

	    break;
	}
    case 23:			/*  MODE   */
	{
	    if (trxmode == CWMODE)
		trxmode = SSBMODE;
	    else if (trxmode == SSBMODE)
		trxmode = DIGIMODE;
	    else
		trxmode = CWMODE;

	    if (trxmode == CWMODE) {
		mvprintw(13, 29, "TRXMODE = CW");
	    } else if (trxmode == SSBMODE)
		mvprintw(13, 29, "TRXMODE = SSB");
	    else
		mvprintw(13, 29, "TRXMODE = DIG");
	    refreshp();
	    sleep(1);

	    break;
	}
    case 24:			/* SET PARAMETERS */
    case 29:			/* CFG PARAMETERS */
	{
	    clear();
	    if (editor == EDITOR_JOE) {
		strcpy(cmdstring, "joe ");
	    } else if (editor == EDITOR_VI) {
		strcpy(cmdstring, "vi ");
	    } else if (editor == EDITOR_MC) {
		strcpy(cmdstring, "mcedit ");
	    } else {
		strcpy(cmdstring, "e3 ");
	    }

	    strcat(cmdstring, config_file);
	    rc = system(cmdstring);

	    read_logcfg();
	    read_rules();	/* also reread rules file */
	    writeparas();
	    mvprintw(24, 0, "Logcfg.dat loaded, parameters written..");
	    refreshp();
	    clear_display();
	    break;
	}
    case 25:			/*  MULTI   */
	{
	    multiplierinfo();

	    break;
	}
    case 26:			/* PROPAGATION */
	{
	    muf();
	    clear_display();
	    break;
	}
    case 27:			/*  RITCLEAR   */
	{
	    if (rit == RITCLEAR)
		rit = 0;
	    else {
		rit = RITCLEAR;

	    }
	    if (rit == RITCLEAR) {
		mvprintw(13, 29, "RIT clear on");
	    } else {
		mvprintw(13, 29, "RIT clear off");
	    }
	    refreshp();
	    sleep(1);

	    break;
	}
    case 28:			/*  trx ctl   */
	{
	    if (trx_control == 1)
		trx_control = 0;
	    else {
		trx_control = 1;

	    }
	    if (trx_control == 1) {
		mvprintw(13, 29, "TRX control on");
	    } else {
		mvprintw(13, 29, "TRX control off");
	    }
	    refreshp();
	    sleep(1);

	    break;
	}
    case 30:			/* CW  */
    case 49:
	{
	    if (keyerport == MFJ1278_KEYER) {
		strcpy(buffer, "MODE CW,30");
		buffer[7] = '\015';
		buffer[8] = 'K';
		buffer[9] = '\015';
		buffer[10] = '\0';
		sendbuf();
	    }
	    trxmode = CWMODE;

	    if (trx_control == 1)
		outfreq = SETCWMODE;
	    break;
	}
    case 31:			/* SSBMODE  */
	{
	    trxmode = SSBMODE;
	    outfreq = SETSSBMODE;
	    break;
	}
    case 32:			/* DIGIMODE  */
	{
	    trxmode = DIGIMODE;
	    break;
	}
    case 33:			/* PACKET  */
	{
	    if ((nopacket == 0) && (packetinterface > 0))
		packet();
	    break;
	}
    case 34:			/* SIMULATOR  */
	{
	    if (simulator == 0) {
		simulator = 1;
		if (ctcomp == 1) {
		    mvprintw(13, 19,
			     "The simulator only works in TRmode. Switching to TRmode");
		    ctcomp = 0;
		} else
		    mvprintw(13, 29, "Simulator on");

		refreshp();

		if (keyerport == NET_KEYER) {

		    if (netkeyer(K_WORDMODE, NULL) < 0) {
			mvprintw(24, 0,
				 "keyer not active; switching to SSB");
			trxmode = SSBMODE;
			clear_display();
		    }
		}
	    } else {
		simulator = 0;
		mvprintw(13, 29, "Simulator off");
		refreshp();

		if (keyerport == NET_KEYER) {

		    if (netkeyer(K_RESET, NULL) < 0) {
			mvprintw(24, 0,
				 "keyer not active; switching to SSB");
			trxmode = SSBMODE;
			clear_display();
		    }
		}

	    }
	    break;
	}
    case 35:			/* INFO  */
	{
	    int currentterm = miniterm;
	    miniterm = 0;
	    networkinfo();
	    miniterm = currentterm;

	    if (currentmode == DIGIMODE)
		trxmode = DIGIMODE;
	    break;
	}
    case 36:			/* CLOFF  */
	{
	    cluster = FREQWINDOW;
	    break;
	}

    case 37:			/* RECONNECT  */
	{
	    if ((nopacket == 0) && (packetinterface > 0)) {
		cleanup_telnet();
		init_packet();
		packet();
	    }
	    break;
	}

    case 38:			/* EXIT=QUIT */
	{
	    writeparas();
	    cleanup_telnet();
	    endwin();
	    puts("\n\nThanks for using TLF.. 73\n");
	    exit(0);
	    break;
	}
    case 39:			/* CQDELAY */
	{
	    mvprintw(12, 29, "CQD: pgup/dwn", cqdelay);
	    refreshp();

	    x = 1;
	    while (x) {
		x = onechar();

		switch (x) {
		case 156:{
			if (cqdelay <= 60) {
			    cqdelay++;
			    attron(COLOR_PAIR(C_HEADER) | A_STANDOUT);
			    mvprintw(0, 19, "  ");
			    mvprintw(0, 19, "%i", cqdelay);
			    break;

			}
		    }
		case 157:{
			if (cqdelay >= 1) {
			    cqdelay--;
			    attron(COLOR_PAIR(C_HEADER) | A_STANDOUT);

			    mvprintw(0, 19, "  ");
			    mvprintw(0, 19, "%i", cqdelay);
			    break;

			}
		default:
			x = 0;
		    }

		}
	    }

	    if (use_rxvt == 0)
		attron(COLOR_PAIR(NORMCOLOR) | A_BOLD);
	    else
		attron(COLOR_PAIR(NORMCOLOR));

	    mvprintw(12, 29 + strlen(hiscall), "");
	    break;

	}
    case 40:			/* ADIF */
	{
	    write_adif();

	    break;
	}
    case 41:			/* SYNC */
	{
	    if (strlen(synclogfile) > 0)
		synclog(synclogfile);
	    scroll_log();
	    /** \todo register return value */
	    readcalls();
	    clear_display();
	    break;
	}
    case 42:			/* RESCORE */
	{
	    /** \todo register return value */
	    readcalls();
	    clear_display();
	    break;
	}
    case 43:			/* SCVOLUME - set soundcard volume */
	{
	    volumebuffer = atoi(sc_volume);
	    mvprintw(12, 29, "Vol: pgup/dwn");
	    refreshp();
	    usleep(500000);
	    mvprintw(12, 29, "Vol:         ");
	    mvprintw(12, 29, "Vol: %d", volumebuffer);

	    x = 1;
	    while (x) {
		x = onechar();

		switch (x) {
		case 156:{
			if (volumebuffer < 95)
			    volumebuffer += 5;

			break;
		    }
		case 157:{
			if (volumebuffer >= 5)
			    volumebuffer -= 5;

			break;
		    }
		default:
			x = 0;

		}

		attron(COLOR_PAIR(COLOR_GREEN) | A_STANDOUT);
		mvprintw(12, 34, "  ");
		mvprintw(12, 34, "%d", volumebuffer);

		if (volumebuffer >= 0 && volumebuffer <= 99)
		    sprintf(sc_volume, "%d", volumebuffer);

		netkeyer(K_STVOLUME, sc_volume);
	    }

	    clear_display();
	    break;
	}
    case 44:			/* SCAN */
	{
	    int currentterm = miniterm;
	    miniterm = 0;
	    testaudio();
	    clear_display();
	    miniterm = currentterm;
	    break;
	}
    case 45:			/* DEBUG */
	{
	    debug_tty();
	    clear_display();
	    break;
	}
    case 46:			/* MINITERM ON/OFF */
	{
	    if (miniterm == 1)
		miniterm = 0;
	    else
		miniterm = 1;
	    break;
	}
    case 47:			/* RTTY Initialize mode (MFJ1278B controller) */
	{
	    strcpy(buffer, "MODE VB");
	    buffer[7] = '\015';
	    buffer[8] = 'K';
	    buffer[9] = '\015';
	    buffer[10] = '\0';
	    sendbuf();
	    trxmode = DIGIMODE;

	    break;
	}
    case 48:			/* SOUND */
	{
	    clear_display();
	    record();
	    clear_display();
	    break;
	}
    case 50:			/* CHARS */
	{
	    mvprintw(13, 29, "Autosend: (0 (off), 2..5 chars) ?");
	    refreshp();
	    x = 1;

	    /* wait for correct input or ESC */
	    while ((x != 0) && ((x < 2) || (x > 5)) ) {
		x = onechar();
		if (x == 27)
		    break;
		x = x - '0';
	    }

	    /* remember new setting */
	    if (x != 27)
		cwstart = x;

	    if (cwstart)
		mvprintw(13,29, "Autosend now: %1d                 ",
			cwstart);
	    else
		mvprintw(13,29, "Autosend now: OFF                ");

	    refreshp();
	    break;

	}
    default:
	{
	    nopar = 1;
	}
    }

    if (nopar != 1) {
	mvprintw(12, 29, "OK !        ");
	writeparas();
    } else {
	if ((nopacket ==0) && (packetinterface > 0))
	    packet();
    }

    refreshp();

    if (use_rxvt == 0)
	attron(COLOR_PAIR(NORMCOLOR) | A_BOLD);
    else
	attron(COLOR_PAIR(NORMCOLOR));

    mvprintw(12, 29, "            ");
    mvprintw(12, 29, "");
    refreshp();
    hiscall[0] = '\0';

    return (0);
}
Пример #3
0
Файл: main.c Проект: patlc/tlf
int main(int argc, char *argv[])
{
    int j;
    pthread_t thrd1, thrd2;
    int ret;
    int retval;
    char keyerbuff[3];
    char tlfversion[80] = "";
    int status;

    while ((argc > 1) && (argv[1][0] == '-')) {
	switch (argv[1][1]) {
	    /* verbose option */
	case 'f':
	    if (strlen(argv[1] + 2) > 0) {
		if ((*(argv[1] + 2) == '~') && (*(argv[1] + 3) == '/')) {
		    /* tilde expansion */
		    config_file = g_strconcat( g_get_home_dir(),
			    argv[1] + 3, NULL);
		}
	    	else {
		    config_file = g_strdup(argv[1] + 2);
		}
	    }
	    break;
	case 's':
	    if (strlen(argv[1] + 2) > 0)
		strcpy(synclogfile, argv[1] + 2);
	    break;
	case 'd':		// debug rigctl
	    debugflag = 1;
	    break;
	case 'v':		// verbose startup
	    verbose = 1;
	    break;
	case 'V':		// output version
	    printf("Version: tlf-%s\n", VERSION);
	    exit(0);
	    break;
	case 'n':		// output version
	    nopacket = 1;
	    break;
	default:
	    printf("Use: tlf [-v] Verbose\n");
	    printf("         [-V] Version\n");
	    printf("         [-f] Configuration file\n");
	    printf("         [-d] Debug mode\n");
	    printf("         [-h] This message\n");
	    printf("         [-n] Start without cluster hookup\n");
	    exit(0);
	    break;
	}
	--argc;
	++argv;
    }

    buffer[0] = '\0';
    buffer[79] = '\0';
    bufloc = 0;

    strcat(logline0, backgrnd_str);
    strcat(logline1, backgrnd_str);
    strcat(logline2, backgrnd_str);
    strcat(logline3, backgrnd_str);
    strcat(logline4, backgrnd_str);

    strcat(terminal1, backgrnd_str);
    strcat(terminal2, backgrnd_str);
    strcat(terminal3, backgrnd_str);
    strcat(terminal4, backgrnd_str);

    termbuf[0] = '\0';
    hiscall[0] = '\0';

/* getting users terminal string and (if RXVT) setting rxvt colours on it */
/* LZ3NY hack :) */
    if (strcasecmp(getenv("TERM"), "rxvt") == 0) {
	use_rxvt = 1;
	printf("terminal is:%s", getenv("TERM"));
    } else if (strcasecmp(getenv("TERM"), "xterm") == 0) {
	use_xterm = 1;
	use_rxvt = 1;
    } else
	putenv("TERM=rxvt");	/*or going to native console linux driver */

    if ((mainscreen = newterm(NULL, stdout, stdin)) == NULL) {	/* activate ncurses terminal control */
	perror("initscr");
	printf
	    ("\n Sorry, wrong terminal type !!!!! \nTry a  linux text terminal or set TERM=linux !!!");
	sleep(5);

	exit(EXIT_FAILURE);
    }
//keypad(stdscr,TRUE);

    InitSearchPanel();	/* at least one panel has to be defined
				   for refreshp() to work */

    getmaxyx(stdscr, ymax, xmax);
    if ((ymax < 25) || (xmax < 80)) {
	char c;

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

    noecho();
    crmode();

    strcpy(sp_return, message[12]);
    strcpy(cq_return, message[13]);

    refreshp();

    if (has_colors()) {
	if (start_color() == ERR) {
	    perror("start_color");
	    endwin();
	    printf
		("\n Sorry, wrong terminal type !!!!! \n\nTry a linux text terminal or set TERM=linux !!!");
	    sleep(5);
	    exit(EXIT_FAILURE);
	}

	sprintf(tlfversion,
		"        Welcome to tlf-%s by PA0R!!" , VERSION);
	showmsg(tlfversion);
	showmsg("");

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

	showmsg("reading configuration data");

	status = read_logcfg(); /* read the configuration file */
	status |= read_rules();	/* read the additional contest rules in "rules/contestname"  LZ3NY */

	if (status != PARSE_OK) {
	    showmsg( "Problems in logcfg.dat or rule file detected! Continue Y/(N)?");
	    if (toupper( getchar() ) != 'Y') {
		endwin();
		exit(1);
	    }
	}

	/* make sure logfile is there and has the right format */
	if (checklogfile_new(logfile) != 0) {
	    showmsg( "Giving up" );
	    sleep(2);
	    endwin();
	    exit(1);
	}

//              if (strlen(synclogfile) > 0)
//                      synclog(synclogfile);

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

	if (use_rxvt == 1) {	// use rxvt colours
	    init_pair(COLOR_BLACK, COLOR_BLACK, COLOR_RED);
	    if (use_xterm == 1) {
		init_pair(C_HEADER, COLOR_GREEN, COLOR_BLUE);
		init_pair(COLOR_RED, COLOR_WHITE, 8);
		init_pair(C_WINDOW, COLOR_CYAN, COLOR_MAGENTA);
		init_pair(C_DUPE, COLOR_WHITE, COLOR_MAGENTA);
		init_pair(C_INPUT, COLOR_BLUE, COLOR_WHITE);
	    } else {
		init_pair(C_HEADER, COLOR_GREEN, COLOR_YELLOW);
		init_pair(COLOR_RED, COLOR_WHITE, COLOR_RED);
		init_pair(C_WINDOW, COLOR_CYAN, COLOR_RED);
		init_pair(C_DUPE, COLOR_RED, COLOR_MAGENTA);
		init_pair(C_INPUT, COLOR_BLUE, COLOR_YELLOW);
	    }
	    init_pair(C_LOG, COLOR_WHITE, COLOR_BLACK);
	    init_pair(C_BORDER, COLOR_CYAN, COLOR_YELLOW);
	} else {
	    // use linux console colours
	    init_pair(COLOR_BLACK, tlfcolors[0][0], tlfcolors[0][1]); // b/w
	    init_pair(C_HEADER, tlfcolors[1][0], tlfcolors[1][1]);    // Gn/Ye
	    init_pair(COLOR_RED, tlfcolors[2][0], tlfcolors[2][1]);   // W/R
	    init_pair(C_WINDOW, tlfcolors[3][0], tlfcolors[3][1]);    // Cy/W
	    init_pair(C_LOG, tlfcolors[4][0], tlfcolors[4][1]);       // W/B
	    init_pair(C_DUPE, tlfcolors[5][0], tlfcolors[5][1]);      // W/Mag
	    init_pair(C_INPUT, tlfcolors[6][0], tlfcolors[6][1]);     // Bl/Y
	    init_pair(C_BORDER, tlfcolors[7][0], tlfcolors[7][1]);    // W/B
	}

	mults_possible = g_ptr_array_new();

	if (multlist == 1) {
	    showmsg("reading multiplier data      ");
	    load_multipliers();

	}

	attron(COLOR_PAIR(COLOR_BLACK));
	showmsg("reading callmaster data");

	nr_callmastercalls = load_callmaster();

	if (*exchange_list != '\0') {
	    // read initial exchange file
	    main_ie_list = make_ie_list(exchange_list);
	    if (main_ie_list == NULL) {
		showmsg( "Problems in initial exchange file detected! Continue Y/(N)?");
		if (toupper( getchar() ) != 'Y') {
		    endwin();
		    exit(1);
		}
		else {
		    showmsg( "Initial exchange data not loaded! Continuing ...");
		    sleep(2);
		}
	    }
	}

#ifdef HAVE_LIBHAMLIB		// Code for hamlib interface

	showmsg("HAMLIB defined");

	if (trx_control != 0) {

	    shownr("Rignumber is", (int) myrig_model);
	    shownr("Rig speed is", serial_rate);

	    showmsg("Trying to start rig ctrl");

	    /** \todo fix exclusion of newer hamlib models */
	    if ((int) myrig_model > 1999)
		status = init_native_rig();
	    else
		status = init_tlf_rig();
	}
#else
	if (trx_control != 0) {
//                      trx_control = 0;
	    showmsg("No Hamlib library, using native driver");
	    shownr("Rignumber is", rignumber);
	    shownr("Rig speed is", serial_rate);
	    status = init_native_rig();
	    sleep(1);
	}
#endif				// end code for hamlib interface

	if (status  != 0) {
	    showmsg( "Continue without rig control Y/(N)?");
	    if (toupper( getchar() ) != 'Y') {
		endwin();
		exit(1);
	    }
	    trx_control = 0;
	    showmsg( "Disabling rig control!");
	    sleep(1);
	}


	if (keyerport == NET_KEYER) {
	    showmsg("Keyer is cwdaemon");
	}
	if (keyerport == MFJ1278_KEYER || keyerport == GMFSK) {
	    init_controller();
	}

	if (lan_active == 1) {
	    retval = lanrecv_init();

	    if (retval < 0)	/* set up the network */
		shownr("LAN receive  init failed", retval);
	    else
		showmsg("LAN receive  initialized");

	    if (lan_send_init() < 0)
		showmsg("LAN send init failed");
	    else
		showmsg("LAN send initialized");
	}

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

	clear();
	mvprintw(0, 0, "        Welcome to tlf-%s by PA0R!!\n\n" , VERSION);
	refreshp();
	getmessages();		/* read .paras file */

	if (nopacket == 1)
	    packetinterface = 0;

	set_term(mainscreen);

	refreshp();

	if ((nopacket == 0) && (packetinterface != 0)) {

	    if (init_packet() == 0)
		packet();
	    else
		cleanup_telnet();

	}

	if (keyerport == NET_KEYER) {
	    if (netkeyer_init() < 0) {
		mvprintw(24, 0, "Cannot open NET keyer daemon ");
		refreshp();
		sleep(1);

	    } else {
		netkeyer(K_RESET, "0");

		sprintf(weightbuf, "%d", weight);

		write_tone();

		snprintf(keyerbuff, 3, "%2d", GetCWSpeed());
		netkeyer(K_SPEED, keyerbuff);		// set speed

		netkeyer(K_WEIGHT, weightbuf);		// set weight

		if (*keyer_device != '\0')
		    netkeyer(K_DEVICE, keyer_device);	// set device

		sprintf(keyerbuff, "%d", txdelay);
		netkeyer(K_TOD, keyerbuff);		// set TOD

		if (sc_sidetone != 0)			// set soundcard output
		    netkeyer(K_SIDETONE, "");

		if (*sc_volume != '\0')			// set soundcard volume
			netkeyer(K_STVOLUME, sc_volume);
	    }

	    if (keyerport != NET_KEYER)
		write_tone();
	}

	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 */

	clear_display();	/* tidy up the display */

	qrb();

	attron(COLOR_PAIR(C_LOG) | A_STANDOUT);

	for (j = 13; j <= 23; j++) {	/* wipe lower window */
	    mvprintw(j, 0, backgrnd_str);
	}

	bm_init();			/* initialize bandmap */

	/* Create the first thread */
	ret = pthread_create(&thrd1, NULL, (void *) logit, NULL);
	if (ret) {
	    perror("pthread_create: logit");
	    endwin();
	    exit(EXIT_FAILURE);
	}

	/* Create the second thread */
	ret =
	    pthread_create(&thrd2, NULL, (void *) background_process,
			   NULL);
	if (ret) {
	    perror("pthread_create: backgound_process");
	    endwin();
	    exit(EXIT_FAILURE);
	}

	pthread_join(thrd2, NULL);
	pthread_join(thrd1, NULL);
	endwin();
	exit(EXIT_SUCCESS);

    } else {
	printf("Terminal does not support color\n");
	printf("\nTry TERM=linux  or use a text console !!\n");
	refreshp();
	sleep(2);
    }
    cleanup_telnet();

    if (trxmode == CWMODE && keyerport == NET_KEYER)
	netkeyer_close();
    else
	close(cfd);		/* close keyer */

    endwin();

    return (0);
}