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

  1. /*
  2.  * XMCHKR.C
  3.  *
  4.  * Contains:     XmodemChecksumReceive()
  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 XmodemChecksumReceive( int port,
  21.  *                            char *file_name,
  22.  *                            void ( *message_routine )( char * ),
  23.  *                            void ( *idle_routine )( XMODEM * ),
  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.  *                                      This file will be opened with "wb"
  42.  *                                      access.
  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.  *
  75.  * DESCRIPTION
  76.  *
  77.  * This routine calls the driver program to perform an XMODEM checksum
  78.  * file receive using the standard arithmetic checksum.
  79.  *
  80.  * SIDE EFFECTS
  81.  *
  82.  * File may have been transfered.
  83.  *
  84.  * RETURNS
  85.  *
  86.  * The routine returns one of the defined XFER_RETURN codes defined
  87.  * in XFER.H.
  88.  *
  89.  * AUTHOR
  90.  *  Mark Nelson          28-Aug-1989  20:57:40.92
  91.  *
  92.  * MODIFICATIONS
  93.  *
  94.  */
  95. int GF_CONV XmodemChecksumReceive( int port,
  96.                            char *file_name,
  97.                            void ( GF_CDECL *message_routine )( char * ),
  98.                            void ( GF_CDECL *idle_routine )( XFER * ),
  99.                            unsigned int abort_key )
  100. {
  101.     XFER xmodem;
  102.  
  103.     xmodem.port = port;
  104.     xmodem.return_file_name = NULL;
  105.     xmodem.filename = file_name;
  106.     xmodem.file_length = 0L;
  107.     xmodem.message_routine = message_routine;
  108.     xmodem.idle_routine = idle_routine;
  109.     xmodem.abort_key = abort_key;
  110.     xmodem.transfer_type = XFER_TYPE_XMODEM;
  111.     xmodem.x.xmodem.crc_mode = FALSE;
  112.     _XmodemReceive( &xmodem );
  113.     return( xmodem.return_status );
  114. }
  115.  
  116.