#include #include #include #include #include #include #include #include "mfjterm.h" #include "scrollback.h" #include "misc.h" #include "inout.h" #include "timefuncs.h" void send_file(void) { static char send_fname[51]; char fstr[81]; FILE* fp; attrset(A_REVERSE); move(19, 1); addstr("File to send: "); edgets(stdscr, send_fname, 50, FALSE); move(19, 1); addstr(" "); refresh(); if (! strlen(send_fname)) goto send_abort; if ((fp = fopen(send_fname, "r"))) { while (fgets(fstr,80,fp)) { fstr[strlen(fstr)-1] = 0; /* Strip LF */ send_string(fstr, 1); zleep(30); if (getch() != ERR) break; } fclose(fp); } else { move(19, 1); curs_set(0); addstr("Couldn't find that file!"); refresh(); sleep(1); move(19, 1); addstr(" "); curs_set(1); } send_abort: move(tnc_y, tnc_x); refresh(); } void capture(void) { static char capsign[2] = {' ', 'C'}; static char capfname[51] = "mfjterm.cap"; attrset(A_REVERSE); move(19, 1); cap ^= 1; if (cap) { addstr("File to capture to: "); edgets(stdscr, capfname, 50, FALSE); move(19, 1); addstr(" "); refresh(); if (! strlen(capfname)) { cap = FALSE; goto cap_abort; } if ((capf = fopen(capfname, "r"))) { fclose(capf); capf = fopen(capfname, "a"); } else capf = fopen(capfname, "w"); } else { curs_set(0); addstr("Capture file Closed"); refresh(); fclose(capf); sleep(1); move(19, 1); addstr(" "); curs_set(1); } move(19, 78); addch(capsign[cap]); cap_abort: move(tnc_y, tnc_x); refresh(); } int read_settings(void) { int i; char cfg_file[81]; char s[81]; FILE* fp; sprintf(cfg_file, "%s%s", lib_path, "/mfjterm.cfg"); if ((fp = fopen(cfg_file, "r"))) { fgets(callsign, 80, fp); callsign[strlen(callsign)-1] = 0; fgets(my_selcall, 80, fp); my_selcall[strlen(my_selcall)-1] = 0; fgets(s, 10, fp); s[strlen(s)-1] = 0; bps = (speed_t)(atoi(s)); opmode = atoi(fgets(s, 3, fp)); pc_translate = atoi(fgets(s, 3, fp)); bell = atoi(fgets(s, 3, fp)); for (i = 0; i < 12; i++) { fgets(fkstr[i],80,fp); fkstr[i][strlen(fkstr[i])-1] = 0; } fclose(fp); return 1; } else return 0; } void save_settings(void) { char cfg_file[81]; FILE* fp; int i; attrset(A_REVERSE); move(19, 1); curs_set(0); addstr("Saving current settings..."); refresh(); sprintf(cfg_file, "%s%s", lib_path, "/mfjterm.cfg"); fp = fopen(cfg_file, "w"); fprintf(fp, "%s\n", callsign); fprintf(fp, "%s\n", my_selcall); fprintf(fp, "%d\n", bps); fprintf(fp, "%d\n", opmode); fprintf(fp, "%d\n", pc_translate); fprintf(fp, "%d\n", bell); for (i = 0; i < 12; i++) fprintf(fp, "%s\n", fkstr[i]); fclose(fp); sleep(1); move(19, 1); addstr(" "); move(tnc_y, tnc_x); curs_set(1); refresh(); } void save_sb_buf(void) { FILE* sb_f; static char sb_fname[51]; int i, lc; attrset(A_REVERSE); move(19,1); addstr("Save S-B buffer to: "); edgets(stdscr, sb_fname, 50, FALSE); move(19, 1); addstr(" "); refresh(); if (! strlen(sb_fname)) goto sb_save_abort; sb_f = fopen(sb_fname, "w"); lc = lines_in_buffer; i = strno; while (--lc >= 0) if (--i < 0) i = 808; while (++lc < (lines_in_buffer)) { fprintf(sb_f,"%s\n", sb_bufstr[i]); if(++i > 808) i=0; } fclose(sb_f); sb_save_abort: move(tnc_y, tnc_x); refresh(); } .