void delete_qso(void) { int x; struct stat statbuf; int lfile; char logline[100]; char call[15], bandmode[6]; mvprintw(13, 29, "OK to delete last qso (y/n)?"); x = key_get(); if ((x == 'y') || (x == 'Y')) { if ((lfile = open(logfile, O_RDWR)) < 0) { TLF_LOG_WARN("I can not find the logfile..."); } else { fstat(lfile, &statbuf); if (statbuf.st_size >= LOGLINELEN) { if (qtcdirection > 0) { // read band, mode and call from last QSO line lseek(lfile, ((int)statbuf.st_size - LOGLINELEN), SEEK_SET); IGNORE(read(lfile, logline, LOGLINELEN - 1));; g_strlcpy(bandmode, logline, 6); g_strlcpy(call, logline + 29, 15); g_strchomp(call); // delete QTC's for that combination of band, mode and call delete_last_qtcs(call, bandmode); } IGNORE(ftruncate(lfile, statbuf.st_size - LOGLINELEN)); } fsync(lfile); close(lfile); if (qsos[nr_qsos][0] != ';') { band_score[bandinx]--; qsonum--; qsonr_to_str(); } nr_qsos--; qsos[nr_qsos][0] = '\0'; } scroll_log(); } attron(COLOR_PAIR(C_LOG) | A_STANDOUT); mvprintw(13, 29, " "); printcall(); clear_display(); }
void *background_process(void *ptr) { extern int landebug; extern struct tm *time_ptr; static int i, t; static char prmessage[256]; static int lantimesync = 0; static int fldigi_rpc_cnt = 0; int n; char debugbuffer[160]; FILE *fp; i = 1; while (i) { while (stop_backgrnd_process == 1) { sleep(1); } usleep(10000); if (packetinterface != 0) { receive_packet(); } if (trxmode == DIGIMODE && digikeyer != NO_KEYER) rx_rtty(); /* * calling Fldigi XMLRPC method, which reads the Fldigi's carrier * this function helps to show the correct freq of the RIG: reads * the carrier value from Fldigi, and stores in a variable; then * it readable by fldigi_get_carrier() * only need at every 2nd cycle * see fldigixmlrpc.[ch] */ if (trxmode == DIGIMODE && (digikeyer == GMFSK || digikeyer == FLDIGI) && trx_control == 1) { if (fldigi_rpc_cnt == 0) { fldigi_xmlrpc_get_carrier(); } fldigi_rpc_cnt = 1 - fldigi_rpc_cnt; } if (stop_backgrnd_process == 0) { write_keyer(); cw_simulator(); } if (lan_active == 1) { if (lan_message[0] == '\0') { if (lan_recv() < 0) { recv_error++; } else { lan_message[strlen(lan_message) - 1] = '\0'; } } if (landebug == 1) { if ((fp = fopen("debuglog", "a")) == NULL) { fprintf(stdout, "store_qso.c: Error opening debug file.\n"); } else { get_time(); strftime(debugbuffer, 80, "%H:%M:%S-", time_ptr); if (strlen(lan_message) > 2) { strcat(debugbuffer, lan_message); strcat(debugbuffer, "\n"); fputs(debugbuffer, fp); } fclose(fp); } } if ((*lan_message != '\0') && (lan_message[0] == thisnode)) { mvprintw(24, 0, "Warning: NODE ID CONFLICT ?! You should use another ID! "); refreshp(); sleep(5); } if ((*lan_message != '\0') && (lan_message[0] != thisnode) && (stop_backgrnd_process != 1)) { switch (lan_message[1]) { case LOGENTRY: log_to_disk(true); break; case QTCRENTRY: store_recv_qtc(lan_message+2); break; case QTCSENTRY: store_sent_qtc(lan_message+2); break; case QTCFLAG: parse_qtc_flagline(lan_message+2); break; case CLUSTERMSG: strncpy(prmessage, lan_message + 2, 80); if (strstr(prmessage, call) != NULL) // alert for cluster messages { mvprintw(24, 0, " "); mvprintw(24, 0, "%s", prmessage); refreshp(); } addtext(prmessage); break; case TLFSPOT: strncpy(prmessage, lan_message + 2, 80); lanspotflg = 1; addtext(prmessage); lanspotflg = 0; break; case TLFMSG: for (t = 0; t < 4; t++) strcpy(talkarray[t], talkarray[t + 1]); talkarray[4][0] = lan_message[0]; talkarray[4][1] = ':'; talkarray[4][2] = '\0'; strncat(talkarray[4], lan_message + 2, 60); mvprintw(24, 0, " "); mvprintw(24, 0, " MSG from %s", talkarray[4]); refreshp(); break; case FREQMSG: if ((lan_message[0] >= 'A') && (lan_message[0] <= 'A' + MAXNODES)) { node_frequencies[lan_message[0] - 'A'] = atof(lan_message + 2); break; } case INCQSONUM: n = atoi(lan_message + 2); if (highqsonr < n) highqsonr = n; if ((qsonum <= n) && (n > 0)) { qsonum = highqsonr + 1; qsonr_to_str(); } lan_message[0] = '\0'; case TIMESYNC: if ((lan_message[0] >= 'A') && (lan_message[0] <= 'A' + MAXNODES)) { lantime = atoi(lan_message + 2); if (lantimesync == 1) timecorr = ((4 * timecorr) + lantime - (time(0) + (timeoffset * 3600L))) / 5; else { timecorr = lantime - (time(0) + (timeoffset * 3600L)); lantimesync = 1; } break; } } lan_message[0] = '\0'; lan_message[1] = '\0'; } } gettxinfo(); /* get freq info from TRX */ } return (NULL); }