home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 11 / 11.iso / n / n002 / 4.ddi / DEMOS.ZIP / YMGBSTST.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-07-16  |  2.2 KB  |  80 lines

  1. #include   "xc.h"
  2. #include   "xm.h"
  3. #include   "ym.h"
  4.   
  5. /* This function will SEND files using the YMODEM-g Batch protocol.
  6.    The file spec is specified on the command line and is
  7.    argv[1]. The baud rate is also specified on the command line.
  8.    This function will perform the transferr using the following
  9.    parameters : COM1, No Parity, 8 bits, one stop bit,
  10.    CNTRL-BRK enabled, Data Carrier Detect signal detection enabled.
  11. */
  12.   
  13. int main(int argc, char *argv[])
  14.   
  15. {
  16.   
  17.     int   status;
  18.     int   baud;    /* user input baud rate */
  19.   
  20.     if (argc!=3)   {
  21.         printf("\nPlease input the correct parameters :");
  22.         printf("\nymbstst [filespec]  [baud rate]");
  23.         printf("\nwhere filespec = files to xfer");
  24.         printf("\n      baud rate = 300,600,1200,2400,4800,9600,19200,38400");
  25.     }
  26.     else  {
  27.   
  28.         baud = atoi(argv[2]);
  29.         switch(baud)  {
  30.             case 300:
  31.                 baud = 2;
  32.                 break;
  33.             case 600:
  34.                 baud = 3;
  35.                 break;
  36.             case 1200:
  37.                 baud = 4;
  38.                 break;
  39.             case 2400:
  40.                 baud = 5;
  41.                 break;
  42.             case 4800:
  43.                 baud = 6;
  44.                 break;
  45.             case 9600:
  46.                 baud = 7;
  47.                 break;
  48.             case 19200:
  49.                 baud = 8;
  50.                 break;
  51.             case 38400:
  52.                 baud = 9;
  53.                 break;
  54.             default :
  55.                 baud = 5; /*2400BAUD*/
  56.                 break;
  57.         }
  58.   
  59.   
  60.         status = xc_entr(8);
  61.         if (status >= 0)  {
  62.             xc_link(COM1,0);
  63.             xc_init(COM1,baud,NOPAR,DATA8,STOP1);
  64.                 xc_dtr(COM1,1);
  65.                 xc_rts(COM1,1);
  66.             status = xc_fcon_tx(COM1); /* turn on flow control */
  67.   
  68.             if((status = ymgb_putf(COM1,argv[1],0,YM_CB_AND_DCD))!=0)
  69.                 printf("\nError: %d during transferr?\n",status);
  70.   
  71.             status = xc_fcoff_tx(COM1);        /* turn off flow control */
  72.   
  73.             xc_unlk(COM1);
  74.         }
  75.         else
  76.             printf("XCOMMS.EXE not installed?\n");
  77.         xc_exit();
  78.     }
  79. }
  80.