home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0020 - 0029 / ibm0020-0029 / ibm0028.tar / ibm0028 / GRLF-C-1.ZIP / GCOMM / XM1KGR.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-08-14  |  5.1 KB  |  122 lines

  1. /*
  2.  * XM1KGR.C
  3.  *
  4.  * Contains:     Xmodem1KGCRCReceive()
  5.  *
  6.  *
  7.  * The Greenleaf Comm Library
  8.  *
  9.  * Copyright (C) 1989-90 Greenleaf Software Inc.  All Rights Reserved.
  10.  *
  11.  */
  12.  
  13. #include <stdio.h>
  14. #include "gf.h"
  15. #include "asiports.h"
  16. #include "xfer.h"
  17. #include "_xfer.h"
  18.  
  19. /*
  20.  * int Xmodem1KGCRCReceive( int port,
  21.  *                          char *file_name,
  22.  *                          void ( *message_routine )( char * ),
  23.  *                          void ( *idle_routine )( XFER * ),
  24.  *                          unsigned int abort_key )
  25.  *
  26.  *
  27.  * ARGUMENTS
  28.  *
  29.  * int port:                           The port can be any opened COM port.
  30.  *                                     Take note of the fact that XMODEM file
  31.  *                                     transfers must have a totally transparent
  32.  *                                     eight bit connection.  This means that
  33.  *                                     The port must be opened with eight bits,
  34.  *                                     and XON/XOFF handshaking must be turned
  35.  *                                     off.  In addition, the buffer sizes
  36.  *                                     should be large enough to accomodate the
  37.  *                                     largest XMODEM buffer, which is about
  38.  *                                     1030 bytes.
  39.  *
  40.  *  char *file_name:                   The file to be opened and downloaded to.
  41.  *                                     Note that the file will be opened with
  42.  *                                     "rb" access by the driver.
  43.  *
  44.  * void ( *message_routine )( char * ):The driver routine calls this message
  45.  *                                     routine to print out major progress
  46.  *                                     messages and error messages.  This can
  47.  *                                     be as simple or complicated a routine as
  48.  *                                     the user desires.  All the routine needs
  49.  *                                     to be able to do is print out a string.
  50.  *                                     Note that none of the strings have any
  51.  *                                     embedded control characters.  If this
  52.  *                                     parameter is a NULL, then no message
  53.  *                                     routine is called.
  54.  *
  55.  * void ( *idle_routine)( XFER * ):    This idle routine is called whenever
  56.  *                                     the driver is waiting for buffers to
  57.  *                                     empty out or fill up.  It passes a
  58.  *                                     pointer to the current Xfer status
  59.  *                                     block.  This information will typically
  60.  *                                     be used to update a status display.
  61.  *                                     See XFER.H for documentation on what
  62.  *                                     the fields in the parameter block mean.
  63.  *                                     ANSITERM.C has an example of a status
  64.  *                                     screen using this information.  If this
  65.  *                                     parameter is a NULL, then no idle
  66.  *                                     routine is called.
  67.  *
  68.  * unsigned int abort_key:             The driver routine looks at the
  69.  *                                     keyboard frequently to see if the user
  70.  *                                     wants to abort.  The calling program
  71.  *                                     defines the acceptable abort key with
  72.  *                                     this parameter.
  73.  *
  74.  * DESCRIPTION
  75.  *
  76.  * This routine calls the driver program to perform an XMODEM-G checksum
  77.  * file receive using a 1K buffer size.  Note that the drive will not let
  78.  * the remote end fall back to using an arithmetic checksum when the
  79.  * 1K buffer size is selected.  Since this is a G receive, it means that
  80.  * the receiver must have an error free connection, and be able to save
  81.  * buffers off to disk just as fast as they are received.  This is a good
  82.  * protocol to use when fast file transfers are desired, and an error
  83.  * free connection is provided by an MNP modem.  The lack of handshaking
  84.  * does hurt.
  85.  *
  86.  * SIDE EFFECTS
  87.  *
  88.  * File may have been transfered.
  89.  *
  90.  * RETURNS
  91.  *
  92.  * The routine returns one of the defined XFER_RETURN codes defined
  93.  * in XFER.H.
  94.  *
  95.  * AUTHOR
  96.  *  Mark Nelson          28-Aug-1989  20:57:40.92
  97.  *
  98.  * MODIFICATIONS
  99.  *
  100.  */
  101. int GF_CONV Xmodem1KGCRCReceive( int port,
  102.                          char *file_name,
  103.                          void ( GF_CDECL *message_routine )( char * ),
  104.                          void ( GF_CDECL *idle_routine )( XFER * ),
  105.                          unsigned int abort_key )
  106. {
  107.     XFER xmodem;
  108.  
  109.     xmodem.port = port;
  110.     xmodem.return_file_name = NULL;
  111.     xmodem.filename = file_name;
  112.     xmodem.file_length = 0L;
  113.     xmodem.message_routine = message_routine;
  114.     xmodem.idle_routine = idle_routine;
  115.     xmodem.abort_key = abort_key;
  116.     xmodem.transfer_type = XFER_TYPE_XMODEM_1KG;
  117.     xmodem.x.xmodem.crc_mode = TRUE;
  118.     _XmodemReceive( &xmodem );
  119.     return( xmodem.return_status );
  120. }
  121.  
  122.