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

  1. /*
  2.  * XM1KGS.C
  3.  *
  4.  * Contains:     Xmodem1KGCRCSend()
  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.  *
  21.  * int Xmodem1KGCRCSend( int port,
  22.  *                       char *file_name,
  23.  *                       void ( *message_routine )( char * ),
  24.  *                       void ( *idle_routine )( XFER * ),
  25.  *                       unsigned int abort_key )
  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 sent.  Note
  41.  *                                     that the driver program is going to
  42.  *                                     try to open the file with "r" 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.  * DESCRIPTION
  75.  *
  76.  * This routine calls the driver program to perform an XMODEM-G file send
  77.  * using a 16 bit CRC checksum and 1K packets.  Since this is a "G" type
  78.  * transfer, the remote end must be able to keep up with no handshaking.
  79.  * This option should only be used on error free connections, such as those
  80.  * provided by an MNP modem.
  81.  *
  82.  * SIDE EFFECTS
  83.  *
  84.  * File may have been transfered.
  85.  *
  86.  * RETURNS
  87.  *
  88.  * The routine returns one of the defined XFER_RETURN codes defined
  89.  * in XFER.H.
  90.  *
  91.  * AUTHOR
  92.  *  Mark Nelson          28-Aug-1989  20:57:40.92
  93.  *
  94.  * MODIFICATIONS
  95.  *
  96.  */
  97.  
  98. int GF_CONV Xmodem1KGCRCSend( int port,
  99.                       char *file_name,
  100.                       void ( GF_CDECL *message_routine )( char * ),
  101.                       void ( GF_CDECL *idle_routine )( XFER * ),
  102.                       unsigned int abort_key )
  103. {
  104.     XFER xmodem;
  105.  
  106.     xmodem.port = port;
  107.     xmodem.return_file_name = NULL;
  108.     xmodem.filename = file_name;
  109.     xmodem.file_length = 0L;
  110.     xmodem.message_routine = message_routine;
  111.     xmodem.idle_routine = idle_routine;
  112.     xmodem.abort_key = abort_key;
  113.     xmodem.transfer_type = XFER_TYPE_XMODEM_1KG;
  114.     xmodem.x.xmodem.crc_mode = TRUE;
  115.     _XmodemSend( &xmodem );
  116.     return( xmodem.return_status );
  117. }
  118.  
  119.