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

  1. /*
  2.  * XM1KS.C
  3.  *
  4.  * Contains:     Xmodem1KCRCSend()
  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 Xmodem1KCRCSend( 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.  *
  41.  *  char *file_name:                   The file to be opened and sent.  The
  42.  *                                     driver program will open up this file
  43.  *                                     with "rb" access.
  44.  *
  45.  * void ( *message_routine )( char * ):The driver routine calls this message
  46.  *                                     routine to print out major progress
  47.  *                                     messages and error messages.  This can
  48.  *                                     be as simple or complicated a routine as
  49.  *                                     the user desires.  All the routine needs
  50.  *                                     to be able to do is print out a string.
  51.  *                                     Note that none of the strings have any
  52.  *                                     embedded control characters.  If this
  53.  *                                     parameter is a NULL, then no message
  54.  *                                     routine is called.
  55.  *
  56.  * void ( *idle_routine)( XFER * ):    This idle routine is called whenever
  57.  *                                     the driver is waiting for buffers to
  58.  *                                     empty out or fill up.  It passes a
  59.  *                                     pointer to the current Xfer status
  60.  *                                     block.  This information will typically
  61.  *                                     be used to update a status display.
  62.  *                                     See XFER.H for documentation on what
  63.  *                                     the fields in the parameter block mean.
  64.  *                                     ANSITERM.C has an example of a status
  65.  *                                     screen using this information.  If this
  66.  *                                     parameter is a NULL, then no idle
  67.  *                                     routine is called.
  68.  *
  69.  * unsigned int abort_key:             The driver routine looks at the
  70.  *                                     keyboard frequently to see if the user
  71.  *                                     wants to abort.  The calling program
  72.  *                                     defines the acceptable abort key with
  73.  *                                     this parameter.
  74.  *
  75.  *
  76.  * DESCRIPTION
  77.  *
  78.  * This routine calls the driver program to perform an XMODEM file send
  79.  * using a 16 bit CRC checksum and 1K packets.  The drive will not fall back
  80.  * to additive checksum mode.  1K buffer sizes really speed up XMODEM, and
  81.  * should probably be used on all but the noisiest lines.
  82.  *
  83.  * SIDE EFFECTS
  84.  *
  85.  * Each of these routines returns the xfer status word that was set up
  86.  * by the driver routine.  The interpretation of the return values
  87.  * is described in the include file, "XFER.H", which also containes
  88.  * their definitions.
  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.  
  102. int GF_CONV Xmodem1KCRCSend( int port,
  103.                      char *file_name,
  104.                      void ( GF_CDECL *message_routine )( char * ),
  105.                      void ( GF_CDECL *idle_routine )( XFER * ),
  106.                      unsigned int abort_key )
  107. {
  108.     XFER xmodem;
  109.  
  110.     xmodem.port = port;
  111.     xmodem.return_file_name = NULL;
  112.     xmodem.filename = file_name;
  113.     xmodem.file_length = 0L;
  114.     xmodem.message_routine = message_routine;
  115.     xmodem.idle_routine = idle_routine;
  116.     xmodem.abort_key = abort_key;
  117.     xmodem.transfer_type = XFER_TYPE_XMODEM_1K;
  118.     xmodem.x.xmodem.crc_mode = TRUE;
  119.     _XmodemSend( &xmodem );
  120.     return( xmodem.return_status );
  121. }
  122.  
  123.  
  124.