예제 #1
0
파일: lancode.c 프로젝트: thatchristoph/tlf
int talk(void)
{

    char talkline[61] = "";

    mvprintw(24, 0,
	     "                                                                           ");
    mvprintw(24, 0, "T>");
    refreshp();
    echo();
    getnstr(talkline, 60);
    noecho();

    strcat(talkline, "\n");

    send_lan_message(TLFMSG, talkline);

    talkline[0] = '\0';
    attron(COLOR_PAIR(C_HEADER));
    mvprintw(24, 0,
	     "                                                                               ");
    refreshp();

    return (0);
}
예제 #2
0
파일: lancode.c 프로젝트: thatchristoph/tlf
int send_freq(float freq)
{

    extern int bandinx;
    extern int trx_control;

    char fbuffer[8];

    if (trx_control == 1) {

	sprintf(fbuffer, "%7.1f", freq);
    } else {
	switch (bandinx) {

	case 0:
	    sprintf(fbuffer, " 160.0");
	    break;

	case 1:
	    sprintf(fbuffer, "  80.0");
	    break;

	case 2:
	    sprintf(fbuffer, "  40.0");
	    break;

	case 3:
	    sprintf(fbuffer, "  30.0");
	    break;

	case 4:
	    sprintf(fbuffer, "  20.0");
	    break;

	case 5:
	    sprintf(fbuffer, "  17.0");
	    break;

	case 6:
	    sprintf(fbuffer, "  15.0");
	    break;

	case 7:
	    sprintf(fbuffer, "  12.0");
	    break;

	case 8:
	    sprintf(fbuffer, "  10.0");
	    break;

	default:
	    sprintf(fbuffer, "     ");
	}
    }

    send_lan_message(FREQMSG, fbuffer);

    return (0);
}
예제 #3
0
파일: lancode.c 프로젝트: thatchristoph/tlf
int send_time(void)
{

    extern int timeoffset;

    long now;
    char timebuffer[14];

    now = (long) (time(0) + (timeoffset * 3600));

    sprintf(timebuffer, "%ld", now);
    strcat(timebuffer, " ");
    send_lan_message(TIMESYNC, timebuffer);

    return (0);
}
예제 #4
0
파일: addspot.c 프로젝트: patlc/tlf
int addspot(void)
{
    extern float freq;
    extern char hiscall[];
    extern int trx_control;
    extern int lanspotflg;
    extern struct tm *time_ptr;
    extern char thisnode;

    char spotline[160];
    char frequency[8];
    char spottime[6];

    if (strlen(hiscall) < 3)
	return(0);

    if (trx_control == 0) {

	attron(COLOR_PAIR(C_LOG) | A_STANDOUT);

	mvprintw(13, 20, "freq.: ");
	echo();
	getnstr(frequency, 7);
	noecho();
	freq = atof(frequency);
    }

    sprintf(spotline, "DX de TLF-%c:     %9.3f  %s", thisnode, freq, hiscall);

    strcat(spotline, "                                           ");

    get_time();

    strftime(spottime, sizeof(spottime), "%H%MZ", time_ptr);
    strcpy(spotline + 70, spottime);
    strcat(spotline, "\n\n");

    send_lan_message(TLFSPOT, spotline);
    lanspotflg = 1;
    addtext(spotline);
    lanspotflg = 0;
    spotline[0] = '\0';
    hiscall[0] = '\0';

    return (0);
}
예제 #5
0
파일: addspot.c 프로젝트: wildj79/tlf
/** add call to list of spots
 *
 * format a fake DX spot from call and frequency add it to the spot list
 * and send it to other stations in the LAN
 */
void add_to_spots(char *call, float freq) {

    extern int lanspotflg;
    extern struct tm *time_ptr;
    extern char thisnode;

    char spotline[160];
    char spottime[6];

    sprintf(spotline, "DX de TLF-%c:     %9.3f  %s", thisnode, freq, call);
    strcat(spotline, "                                           ");

    get_time();

    strftime(spottime, sizeof(spottime), "%H%MZ", time_ptr);
    strcpy(spotline + 70, spottime);
    strcat(spotline, "\n\n");

    send_lan_message(TLFSPOT, spotline);
    lanspotflg = 1;
    addtext(spotline);
    lanspotflg = 0;
}
예제 #6
0
파일: log_to_disk.c 프로젝트: wildj79/tlf
/** \brief logs one record to disk
 * Logs one record to disk which may come from different sources
 * (direct from tlf or from other instance via LAN)
 *
 * \param from_lan true - Log lanmessage, false - normal message
 */
