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 / XM1KR.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-08-14  |  4.7 KB  |  115 lines

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