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

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