home *** CD-ROM | disk | FTP | other *** search
- #include "tsr.h"
- unsigned int r_hello = 0x7273;
-
- /* scan code for H key used with Alt here */
- #define SCAN_E 18
-
- /* window save buffers declared globally */
- unsigned char scrnbuf[4000]; /* for interrupted screen */
- unsigned char etermbuf[4000]; /* for eterm screen */
-
- /* save eterm cursor position here, restore it when popping up */
- int saverow, savecol;
- /* get xmodem statistics here */
- int acked,naked,timed,junked;
-
-
- #include "im.h" /* Intelligent modem services */
- #include "xm.h" /* XMODEM services */
- #include "xc.h" /* Communications services */
- #include <stdio.h> /* Standard terminal stuff */
-
- /* Keyboard definitions */
-
- #define FK1 0x3B00 /* Function key 1 */
- #define FK2 0x3C00 /* Function key 2 */
- #define FK3 0x3D00 /* Function key 3 */
- #define FK4 0x3E00 /* Function key 4 */
- #define FK5 0x3F00 /* Function key 5 */
- #define FK6 0x4000 /* Function key 6 */
- #define RUB1 0x08 /* Rubout */
- #define RUB2 0x7F /* Rubout */
- #define RET 0x0D /* CR */
-
- /* Dirty definitions */
-
- #define CLEAN 0 /* <dirty> no cleanup necessary */
- #define CLRSCREEN 1 /* <dirty> clear screen */
- #define CLRSTATUS 2 /* <dirty> clear status part only */
-
- /* Miscellaneous */
-
- #define MIN_BUFFERS 8 /* Minimum buffers required */
- #define SCROLL 1 /* Scroll flag value */
- #define CLEARS 0 /* Clear the screen value */
- #define MAXFIELD 79 /* Maximum field */
- #define STATUSROW 24 /* Row address of status row */
- #define SCRWIDTH 79 /* Last column */
- #define STATCOLUMN 57 /* Starting column of rightmost status */
- #define STATWIDTH 22 /* Width of the rightmost status */
-
- /* Field indices (into the <text> array structure) */
-
- #define INTRO1 0 /* <text> structure entry */
- #define INTRO2 1
- #define INTRO3 2
- #define DATA_FILE 3
- #define ONLINEMSG 4
- #define DATA_DEFAUL 5
- #define MAIN_F1 6
- #define MAIN_F2 7
- #define MAIN_F3 8
- #define MAIN_F5 9
- #define DUMMY 10
- #define NOCONN 11
- #define CONN 12
- #define DIALING 13
- #define INITMODEM 14
- #define HANGUP 15
- #define XUPLOAD 16
- #define XDOWNLOAD 17
- #define XEXIT 18
-
- #define XMODEM 19
- #define SESSION 20
- #define FAILED 21
- #define CANCELLD 22
- #define USERABORT 23
- #define FILEOPEN 24
- #define FILEIO 25
- #define GETUPLOAD 26
- #define GETDOWNLOAD 27
-
- #define COMPORT 28
- #define COMBAUD 37
- #define COMPARITY 47
- #define COMDATA 50
- #define COMSTOP 52
-
- #define COM_HELP 54
- #define COM_ACCEPT 55
- #define COM_ABORT 56
- #define COM_ACP 57
- #define XMODEM_STD 58
- #define XMODME_CRC 59
- #define XMODME_1K 60
- #define XMODEM_EXIT 61
- #define MAIN_F6 62
- #define NULL_STR 63 /* The last one */
-
- extern long xc_test();
-
- /*
- === constants ========================================================
- */
-
- char config_file[]= "ETERM.DAT";
-
- struct {
- int row; /* Row coordinate */
- int col; /* Column coordinate */
- int wid; /* Width */
- char *str; /* Character string */
- } text[] = {
- { 5, 9, 0, "Essential Terminal Emulator"}, /* INTRO1 */
- { 7, 9, 0, "Copyright (C) 1987, 1988, 1991 Essential Software Incorporated"}, /* INTRO2 */
- { 9, 9, 0, "Revision 4.0"},
-
- { STATUSROW, STATCOLUMN, STATWIDTH, "Using ETERM.DAT setup" },
- { STATUSROW, STATCOLUMN, STATWIDTH, "TTY emulation" },
- { STATUSROW, STATCOLUMN, STATWIDTH, "Default setup" },
-
- { STATUSROW, 0, 11, "[F1] XMODEM" },
- { STATUSROW, 12, 10, "[F2] Setup" },
- { STATUSROW, 23, 12, "[F3] Refresh" },
- { STATUSROW, 36, 9, "[F5] Exit" },
- { STATUSROW, STATCOLUMN - 2, 1, "\360" },
- { STATUSROW, STATCOLUMN, STATWIDTH, "No connection" },
- { STATUSROW, STATCOLUMN, STATWIDTH, "Connected!" },
- { STATUSROW, STATCOLUMN, STATWIDTH, "Dialing ..." },
- { STATUSROW, STATCOLUMN, STATWIDTH, "Setup modem ..." },
- { STATUSROW, STATCOLUMN, STATWIDTH, "Hanging up ..." },
-
- { STATUSROW, 0 , 11, "[F1] Upload" },
- { STATUSROW, 13, 13, "[F2] Download" },
- { STATUSROW, 27, 17, "[F6] Exit" },
-
- { STATUSROW, STATCOLUMN, STATWIDTH, "XMODEM successful" },
- { STATUSROW, STATCOLUMN, STATWIDTH, "Session error" },
- { STATUSROW, STATCOLUMN, STATWIDTH, "XMODEM failed" },
- { STATUSROW, STATCOLUMN, STATWIDTH, "XMODEM cancelled" },
- { STATUSROW, STATCOLUMN, STATWIDTH, "User aborted" },
- { STATUSROW, STATCOLUMN, STATWIDTH, "File open error" },
- { STATUSROW, STATCOLUMN, STATWIDTH, "File I/O error" },
- { STATUSROW, 0, STATCOLUMN - 1, "Upload filename: " },
- { STATUSROW, 0, STATCOLUMN - 1, "Download filename: " },
-
- { STATUSROW, 0, 9, "[F1] COM1" },
- { STATUSROW, 0, 9, "[F1] COM2" },
- { STATUSROW, 0, 9, "[F1] COM3" },
- { STATUSROW, 0, 9, "[F1] COM4" },
- { STATUSROW, 0, 9, "[F1] COM5" },
- { STATUSROW, 0, 9, "[F1] COM6" },
- { STATUSROW, 0, 9, "[F1] COM7" },
- { STATUSROW, 0, 9, "[F1] COM8" },
- { STATUSROW, 0, 9, "[F1] COM9" },
-
- { STATUSROW, 10, 9, "[F2] 110 " },
- { STATUSROW, 10, 9, "[F2] 150 " },
- { STATUSROW, 10, 9, "[F2] 300 " },
- { STATUSROW, 10, 9, "[F2] 600 " },
- { STATUSROW, 10, 9, "[F2] 1200" },
- { STATUSROW, 10, 9, "[F2] 2400" },
- { STATUSROW, 10, 9, "[F2] 4800" },
- { STATUSROW, 10, 9, "[F2] 9600" },
- { STATUSROW, 10, 9, "[F2] 19K " },
- { STATUSROW, 10, 9, "[F2] 38K " },
-
- { STATUSROW, 20, 12, "[F3] NO PAR" },
- { STATUSROW, 20, 12, "[F3] ODD PAR" },
- { STATUSROW, 20, 12, "[F3] EVN PAR" },
-
- { STATUSROW, 33, 11, "[F4] 7 DATA" },
- { STATUSROW, 33, 11, "[F4] 8 DATA" },
-
- { STATUSROW, 45, 11, "[F5] 1 STOP" },
- { STATUSROW, 45, 11, "[F5] 2 STOP" },
-
- { STATUSROW, STATCOLUMN, STATWIDTH, "\021\304\304\331 or F6" },
- { STATUSROW, STATCOLUMN, STATWIDTH, "Setup accepted" },
- { STATUSROW, STATCOLUMN, STATWIDTH, "Setup cancelled" },
- { STATUSROW, STATCOLUMN, STATWIDTH, "Accepted, reload ETERM" },
-
- { STATUSROW, 0, 11, "[F1] XMODEM" },
- { STATUSROW, 12, 15, "[F2] XMODEM/CRC" },
- { STATUSROW, 28, 14, "[F3] XMODEM-1K" },
- { STATUSROW, 43, 17, "[F6] Exit" },
-
- { STATUSROW, 46, 9, "[F6] QUIT" },
- { STATUSROW, 0, SCRWIDTH, "" },
- { 0, 0, 0, "" }
- };
- /*
- ======================================================================
- */
- /*
- === global data base =================================================
-
- ETERM.DAT Configuration data base format:
- */
-
- int Port = COM1; /* Default communications port */
- int Baud = BAUD1200; /* Default baud rate */
- int Parity = NOPAR; /* Default parity */
- int Data = DATA8; /* Default data bit size */
- int Stopbits = STOP1; /* Default stop bit */
- int attr_status = 0x70; /* Default attribute */
- int attr_text = 0x07; /* Text window (emulator) attribute */
- int max_ports; /* Maximum supported ports - rev 2.0 */
- int in_xmodem = 0;
-
- int dirty = CLRSCREEN; /* Clear screen initially */
-
-
- #define FILE_ERR 0
-
- FILE *fp;
- int hit_count=0;
- int fatal_error=0;
-
-
- char xmodeminfo[] = "";
- /*** "Blocks transferred [%d] refused [%d] timeouts [%d] garbled [%d]";***/
-
-
- static int firsttime = 1;
- extern unsigned _hotkey_hit; /* variable TRUE when Alt-E was hit */
- static int xm_status;
- int status = 2; /* Index into status messages */
-
- main(argc, argv)
- int argc; /* Argument count */
- char *argv[]; /* Argument variables */
- {
- int resprog();
- int rc;
-
- /*** inittsr2() is a resident_C function to create a TSR. ***/
- /*** tsrloaded() is also a resident_C function to see if we ***/
- /*** are loaded already. ***/
- /*** See the resident_C user manual for more details. ***/
-
- int key; /* Scan code and ASCII key */
- if (!tsrloaded(r_hello))
- {
-
- /*** Go through the initialization code the first time into the ***/
- /*** program. You could have other initializions done here too. ***/
-
- rc =xc_entr(MIN_BUFFERS);
- if(rc == 0){ /* Enough buffers are available */
- scrtomem(2000,0,scrnbuf); /* save DOS screen before initializing */
- savcur(); /* save cursor position */
- xm_status = 0; /* Assume all is OK */
- max_ports = xc_gport(); /* Return the maximum number of ports */
- eterm_init();
- main_menu(CLRSTATUS);
- /* xck_link(); */ /* Enable Ctrl-Break processing */
- /* Not a good idea for a TSR */
-
- /* *** Optionally, dial the modem *** */
- /* The modem dialing code was commented because it did not */
- /* seem to fit a resident emulator example too well. */
- /* Perhaps a dialing menu once popped up would be a better idea. */
- /***********
- if (argc >1) {
- dfield(INITMODEM);
- im_fopen(Port);
- dfield(DIALING);
- if (im_dial(Port, argv[1]) < IM_OK)
- dfield(NOCONN);
- else
- dfield(CONN);
- }
- ***********/
- xct_link();
- xct_pend(20);
- wclear();
- xct_unlk();
- _hotkey_hit = 1; /* run resprog before going resident */
- resprog();
- firsttime = 0; /* so we know its not first time later */
- _hotkey_hit = 0; /* reset kotkey for resprog */
- }
-
- if ((rc = inittsr2(ALT_KEY, SCAN_E, resprog,
- 1024, r_hello, SIG,(void far *)NULL)) != 0)
- {
- printf("Could Not Load. Error = %d \n",rc);
- exit(1);
- }
- }
- else
- printf(" already loaded\n");
-
- /**** Could simulate inittsr2() without going resident with ****/
- /**** while loop below. ****/
- /*
- while(1){
- rc = resprog();
- }
- */
- }
-
- /*** resprog will get control on timer tick or when Alt-E is hit ***/
- /*** and also gets control once before going resident. ***/
-
- resprog(argv,argc)
- int argc;
- char *argv[]; /* Argument variables */
- {
-
- int key; /* Scan code and ASCII key */
- int rc;
- int temprow,tempcol;
-
- /*** If we are in an xmodem transfer, we get to the xmodem code ***/
- /*** right away. We do this because we do not want the xmodem ***/
- /*** transfer to timeout and we are probably not interested in ***/
- /*** doing anything else while the xmodem is taking place. ***/
- /*** However, if the hotkey is hit, we will pop-up. ***/
-
- if(in_xmodem && (!_hotkey_hit)){
- xm_status = xmodem();
- if(xm_status < 0 || xm_status == XM_COMPL){
- in_xmodem = 0;
- putch(7);putch(7); /* ring bell twice when xmodem done */
- /* could also force a pop-up or put */
- /* a message in a window or something */
- }
- /*******
- You might want to add some other checks here. For example, if the
- user hit the hotkey, you might want to ask if he wants to abort
- the xmodem session. To abort the session is difficult now - unless
- you just timeout or drop the connection. If you do need to abort,
- take a look at the code for xmk_putf() in xmk.c. xmk_putf() uses
- xmk_bputf() and allows for aborting by using Ctrl-Break. You would
- probably want to modify the abort logic in xmk.c to use something
- other than Ctrl-Break in a resident (or background) program.
-
- In this example, we assume the xmodem session is the only
- priority until it is done or it fails so we return.
-
- *******/
- return(xm_status); /* we return status for simulation of TSR */
- } /* in main above. status has no meaning */
- /* once the program is TSR. */
-
-
- if(!_hotkey_hit){ /* If hotkey has not been hit, we don't pop up */
- return;
- }
- else
- if (!firsttime){
- _hotkey_hit = 0; /* reset hotkey flag */
- scrtomem(2000,0,scrnbuf); /* resident_C function saves screen */
- memtoscr(2000,0,etermbuf); /* res_C function to restore screen */
- savcur(); /* resident_C function saves cursor */
- }
-
- xm_status = 0;
- xcv_scur(saverow,savecol);
- while (xm_status == 0) {
- if(in_xmodem){ /* want to keep xmodem moving */
- xm_status = xmodem();
- if(xm_status < 0 || xm_status == XM_COMPL){
- in_xmodem = 0;
- putch(7);putch(7); /* ring bell twice when done */
- }else{
- xmk_stat(Port,&acked,&naked,&timed,&junked);
- xcv_gcur(&temprow,&tempcol);
- xcv_scur(23,0);
- printf("blocks completed [%4d]",acked);
- xcv_scur(temprow,tempcol);
- }
-
- }
- if (xck_keyt()) {
- switch (key = xck_getc()) {
- case FK1: /* XMODEM */
- if(!in_xmodem)
- xmodem();
- main_menu(CLRSTATUS);
- break; /* also not needed */
- case FK2: /* Setup */
- if(!in_xmodem)
- config();
- main_menu(CLRSTATUS);
- break;
- case FK3: /* Refresh */
- wclear();
- break;
- case FK5:
- xm_status = 99;
- break;
- case FK6: /* replace ctrl-break below */
- xm_status = 98;
- break;
- default: /* Send key out to the comm port */
- xc_putc(Port, (char) key);
- }
- }
- if (xc_test(Port) && !in_xmodem) /* Display the incoming character */
- echo(xc_getc(Port));
- }
-
- if(xm_status == 98 & !firsttime){ /* Was F6 hit */
- wclear(); /* Clear the entire thing */
- sclear(SCRWIDTH);
- xc_dtr(Port, 0);
- xc_rts(Port, 0);
- xc_exit(); /* Turn off interrupts (everything) */
- fclose(fp);
- xcv_gcur(&saverow,&savecol); /* save eterm cursor */
- rstcur(); /* restore interrupted program cursor */
- memtoscr(2000,0,scrnbuf); /* restore interrupted screen */
- if( freetsr()){ /* remove TSR from memory */
- printf("Couldn't free!!!!!!!!!!!!!\n");
- printf("hit any key to continue.\n");
- xck_getc();
- }
- exit();
- }else{ /* must be F5 or F1 */
- scrtomem(2000,0,etermbuf); /* save eterm screen */
- xcv_gcur(&saverow,&savecol); /* save eterm cursor */
- rstcur(); /* restore interrupted program cursor */
- memtoscr(2000,0,scrnbuf); /* restore interrupted screen */
- return;
- }
- }
-
-
- /*
- === support functions (in order of appearance) ======================
-
- is_break Check for Ctrl-Break
- eterm_init Initialize the screen display, optionally read in
- the ETERM.DAT configuration file
- main_menu Display main menu
- donline Display on-line message
- window Perform a window scroll up or clear for an entire line
- or lines given the attribute
- dfield Display field on the bottom line using the
- attr_status attribute
- echo Echo the character on screen and optionally scroll
- sclear Status line clear up to specified column
- wclear Window text screen clear
- config Process the configuration options and save
- xmodem Transfer XMODEM files up or down
- getinput A simple in-line response reader function
-
- ======================================================================
- */
-
- int is_break() /* Test for the presence of a Ctrl-Break abort */
- {
- int status;
- return(0);
-
- if (status = xck_test()) {
- while (xck_keyt())
- xck_getc();
- }
- return(status);
- }
-
-
- /*
- eterm_init - Initialize the screen display, optionally read in
- the ETERM.DAT configuration file
-
- */
-
-
- int eterm_init() /* Load in the default ETERM data configuration file */
- {
- FILE *Stream;
- int setup_message;
- /* Clear both window areas */
- if ((Stream = fopen(config_file, "r")) != NULL) {
- setup_message = DATA_FILE;
- fread(&Port, sizeof(Port), 1, Stream);
- fread(&Baud, sizeof(Baud), 1, Stream);
- fread(&Parity, sizeof(Parity), 1, Stream);
- fread(&Data, sizeof(Data), 1, Stream);
- fread(&Stopbits, sizeof(Stopbits), 1, Stream);
- fread(&attr_status, sizeof(attr_status), 1, Stream);
- fread(&attr_text, sizeof(attr_text), 1, Stream);
-
- fclose(Stream);
- } else {
- setup_message = DATA_DEFAUL;
- }
- sclear(SCRWIDTH);
- wclear();
- dfield(setup_message);
-
- xcv_scur(text[INTRO1].row, text[INTRO1].col);
- puts(text[INTRO1].str);
- xcv_scur(text[INTRO2].row, text[INTRO2].col);
- puts(text[INTRO2].str);
- xcv_scur(text[INTRO3].row, text[INTRO3].col);
- puts(text[INTRO3].str);
- xcv_scur(0, 0); /* Home the cursor */
-
- main_menu(CLRSCREEN); /* On-line message with function keys */
- xc_link(Port, 0); /* *** Rev 1.2 Used to be 1 instead of 0 */
- xc_dtr(Port, 1); /* *** Rev 1.2 New *** */
- xc_rts(Port, 1); /* *** Rev 1.2 New *** */
- xc_init(Port, Baud, Parity, Data, Stopbits);
- return(0); /* Always successful! */
- }
-
- /* Display the main_menu options except for the status field (at the right).
- The dirty flag is passed and determines what to do when a character is
- either received or typed.
- */
- int main_menu(dirty_flag)
- {
- sclear(STATCOLUMN - 1);
- dfield(MAIN_F1);
- dfield(MAIN_F2);
- dfield(MAIN_F3);
- dfield(MAIN_F5);
- dfield(MAIN_F6);
- dirty = dirty_flag;
- return(0); /* Always successful! */
- }
-
-
- int donline() /* donline - display on-line status message */
- {
- dfield(ONLINEMSG);
- return(0); /* Always successful! */
- }
-
-
- /*
- window - perform a window scroll up or clear for an entire line
- or lines given the attribute
-
- To clear the bottom line, do this:
- window(24, 1, SCRWIDTH, '\007', CLEARS);
- To scroll the upper 24 lines, do this:
- window(0, 24, SCRWIDTH, '\007', SCROLL);
-
- The cursor address does NOT change!
-
- */
- int window(row, row_count, column, attribute, flag)
- int row; /* Row address starting at 0 */
- int row_count; /* Number of rows to scroll or clear */
- int column; /* Last column number */
- char attribute; /* Attribute for the window */
- int flag; /* SCROLL or CLEARS flag */
- {
- xcv_scrl(row, 0, row + row_count - 1, column, attribute, flag);
- return(0); /* Always succeeds! */
- }
-
- /*
- dfield - display field on the bottom line using the
- attr_status attribute
-
- To display "F2 Download" at column 16 in a 20 column width
- pass a <text> structure array index that points to the
- entry:
-
-
- struct {
- int row;
- int col;
- int wid;
- char *str;
- } text[] = {
- . . .
- { STATUSROW, 0, STATCOLUMN - 1, "Download filename: " },
- . . .
-
- dfield(XDOWNLOAD);
-
- The cursor is not moved
-
- */
- int dfield(index)
- int index; /* Index into text array */
- {
- char _string[MAXFIELD]; /* Maximum string field width */
- int i; /* Counter variable */
- int width = text[index].wid; /* Maximum LEGAL field width */
- int column = text[index].col; /* Number of columns */
- char *string = text[index].str;
- int oldrow, oldcol; /* Old cursor address */
-
- if (width > MAXFIELD)
- width = MAXFIELD; /* Specified field is too big */
- /* Create the fixed field */
- for (i = 0; (_string[i] = *string++); ++i)
- ;
- for (; (i < width); ++i)
- _string[i] = ' ';
- xcv_gcur(&oldrow, &oldcol); /* Save the cursor location */
-
- /* Write out the field */
- for (i = 0; (i < width); ++i) {
- xcv_scur(STATUSROW, column + i);
- xcv_chat(_string[i], attr_status);
- }
- xcv_scur(oldrow, oldcol); /* Restore the cursor */
- return(0); /* Always succeeds! */
- }
-
- int echo(ch) /* Display a character and optionally scroll up one line */
- char ch;
- {
- int oldrow, oldcol;
- xcv_wtty(ch);
- xcv_gcur(&oldrow, &oldcol);
- if (oldrow == STATUSROW) {
- window(0, STATUSROW, SCRWIDTH, attr_text, SCROLL);
- xcv_scur(oldrow - 1, oldcol);
- }
- return(0); /* Always succeeds! */
- }
-
- int sclear(column) /* Clear status line */
- int column; /* Last column */
- {
- window(STATUSROW, 1, column, attr_text, CLEARS);
-
- }
-
- int wclear() /* Clear window text area */
- {
- xcv_scur(0, 0); /* Home cursor */
- window(0, STATUSROW, SCRWIDTH, attr_text, CLEARS);
- }
-
- int config() /* Configure the comm port attributes onto disk file */
- {
- int message = 0;
- int ch;
- FILE *Stream;
- int old_port = Port; /* Save the old port */
-
- sclear(STATCOLUMN - 1);
- dfield(COM_HELP);
-
- while (message == 0) {
- dfield(COMPORT + Port);
- dfield(COMBAUD + Baud);
- dfield(COMPARITY + Parity);
- dfield(COMDATA + Data);
- dfield(COMSTOP + Stopbits);
- switch (ch = xck_getc()) {
- case FK1:
- if (++Port == max_ports)
- Port = 0;
- break;
- case FK2:
- if (++Baud > BAUD38400)
- Baud = 0;
- break;
- case FK3:
- if (++Parity > 2)
- Parity = 0;
- break;
- case FK4:
- if (++Data > 1)
- Data = 0;
- break;
- case FK5:
- if (++Stopbits > 1)
- Stopbits = 0;
- break;
- default:
- if (ch == FK6)
- message = COM_ABORT;
- if ((ch & 0xFF) == RET) {
- Stream = fopen(config_file, "w");
- fwrite(&Port, sizeof(Port), 1, Stream);
- fwrite(&Baud, sizeof(Baud), 1, Stream);
- fwrite(&Parity, sizeof(Parity), 1, Stream);
- fwrite(&Data, sizeof(Data), 1, Stream);
- fwrite(&Stopbits, sizeof(Stopbits), 1, Stream);
- fwrite(&attr_status, sizeof(attr_status), 1, Stream);
- fwrite(&attr_text, sizeof(attr_text), 1, Stream);
- fclose(Stream);
- if (old_port == Port) {
- xc_init(Port, Baud, Parity, Data, Stopbits);
- message = COM_ACCEPT;
- } else {
- message = COM_ACP;
- Port = old_port;
- }
- }
- break;
- } /* End of character switch */
- } /* End of while loop */
- dfield(message);
- return(0);
- }
-
- int xmodem() /* Perform XMODEM upload or download */
- {
- int keyin;
- static int exitflag = 2;
- int row, column;
- char answer[33];
- static int transfer;
- int trans_status;
- /* Ask the user to either upload or download */
-
- if(!in_xmodem){
- exitflag = 2;
- transfer = -1;
- sclear(STATCOLUMN - 1);
- dfield(XUPLOAD);
- dfield(XDOWNLOAD);
- dfield(XEXIT);
- while (exitflag == 2) {
- switch ((keyin = xck_getc())) {
- case FK1: /* Upload */
- exitflag = 0;
- break;
- case FK2: /* Download */
- exitflag = 1;
- break;
- default: /* Exit abnormally */
- if (keyin == FK6)
- exitflag = -1;
- }
- }
- if (exitflag == -1)
- dfield(USERABORT);
- else {
- sclear(SCRWIDTH);
- if (exitflag == 0)
- dfield(GETUPLOAD);
- else
- dfield(GETDOWNLOAD);
- xcv_gcur(&row,&column);
- xcv_scur(STATUSROW,20);
-
- if (getinput(answer) <= 0) {
- dfield(XMODEM + 4);
- } else {
- /* *********** REV 2.0 ask the type of XMODEM transfer ********* */
- sclear(STATCOLUMN - 1);
- dfield(XMODEM_STD);
- dfield(XMODME_CRC);
- dfield(XMODME_1K);
- dfield(XMODEM_EXIT);
- switch (xck_getc()) {
- case FK1: /* Standard */
- transfer = 0;
- break;
- case FK2: /* CRC option*/
- transfer = 1;
- break;
- case FK3: /* 1K option*/
- transfer = 2;
- break;
- case FK6: /* 1K option*/
- exitflag = -1;
- dfield(USERABORT);
- break;
- default: /* Exit abnormally */
- exitflag = -1;
- dfield(USERABORT);
- break;
- }
- /* ******************************************************** */
- xcv_scur(row,column);
-
- if (exitflag == -1) {
- dfield(NULL_STR);
- return(-1);
- }
- }
- }
- }
- if (exitflag == 0) { /* Execute upload/download */
- switch (transfer) {
- case 0:
- trans_status = xmk_bputf(Port, answer, XMODEM_128, XMODEM_XSUM,1);
- in_xmodem = 1;
- break;
- case 1:
- trans_status = xmk_bputf(Port, answer, XMODEM_128, XMODEM_CRC,1);
- in_xmodem = 1;
- break;
- case 2:
- trans_status = xmk_bputf(Port, answer, XMODEM_1K, XMODEM_CRC,1);
- in_xmodem = 1;
- break;
- }
- } else {
- switch (transfer) {
- case 0:
- trans_status = xmk_bgetf(Port, answer, XMODEM_128, XMODEM_XSUM,1);
- in_xmodem = 1;
- break;
- case 1:
- trans_status = xmk_bgetf(Port, answer, XMODEM_128, XMODEM_CRC,1);
- in_xmodem = 1;
- break;
- case 2:
- trans_status = xmk_bgetf(Port, answer, XMODEM_1K, XMODEM_CRC,1);
- in_xmodem = 1;
- break;
- }
- }
-
-
- return(trans_status);
- }
-
-
-
- /*
- getinput - Given the character string buffer address, accept the
- user input string and return the number of characters entered. Accept
- input at the current cursor location.
- Returns:
-
- 0 Only Enter key pressed
- >0 The character string of n characters returned
- -1 Ctrl-Break pressed
- */
- int getinput(buffer)
- char buffer[];
- {
- int i = 0;
- int exitflag = 0;
- char ch;
- int row, column;
-
- while (exitflag == 0) {
- switch ((ch = xck_getc()) & 0xFF) {
- case RET:
- buffer[i] = '\000';
- exitflag = 1; /* Exit file entry */
- break;
- case RUB1:
- case RUB2:
- if (i) {
- --i;
- xcv_gcur(&row, &column);
- xcv_scur(row, column - 1);
- xcv_wtty(' ');
- xcv_scur(row, column - 1);
- }
- break;
- default:
- buffer[i++] = ch;
- xcv_wtty(ch);
- }
- }
- return(i); /* Return size of answer */
- }