home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / bss / pup.arc / XMODEM.C < prev   
C/C++ Source or Header  |  1987-11-13  |  18KB  |  707 lines

  1. #include <puppy.h>
  2. #include <ascii.h>
  3. #include <pupmem.h>
  4.  
  5. /*
  6.     XMODEM, TELINK drivers
  7.  
  8.     T. Jennings 20 Sep 87
  9.  
  10. */
  11.  
  12. /* Protocol driver return codes */
  13.  
  14. #define OK 0        /* alls well */
  15. #define ERROR -1    /* generic error */
  16. #define ABORT -2    /* manually aborted */
  17. #define DISKFULL -3    /* disk full error */
  18.  
  19. /* Global statistics */
  20.  
  21. extern int totl_files;    /* how many sent/received */
  22. extern int totl_blocks;    /* 128 bytes blocks */
  23. extern int totl_errors;    /* block retries, etc */
  24.  
  25.  
  26.  
  27. /* Transmit one or more files. The list fn contains one or more file names;
  28. if explicit is true, then they should be used as is else the system path
  29. name should be used. */
  30.  
  31. transmit(fn,namelist,listlen)
  32. char *fn;        /* filename for XMODEM */
  33. char *namelist;        /* list of sent names */
  34. int listlen;        /* max. len of the list */
  35. {
  36. char fspec[SS];        /* full file to search for */
  37. char fname[SS];        /* full filename to send */
  38. int i,f,files;
  39. int error;
  40. struct _fileinfo fileinfo;
  41.  
  42.     while (*fn) {
  43.         cpyarg(fspec,fn);            /* get an atom, */
  44.         fn= next_arg(fn);            /* for next time */
  45.         i= 0; 
  46.         while (getinfo(fspec,i++,&fileinfo)) {
  47.             strip_path(fname,fspec);    /* get the prefix, */
  48.             strcat(fname,fileinfo.name);    /* add the filename */
  49.             xferstat(1,"File: %s",fname);    /* display it, */
  50.  
  51.             if (filemode != XMODEM) {    /* send filename */
  52.                 error= sendfname(fileinfo.name);
  53.                 if (error != OK) break;    /* ERROR or ABORT */
  54.             }
  55.             f= open(fname,0);        /* open it, */
  56.             if (f == -1) {
  57.                 xferstat(2,"Can't open \"%s\"",fname);
  58.                 continue;
  59.             }
  60.             error= sendfile(f,(filemode == TELINK),&fileinfo);
  61.             close(f);            /* close the file, */
  62.             if (error != OK) break;        /* check errors */
  63.             if (strlen(fname) < listlen) {    /* keep a list */
  64.                 strcat(namelist,fname);
  65.                 strcat(namelist," ");
  66.                 listlen -= strlen(fname);
  67.             }
  68.             ++totl_files;            /* count another */
  69.             ++files;
  70.         }
  71.         if (error != OK) break;
  72.     }
  73.     xmitdone(files);                /* complete transmission */
  74.     return(error);
  75. }
  76.  
  77. /* Complete transmission. */
  78.  
  79. xmitdone(files)
  80. int files;
  81. {
  82. int i;
  83.  
  84.     if ((filemode != XMODEM) && files) {
  85.         xferstat(1,"Last file");
  86.         do {i= modin(100);}
  87.         while ((i != -1) && (i != NAK) && (i != ETX));
  88.         if (i == NAK) {
  89.             xferstat(0,"NAK");
  90.             modout(ACK);        /* name ACK, */
  91.             modout(EOT);        /* no more, */
  92.         }
  93.         xferstat(1,"No More Files EOT");
  94.         modout(EOT);
  95.     }
  96. }
  97.  
  98. /* Receive files: the filename fn is used for XMODEM only; for TELINK
  99. it is a dummy. If explicit is true, the path from fn is used, else
  100. the system path is used. */
  101.  
  102. receive(fn,namelist,listlen)
  103. char *fn;        /* filename for XMODEM */
  104. char *namelist;        /* list of received names */
  105. int listlen;        /* max. len of the list */
  106. {
  107. int f,oops;
  108. char path[SS];        /* path/drive from input filename */
  109. char name[SS];        /* plain filename only */
  110. char fname[SS];        /* fully filename with prefix */
  111.  
  112.     cpyarg(name,strip_path(path,fn));        /* seperate filename/path */
  113.  
  114.     while (1) {
  115.         if (filemode != XMODEM) {        /* for TELINK/MODEM7 */
  116.             oops= getfname(name);        /* get the filename */
  117.             if (oops != OK) {        /* remotely */
  118.                 xferstat(1,"Can't get a filename");
  119.                 break;            /* error */
  120.             }
  121.             if (badname(name)) name[1]= '$'; /* reserved filenames */
  122.         }
  123.         cpyarg(fname,path);            /* build the full */
  124.         strcat(fname,name);            /* filename */
  125.         xferstat(1,"File: %s",fname);        /* display it */
  126.  
  127.         f= open(fname,0);            /* make sure it does NOT */
  128.         if (f != -1) {                /* exist */
  129.             close(f);
  130.             xferstat(2,"File already exists!");
  131.             oops= ERROR;
  132.             break;
  133.         }
  134.         f= creat(fname,2);            /* create it, */
  135.         if (f == -1) {
  136.             xferstat(2,"Cannot create file");
  137.             break;
  138.         }
  139.         oops= getfile(f);            /* fill it, */
  140.         close(f);                /* close it, */
  141.  
  142.         if (oops != OK) break;            /* oops, ABORT or EOT */
  143.         if (strlen(fname) < listlen) {        /* keep a list */
  144.             strcat(namelist,fname);
  145.             strcat(namelist," ");
  146.             listlen -= strlen(fname);
  147.         }
  148.         ++totl_files;                /* another ... */
  149.         if (filemode == XMODEM) break;        /* only one */
  150.     }
  151.     flush(0);                    /* flush garbage, */
  152.     return(oops);
  153. }        
  154.  
  155. /* Receive a MODEM7 filename, put into the passed array; return ERROR if error,
  156. OK if we get a filename, EOT if no more files. */
  157.  
  158. getfname(name)
  159. char *name;
  160. {
  161. int i;
  162. char aborts;
  163.  
  164.     aborts= 0;
  165.     for (i= 30; i-- > 0; ) {
  166.         switch (getfn(name)) {
  167.             case OK: return(OK);    /* got a name, */
  168.             case EOT: return(EOT);     /* no more files */
  169.             case ETX: if (++aborts > 2) return(ABORT);
  170.                 break;
  171.         }
  172.     }
  173.     return(ERROR);
  174. }
  175.  
  176. /* Get a single file from the remote computer. Return ERROR if something
  177. went wrong, SOH if the remote is not in batch mode, or 0 if transfer 
  178. complete. If batch mode, the name is a prefix we should stick on the 
  179. beginning of the disk file we create. Does CRC mode if that mode is set,
  180. or a newer TELINK is used, that transmits the CRC flag. */
  181.  
  182. getfile(f)
  183. int f;        /* open file */
  184. {
  185. int i;
  186. int blknum;                /* file block number, */
  187. BYTE sector;                /* XMODEM block number */
  188. BYTE buff[128];                /* XMODEM data block */
  189. int errors;                /* errors 0 - 9 */
  190. BYTE ackchar;                /* ACK/NAK */
  191. BYTE aborts;                /* # of Control-Cs in a row */
  192.  
  193. long fsize;                /* file size or -1 */
  194. long ftime;                /* creation time/date */
  195.  
  196.     blknum= 0;            /* file block number */
  197.     aborts= 0;            /* no Control-Cs yet */
  198.     errors= 0;            /* no errors */
  199.     fsize= -1L;            /* unknown so far */
  200.     ftime= -1L;
  201.     sector= 1;            /* XMODEM block, first time */
  202.     
  203.     ackchar= NAK;
  204.     if (crcmode) ackchar= 'C';    /* use right initial char, */
  205.  
  206.     while (errors < 10) {                /* retry count */
  207.         if (ackchar != ACK) xferstat(0,"NAK");    /* status report */
  208.         modout(ackchar);            /* previous ACK/NAK */
  209.         ++errors;                /* assume an error */
  210.         i= modin(400);                /* get initial character */
  211.         switch (i) {                /* see what it is */
  212.             case SOH:            /* XMODEM data */
  213.                 i= getblock(crcmode,buff); /* get sect number */
  214.                 ackchar= NAK;        /* assume bad, */
  215.                 if (i < 0) break;    /* check for error */
  216.  
  217.                 if (i < sector) {    /* duplicate */
  218.                     xferstat(1,"Duplicate");
  219.                     goto goodblk;    /* ACK it */
  220.  
  221.                 } else if (i > sector) {/* out of sync */
  222.                     xferstat(1,"Block Sync Error");
  223.                     break;
  224.                 }
  225.                 i= 128;            /* set bytes in buffer */
  226.                 if (fsize > 0L) {    /* correct if known */
  227.                     i= (fsize > 128L) ? 128 : fsize;
  228.                     fsize -= i;
  229.                 }
  230.                 if (write(f,buff,i) != i) {
  231.                     xferstat(2,"DISK FULL!");
  232.                     ++totl_errors;
  233.                     return(DISKFULL);
  234.                 }
  235.                 ++totl_blocks;
  236.                 ++sector;
  237.                 ++blknum;
  238.  
  239. goodblk: ;            aborts= 0;
  240.                 errors= 0;
  241.                 ackchar= ACK;
  242.                 break;
  243.  
  244.             case SYN:            /* TELINK block */
  245.                 ackchar= NAK;        /* assume bad */
  246.                 if (getblock(0,buff) != 0) break;
  247.                 fsize= _ctol(&buff[0]);    /* FSC001-8 */
  248.                 ftime= _ctol(&buff[4]);    /* FSC001-8 */
  249.                 xferstat(1,"Telink Block");
  250.                 goto goodblk;
  251.  
  252.             case EOT:            /* end of file */
  253.                 xferstat(1,"End of File EOT");
  254.                 modout(ACK);        /* ACK the EOT, */
  255.                 if (ftime != -1L)    /* set filetime */
  256.                     _ftime(1,f,&ftime);
  257.                 return(OK);
  258.  
  259.             case ETX:            /* Control-C */
  260.                 xferstat(1,"Control-C");
  261.                 if (++aborts > 2) return(ABORT);
  262.                 break;
  263.  
  264.             case -1:            /* timeout */
  265.                 break;
  266.  
  267.             default:            /* garbage */
  268.                 flush(10);        /* quiet line */
  269.                 break;
  270.         }
  271.         xferstat(0,"Blk %u",blknum);
  272.         if (errors) flush(1);        /* flush garbage if error */
  273.     }
  274.     if (errors) {                /* if errors */
  275.         ++totl_errors;            /* flush the line */
  276.         flush(1);            /* was 100 */
  277.     }
  278.     return(ERROR);
  279. }
  280.  
  281. /* Send a filename, MODEM7 style. */
  282.  
  283. sendfname(name)
  284. char *name;
  285. {
  286. int i,ci,aborts;
  287.  
  288.     aborts= 0;
  289.     for (i= 10; i-- > 0; ) {
  290.         switch (sendfn(name)) {
  291.             case ETX: if (++aborts > 2) return(ABORT);
  292.             case OK: return(OK);
  293.         }
  294.     }
  295.     return(ERROR);
  296. }
  297.  
  298. /* Send a file in XMODEM. */
  299.  
  300. sendfile(file,statflg,fileinfo)
  301. int file;            /* open file */
  302. int statflg;            /* 1 == send TELINK block */
  303. struct _fileinfo *fileinfo;    /* file info struct */
  304. {
  305. char c;
  306. int i;
  307. int blknum;                /* file block number, */
  308. BYTE sector;                /* >>> 8 BIT <<< XMODEM block number */
  309. BYTE buff[128];                /* XMODEM data block */
  310. char errors;                /* errors 0 - 9 */
  311. char aborts;                /* # of Control-Cs */
  312.  
  313.     blknum= 0;            /* file block number */
  314.     sector= 1;            /* first XMODEM block number, */
  315.     aborts= 0;            /* no Control-Cs yet */
  316.  
  317.     crcmode= waitnak();            /* get initial NAK/CRC mode */
  318.     if (crcmode == ERROR) return(ERROR);    /* if not NAK/CRC, error */
  319.     if (statflg) sendtel(fileinfo);        /* file statistics */
  320.  
  321.     for (errors= 0; errors < 10; ) {        /* (no, not a mistake ...) */
  322.         i= read(file,buff,128);            /* read some file data, */
  323.         if (! i) break;                /* end of file */
  324.         while (i < 128) buff[i++]= 26;        /* pad last block */
  325.  
  326.         for (errors= 0; errors < 10; ++errors) { /* (... its really OK) */
  327.             xferstat(0,"Block %u",blknum);    /* stats for the nosy sysop */
  328.             modout(SOH);            /* tell rcvr a block comes */
  329.             sendblock(sector,crcmode,buff);
  330.             i= getack();            /* get an acknowledge */
  331.             if (i == ACK) {
  332.                 ++sector;
  333.                 ++blknum;
  334.                 ++totl_blocks;
  335.                 errors= 0;
  336.                 break;
  337.  
  338.             } else {
  339.                 ++totl_errors;        /* another error, */
  340.                 flush(0);        /* flush garbage */
  341.                 if (i != NAK) errors= 10;
  342.             }
  343.         }
  344.     }
  345.  
  346. /* All blocks sent, or too many errors. Tell the remote no more. */
  347.  
  348.     xferstat(1,"");
  349.     if (! errors) {
  350.         for (i= 5; --i > 0; ) {
  351.             xferstat(0,"File EOT");
  352.             modout(EOT);
  353.             if (modin(1000) == ACK) break;
  354.             flush(0);
  355.         }
  356.         return(OK);
  357.     }
  358.     return(ERROR);
  359. }
  360.  
  361. /* Get an acknowledge character or timeout. Return the character
  362. received, or TIMEOUT for a timeout, ABORT for 3 Control-Cs in a row. */
  363.  
  364. getack() {
  365.  
  366. char aborts;
  367. int c;
  368.  
  369.     aborts= 0;
  370.  
  371.     while (1) {
  372.         c= modin(1000);
  373.         switch (c) {
  374.             case ACK: return(c);
  375.  
  376.             case NAK: xferstat(0,"NAK"); return(c);
  377.  
  378.             case ETX: xferstat(1,"Control-C");
  379.                 if (++aborts > 2) return(ABORT); 
  380.                 break;
  381.  
  382.             case -1: return(ERROR); break;
  383.         }
  384.     }
  385. }
  386.  
  387. /* Wait for an initial NAK or CRC; return 0 for NAK, 1 for CRC, or ERROR
  388. for anything else. */
  389.  
  390. waitnak() {
  391.  
  392. char aborts,errors,c;
  393.  
  394.     aborts= 0;
  395.     xferstat(0,"Waiting NAK");
  396.     for (errors= 60; errors-- > 0; ) {    /* 60 seconds max */
  397.  
  398.         switch (modin(100)) {
  399.             case NAK:
  400.                 xferstat(0,"NAK      ");
  401.                 return(0);
  402.  
  403.             case 'C':
  404.                 xferstat(0,"CRC      ");
  405.                 return(1);
  406.  
  407.             case ETX:
  408.                 xferstat(1,"Control-C ");
  409.                 if (++aborts > 2) return(ABORT);
  410.                 break;
  411.         }
  412.         flush(0);
  413.     }
  414.     return(ERROR);
  415. }
  416.  
  417. /* Attempt to send the TELINK data block. Do only 4 attempts; if not received 
  418. by then, assume the other end is not capable of receiving it. If not received, 
  419. then the file will be handled like XMODEM or MODEM7; time and date lost, 
  420. filesize rounded up to the nearest 128 bytes. */
  421.  
  422. sendtel(fileinfo)
  423. struct _fileinfo *fileinfo;
  424. {
  425. int i;
  426. char buffer[128],aborts;
  427.  
  428.     for (i= 0; i < sizeof(buffer); i++)
  429.         buffer[i]= 0;        /* clear data block, */
  430.  
  431.     cpyarg(&buffer[8],fileinfo-> name);/* install filename, */
  432.     strcpy(&buffer[25],"Pup sez: Hi");
  433.     buffer[41]= crcmode;        /* send the CRC flag, acknowledge it, */
  434.  
  435.     aborts= 0;
  436.     for (i= 4; i-- > 0; ) {
  437.         xferstat(0,"TELINK block");
  438.         modout(SYN);
  439.         sendblock(0,0,buffer);    /* send in checksum, */
  440.         switch (modin(1000)) {
  441.             case ACK: return(OK);
  442.             case ETX: if (++aborts > 2) return(ABORT); break;
  443.         }
  444.     }
  445.     return(ERROR);
  446. }
  447.  
  448. /* Get an XMODEM block, return its sequence number, or -1 if error. This
  449. gets the sector number, its 1's complement, the 128 data bytes and does
  450. the checksum or CRC. */
  451.  
  452. getblock(crcflag,buffer)
  453. int crcflag;
  454. char *buffer;
  455. {
  456. int i,v;
  457. int sector;
  458. int chksum;
  459.  
  460.     sector= modin(100);        /* get the sector number, */
  461.     chksum= modin(100);        /* 1's compl (use chksum as temp) */
  462.     if (sector + chksum != 255) return(-1); /* bad sector! */
  463.  
  464.     chksum= 0;            /* initialize check sum and CRC, */
  465.     clrcrc();            /* we maintain both in parallel, */
  466.     for (i= 0; i < 128; i++) {
  467.         v= modin(100);
  468.         if (v == -1) return(-1);
  469.         buffer[i]= v;
  470.         chksum += v;
  471.         updcrc(v);
  472.     }
  473.     if (crcflag) {            /* if CRC mode, get the two */
  474.         v= modin(100);        /* CRC bytes and do those, */
  475.         if (v == -1) return(-1);
  476.         updcrc(v);
  477.         v= modin(100);
  478.         if (v == -1) return(-1);
  479.         updcrc(v);
  480.         if (chkcrc()) return(-1); /* -1 if bad CRC */
  481.  
  482.     } else {            /* checksum */
  483.         v= modin(100);        /* get the checksum, */
  484.         if (v == -1) return(-1);
  485.         if (v != (chksum & 255)) return(-1);
  486.     }
  487.     return(sector);            /* good block */
  488. }
  489.  
  490. /* Transmit an XMODEM block with the specified sector number and checksum/CRC
  491. mode. No return value. */
  492.  
  493. sendblock(sector,crcflag,buffer)
  494. BYTE sector;
  495. int crcflag;
  496. char *buffer;
  497. {
  498. int i;
  499. WORD crc;
  500. BYTE chksum;
  501.  
  502.     modout(sector);            /* send the sector number */
  503.     modout(~sector);        /* and its complement */
  504.  
  505.     chksum= 0;            /* maintain both CRC and checksum, */
  506.     clrcrc();
  507.     for (i= 0; i < 128; i++) {
  508.         modout(buffer[i]);
  509.         chksum+= buffer[i];
  510.         updcrc(buffer[i]);
  511.     }
  512.     flush(0);            /* flush out garbage, */
  513.     if (crcflag) {
  514.         crc= fincrc();        /* get CRC bytes, */
  515.         modout(crc >> 8);    /* MS byte first, */
  516.         modout(crc);        /* then LS byte, */
  517.  
  518.     } else {
  519.         modout(chksum);        /* send checksum, */
  520.     }
  521. }
  522.  
  523. /* Transmit a filename for batch mode tranmission. Return ERROR if cant do it,
  524. or OK if sent properly. It is assumed that the receiver is ready to receive
  525. the filename we have to send. */
  526.  
  527. sendfn(name)
  528. char *name;
  529. {
  530. BYTE chksum;
  531. char c,localname[SS];
  532. int i;
  533.  
  534.     chksum= 0;                /* mis-use as Control-C counter */
  535.     for (i= 60; i-- > 0; ) {        /* get initial character */
  536.         c= modin(100);
  537.         if (c == NAK) break;        /* got name NAK */
  538.  
  539.         if (c == ETX) {            /* if Control-C */
  540.             if (++chksum > 2) return(ABORT);
  541.         }
  542.         flush(0);
  543.     }
  544.     if (! i) return(ERROR);            /* timeout */
  545.  
  546.     cvt_to_fcb(name,localname);        /* convert name, */
  547.     chksum= 0;                /* start checksum, */
  548.     modout(ACK);                /* all ready, */
  549.     for (i= 0; i < 11; i++) {
  550.         c= localname[i];        /* get name char, */
  551.         chksum += c;            /* maintain checksum, */
  552.         modout(c);            /* send name char, */
  553.         if (modin(200) != ACK) break;    /* if not an ACK */
  554.     }
  555.     if (i >= 11) {                /* if all sent OK */    
  556.         modout(SUB);            /* end of name, */
  557.         chksum += SUB;            /* stupid protocol */
  558.         if (modin(100) == (chksum & 0xff)) { /* get recvr's checksum, */
  559.             modout(ACK);        /* if good, say so, */
  560.             return(0);        /* return happy :-), */
  561.         }
  562.     }
  563.     modout('u');                /* else not sent OK, */
  564.     return(ERROR);                /* return sad :-( */
  565. }
  566.  
  567. /* Get a filename from the sender. */
  568.  
  569. getfn(name)
  570. char *name;
  571. {
  572. int i;
  573. int c;            /* NOTE: 'c' is an integer !!! */
  574. BYTE chksum;
  575. char newname[SS];
  576.  
  577.     modout(NAK);                    /* sync sender, */
  578.     c= modin(200);                    /* get sync character, */
  579.     if (c != ACK) return(c);
  580.  
  581.     chksum= 0;
  582.     for (i= 0; i < 11; i++) {            /* 11 char max, */
  583.         c= modin(100);                /* get a char, */
  584.         switch (c) {
  585.             case -1: return(ERROR);        /* timeout */
  586.             case 'u': return(ERROR);    /* error */
  587.             case EOT: return(EOT);        /* no more files */
  588.             case SUB: break;        /* end of name */
  589.             default:
  590.                 chksum += c;        /* file name char I guess */
  591.                 newname[i]= c;        /* stash it */
  592.                 modout(ACK);        /* say "ok" */
  593.                 break;
  594.         }
  595.     }
  596.     if (modin(200) == SUB) {            /* if end of name, */
  597.         modout(chksum & 0xff);            /* send check sum, */
  598.         if (modin(200) == ACK) {
  599.             cvt_from_fcb(newname,name);    /* fix name, */
  600.             return(OK);
  601.         }
  602.     }
  603.     return(ERROR);                    /* filename too long */
  604. }
  605.  
  606. /* Convert a CP/M like filename to a normal ASCIZ name. */
  607.  
  608. cvt_from_fcb(inname,outname)
  609. char *inname,*outname;
  610. {
  611. int i;
  612. char c;
  613.  
  614.     for (i= 8; --i > 0; ) {
  615.         c= fnc(*inname++);
  616.         if (c != ' ') *outname++= c;    /* ignore spaces */
  617.     }                    /* but do all 8 */
  618.     *outname++= '.';            /* add the dot, */
  619.  
  620.     for (i= 3; --i > 0; ) {
  621.         c= fnc(*inname++);
  622.         if (c == ' ') break;
  623.         *outname++= c;
  624.     }
  625.     *outname= NUL;                /* terminate it, */
  626. }
  627.  
  628. /* Fix this filename character */
  629.  
  630. fnc(c)
  631. char c;
  632. {
  633.     if ((c < ' ') || (c == '\\') || (c == '/')) c= '$';
  634.     return(c);
  635. }
  636.  
  637.  
  638. /* Convert a normal asciz string to MSDOS/CPM FCB format. Make the filename
  639. portion 8 characters, extention 3 maximum. Supports wildcards, skips drive
  640. specs. */
  641.  
  642. cvt_to_fcb(inname,outname)
  643. char *inname;
  644. char *outname;
  645. {
  646. char c;
  647. int i;
  648.  
  649.     if (inname[1] == ':') inname= &inname[2];
  650.     for (i= 0; i < 11; i++)
  651.         outname[i]= ' ';        /* clear out name, */
  652.     _cvt2(inname,outname,8);        /* do name portion, */
  653.     while (*inname) {            /* skip to dot, if any */
  654.         if (*inname++ == '.') break;
  655.     }
  656.     _cvt2(inname,&outname[8],3);        /* do extention, */
  657. }
  658. /* Do part of a name. */
  659.  
  660. _cvt2(inname,outname,n)
  661. char *inname,*outname;
  662. int n;
  663. {
  664. int i;
  665.     for (i= 0; i < n; i++) {        /* NAME PART */
  666.         if (*inname == '\0')        /* if null, */
  667.             break;            /* quit, */
  668.         else if (*inname == '*')    /* if *, fill with ?, */
  669.             outname[i]= '?';
  670.         else if (*inname == '.')    /* if a dot, */
  671.             break;            /* skip to extention, */
  672.         else {
  673.             outname[i]= toupper(*inname);
  674.             ++inname;
  675.         }
  676.     }
  677. }
  678.  
  679. /* Display a file transfer status message. N is how to handle it:
  680.  
  681.     0    CR only; stay on same line
  682.     1    CR/LF after text
  683.     2    CR/LF before & after text
  684.  */
  685.  
  686. xferstat(n,s)
  687. char *s;
  688. {
  689. char buff[SS * 4];
  690.  
  691.     if (n == 2) puts("\r\n");
  692.     switch (filemode) {
  693.         case XMODEM:    puts("-X"); break;
  694.         case TELINK:    puts("-T"); break;
  695.         case MODEM7:    puts("-B"); break;
  696.         case KERMIT:    puts("-K"); break;
  697.         case ZMODEM:    puts("-Z"); break;
  698.     }
  699.     if (crcmode) puts("C");
  700.     puts(": ");    
  701.  
  702.     _spr(buff,&s);
  703.     puts(buff);
  704.  
  705.     puts("\r"); if (n) puts("\n");
  706. }
  707.