int log_to_disk(int from_lan)
{
    extern char hiscall[];
    extern char comment[];
    extern char my_rst[];
    extern char his_rst[];
    extern char last_rst[4];
    extern char qsonrstr[5];
    extern char lan_logline[];
    extern int rit;
    extern int trx_control;
    extern int cqmode;
#ifdef HAVE_LIBHAMLIB
    extern freq_t outfreq;
#else
    extern int outfreq;
#endif
    extern int block_part;
    extern char lan_message[];
    extern char thisnode;
    extern int lan_mutex;
    extern int cqwwm2;
    extern int no_rst;

    pthread_mutex_lock(&disk_mutex);

    if (!from_lan) {		// qso from this node

	addcall();		/* add call to dupe list */

	makelogline();

	store_qso(logline4);

	// send qso to other nodes......
	send_lan_message(LOGENTRY, logline4);

	if (trx_control && (cqmode == S_P))
	    addspot();		/* add call to bandmap if in S&P and
				   no need to ask for frequency */

	hiscall[0] = '\0';	/* reset the call  string */
	comment[0] = '\0';	/* reset the comment  string */

	strncpy(last_rst, his_rst, sizeof(last_rst)); /* remember last report */
	his_rst[1] = '9';	/* restore RST to 599 */
	my_rst[1] = '9';

    } else {			// qso from lan

	strncpy(lan_logline, lan_message + 2, 87);
	strcat(lan_logline,
	       "                                                                              ");

	if (cqwwm2 == 1) {
	    if (lan_logline[0] != thisnode)
		lan_logline[79] = '*';
	}

	lan_logline[87] = '\0';

	total = total + score2(lan_logline);

	addcall2();

	store_qso(lan_logline);
    }


    if (from_lan)
	lan_mutex = 2;
    else
	lan_mutex = 1;

    scroll_log();

    lan_mutex = 0;

    attron(modify_attr(COLOR_PAIR(NORMCOLOR)));	/* erase comment  field */

    if (!from_lan)
	mvprintw(12, 54, "                          ");

    attron(COLOR_PAIR(C_LOG) | A_STANDOUT);
    if (!from_lan) {
	mvprintw(7, 0, logline0);
	mvprintw(8, 0, logline1);
	mvprintw(9, 0, logline2);
    }
    mvprintw(10, 0, logline3);
    mvprintw(11, 0, logline4);
    refreshp();

    attron(COLOR_PAIR(C_WINDOW));

    mvprintw(12, 23, qsonrstr);

    if (no_rst) {
	mvaddstr(12, 44, "---");
	mvaddstr(12, 49, "---");
    } else {
	mvaddstr(12, 44, his_rst);
	mvaddstr(12, 49, my_rst);
    }

    sync();

    if ((rit == 1) && (trx_control == 1))
	outfreq = RESETRIT;

    block_part = 0;		/* unblock use partials */

    pthread_mutex_unlock(&disk_mutex);

    return (0);
}
예제 #7
0
파일: sendbuf.c 프로젝트: wildj79/tlf
void ExpandMacro(void) {

    extern char call[20];
    extern char hiscall[20];
    extern char hiscall_sent[];
    extern char his_rst[];
    extern char qsonrstr[5];
    extern char comment[];
    extern char lastqsonr[];
    extern int early_started;
    extern int noleadingzeros;
    extern int lan_active;
    extern int exchange_serial;

    int i;
    static char comstr[BUFSIZE] = "";
    static char qsonroutput[5] = "";
    static char rst_out[4] = "";


    strcpy(comstr, call);
    comstr[strlen(call) - 1] = '\0'; // skip trailing \n
    replace_all(buffer, BUFSIZE, "%", comstr);   /* mycall */


    if (NULL != strstr(buffer, "@")) {
        char *p = hiscall + strlen(hiscall_sent);
	if (strlen(hiscall_sent) != 0) {
	    hiscall_sent[0] = '\0';
	    early_started = 0;
//                              sending_call = 0;
	}
        replace_1(buffer, BUFSIZE, "@", p);   /* his call, 1st occurence */
        replace_all(buffer, BUFSIZE, "@", hiscall);   /* his call, further occurrences */
    }


    strncpy(rst_out, his_rst, 4);
    rst_out[1] = short_number(rst_out[1]);
    rst_out[2] = short_number(rst_out[2]);
    rst_out[3] = '\0';

    replace_all(buffer, BUFSIZE, "[", rst_out);   /* his RST */


    if (NULL != strstr(buffer, "#")) {
        int leading_zeros = 0;
        int lead = 1;
        for (i = 0; i <= 4; i++) {
            if (lead && qsonrstr[i] == '0') {
                ++leading_zeros;
            } else {
                lead = 0;
            }
            qsonroutput[i] = short_number(qsonrstr[i]);
        }
        qsonroutput[4] = '\0';

	if (noleadingzeros != 1 && leading_zeros > 1) {
            leading_zeros = 1;
	}

        replace_all(buffer, BUFSIZE, "#", qsonroutput + leading_zeros);   /* serial nr */

	if ((lan_active == 1) && (exchange_serial == 1)) {
	    strncpy(lastqsonr, qsonrstr, 5);
	    send_lan_message(INCQSONUM, qsonrstr);
	}
    }


    replace_all(buffer, BUFSIZE, "!", comment);
}
예제 #8
0
파일: qtc_log.c 프로젝트: Tlf/tlf
int log_recv_qtc_to_disk(int qsonr)
{
    char qtclogline[100], temp[80];
    int qpos = 0, i, tempi;

    for(i=0; i<10; i++) {

        if (strlen(qtcreclist.qtclines[i].time) == 4 &&
                strlen(qtcreclist.qtclines[i].callsign) > 0 &&
                strlen(qtcreclist.qtclines[i].serial) > 0) { // all fields are filled
            memset(qtclogline, sizeof(qtclogline)/sizeof(qtclogline[0]), ' ');
            qpos = 0;

            // QTC:  3799 PH 2003-03-23 0711 YB1AQS        001/10     DL8WPX        0330 DL6RAI        1021
            // QTC: 21086 RY 2001-11-10 0759 HA3LI           1/10     YB1AQS        0003 KB3TS          003

            sprintf(temp, "%3s", band[bandinx]);
            if (trxmode == CWMODE) {
                strcat(temp, "CW  ");
            }
            else if (trxmode == SSBMODE) {
                strcat(temp, "SSB ");
            }
            else {
                strcat(temp, "DIG ");
            }
            qpos = add_to_qtcline(qtclogline, temp, qpos);

            sprintf(temp, "%04d", qsonr);
            qpos = add_to_qtcline(qtclogline, temp, qpos);

            sprintf(temp, " %s ", qtcreclist.qtclines[i].receivedtime);
            qpos = add_to_qtcline(qtclogline, temp, qpos);

            if (lan_active == 1) {
                qtclogline[qpos++] = thisnode;	// set node ID...
            } else {
                qtclogline[qpos++] = ' ';
            }
            qtclogline[qpos++] = ' ';

            sprintf(temp, "%-14s", qtcreclist.callsign);
            qpos = add_to_qtcline(qtclogline, temp, qpos);

            sprintf(temp, " %04d", qtcreclist.serial);
            qpos = add_to_qtcline(qtclogline, temp, qpos);

            sprintf(temp, " %04d", qtcreclist.count);
            qpos = add_to_qtcline(qtclogline, temp, qpos);

            sprintf(temp, " %s", qtcreclist.qtclines[i].time);
            qpos = add_to_qtcline(qtclogline, temp, qpos);

            sprintf(temp, " %-14s", qtcreclist.qtclines[i].callsign);
            qpos = add_to_qtcline(qtclogline, temp, qpos);

            tempi = atoi(qtcreclist.qtclines[i].serial);
            if(tempi < 1000) {
                sprintf(temp, "  %03d    ", tempi);
            }
            else {
                sprintf(temp, " %04d    ", tempi);
            }
            qpos = add_to_qtcline(qtclogline, temp, qpos);

            if (trx_control == 1) {
                snprintf(temp, 8, "%7.1f", freq);
            }
            else {
                snprintf(temp, 8, "      *");
            }
            qpos = add_to_qtcline(qtclogline, temp, qpos);

            qtclogline[qpos] = '\n';
            qtclogline[qpos + 1] = '\0';

            store_recv_qtc(qtclogline);

            // send qtc to other nodes......
            if (lan_active == 1) {
                send_lan_message(QTCRENTRY, qtclogline);
            }
        }
    }

    /* clear all line infos */
    for(i=0; i<10; i++) {
        qtcreclist.qtclines[i].time[0] = '\0';
        qtcreclist.qtclines[i].callsign[0] = '\0';
        qtcreclist.qtclines[i].serial[0] = '\0';
        qtcreclist.qtclines[i].status = 0;
        qtcreclist.qtclines[i].confirmed = 0;
        qtcreclist.qtclines[i].receivedtime[0] = '\0';
    }
    for(i=0; i<QTC_RY_LINE_NR; i++) {
        qtc_ry_lines[i].content[0] = '\0';
        qtc_ry_lines[i].attr = 0;
    }
    qtc_ry_currline = 0;
    qtc_ry_copied = 0;

    /* clear record list */
    qtcreclist.count = 0;
    qtcreclist.serial = 0;
    qtcreclist.confirmed = 0;
    qtcreclist.sentcfmall = 0;
    qtcreclist.callsign[0] = '\0';

    return (0);
}
예제 #9
0
파일: qtc_log.c 프로젝트: Tlf/tlf
int log_sent_qtc_to_disk(int qsonr)
{
    char qtclogline[100], temp[80];
    int qpos = 0, i;

    for(i=0; i<10; i++) {
        if (qtclist.qtclines[i].saved == 0 && qtclist.qtclines[i].flag == 1 && qtclist.qtclines[i].sent == 1) { // not saved and marked for sent

            memset(qtclogline, sizeof(qtclogline)/sizeof(qtclogline[0]), ' ');
            qpos = 0;

            // QTC:  3799 PH 2003-03-23 0711 YB1AQS        001/10     DL8WPX        0330 DL6RAI        1021
            // QTC: 21086 RY 2001-11-10 0759 HA3LI           1/10     YB1AQS        0003 KB3TS          003

            sprintf(temp, "%3s", band[bandinx]);
            if (trxmode == CWMODE) {
                strcat(temp, "CW  ");
            }
            else if (trxmode == SSBMODE) {
                strcat(temp, "SSB ");
            }
            else {
                strcat(temp, "DIG ");
            }
            qpos = add_to_qtcline(qtclogline, temp, qpos);

            sprintf(temp, "%04d", qsonr);
            qpos = add_to_qtcline(qtclogline, temp, qpos);

            sprintf(temp, " %04d", qtclist.qtclines[i].qsoline+1);
            qpos = add_to_qtcline(qtclogline, temp, qpos);

            sprintf(temp, " %s ", qtclist.qtclines[i].senttime);
            qpos = add_to_qtcline(qtclogline, temp, qpos);

            if (lan_active == 1) {
                qtclogline[qpos++] = thisnode;	// set node ID...
            } else {
                qtclogline[qpos++] = ' ';
            }
            qtclogline[qpos++] = ' ';

            sprintf(temp, "%-14s", qtclist.callsign);
            qpos = add_to_qtcline(qtclogline, temp, qpos);

            sprintf(temp, " %04d", qtclist.serial);
            qpos = add_to_qtcline(qtclogline, temp, qpos);

            sprintf(temp, " %04d ", qtclist.count);
            qpos = add_to_qtcline(qtclogline, temp, qpos);

            strcpy(qtclogline+qpos, qtclist.qtclines[i].qtc);
            qpos+=strlen(qtclist.qtclines[i].qtc);

            qpos = add_to_qtcline(qtclogline, "    ", qpos);

            if (trx_control == 1) {
                snprintf(temp, 8, "%7.1f", freq);
            }
            else {
                snprintf(temp, 8, "      *");
            }
            qpos = add_to_qtcline(qtclogline, temp, qpos);

            qtclogline[qpos] = '\n';
            qtclogline[qpos + 1] = '\0';

            store_sent_qtc(qtclogline);

            // send qtc to other nodes......
            if (lan_active == 1) {
                send_lan_message(QTCSENTRY, qtclogline);
            }
        }
    }

    for(i=0; i<10; i++) {
        qtclist.qtclines[i].qtc[0] = '\0';
        qtclist.qtclines[i].flag = 0;
        qtclist.qtclines[i].saved = 0;
        qtclist.qtclines[i].sent = 0;
        qtclist.qtclines[i].senttime[0] = '\0';
    }

    qtclist.count = 0;
    qtclist.marked = 0;
    qtclist.totalsent = 0;

    return (0);
}