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

  1. /*
  2.  * YMGS.C
  3.  *
  4.  * Contains:     YmodemGSend()
  5.  *
  6.  * The Greenleaf Comm Library
  7.  *
  8.  * Copyright (C) 1989-90 Greenleaf Software Inc.  All Rights Reserved.
  9.  *
  10.  */
  11.  
  12. #include <stdio.h>
  13. #include "gf.h"
  14. #include "asiports.h"
  15. #include "xfer.h"
  16. #include "_xfer.h"
  17.  
  18.  
  19. /*
  20.  *
  21.  * int YmodemGSend( int port,
  22.  *                  char *file_name_list,
  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_list:              This is a pointer to a string containing
  41.  *                                     a list of file names.  The file names
  42.  *                                     can be separated by spaces, commas,
  43.  *                                     or semicolons.  The driver will do its
  44.  *                                     best to send them one at a time.
  45.  *
  46.  * void ( *message_routine )( char * ):The driver routine calls this message
  47.  *                                     routine to print out major progress
  48.  *                                     messages and error messages.  This can
  49.  *                                     be as simple or complicated a routine as
  50.  *                                     the user desires.  All the routine needs
  51.  *                                     to be able to do is print out a string.
  52.  *                                     Note that none of the strings have any
  53.  *                                     embedded control characters.  If this
  54.  *                                     parameter is a NULL, then no message
  55.  *                                     routine is called.
  56.  *
  57.  * void ( *idle_routine)( XFER * ):    This idle routine is called whenever
  58.  *                                     the driver is waiting for buffers to
  59.  *                                     empty out or fill up.  It passes a
  60.  *                                     pointer to the current Xfer status
  61.  *                                     block.  This information will typically
  62.  *                                     be used to update a status display.
  63.  *                                     See XFER.H for documentation on what
  64.  *                                     the fields in the parameter block mean.
  65.  *                                     ANSITERM.C has an example of a status
  66.  *                                     screen using this information.  If this
  67.  *                                     parameter is a NULL, then no idle
  68.  *                                     routine is called.
  69.  *
  70.  * unsigned int abort_key:             The driver routine looks at the
  71.  *                                     keyboard frequently to see if the user
  72.  *                                     wants to abort.  The calling program
  73.  *                                     defines the acceptable abort key with
  74.  *                                     this parameter.
  75.  *
  76.  * DESCRIPTION
  77.  *
  78.  * This routine calls the driver program to perform a YMODEM-G file send.
  79.  * Like the Ymodem routine, multiple file names can be specified in the
  80.  * file_name parameter.  Since the "G" protocol type does away with most
  81.  * of the XMODEM handshaking, this protocol should only be used on an
  82.  * error free connection.  The remote end must be able to keep up with
  83.  * incoming data with no handshaking.
  84.  *
  85.  * SIDE EFFECTS
  86.  *
  87.  * File(s) may have been transfered.
  88.  *
  89.  * RETURNS
  90.  *
  91.  * The routine returns one of the defined XFER_RETURN codes defined
  92.  * in XFER.H.
  93.  *
  94.  * AUTHOR
  95.  *  Mark Nelson          28-Aug-1989  20:57:40.92
  96.  *
  97.  * MODIFICATIONS
  98.  *
  99.  */
  100.  
  101. int GF_CONV YmodemGSend( int port,
  102.                  char *file_name_list,
  103.                  void ( GF_CDECL *message_routine )( char *message ),
  104.                  void ( GF_CDECL *idle_routine )( XFER *status_block ),
  105.                  unsigned int abort_key )
  106. {
  107.     XFER xmodem;
  108.  
  109.     xmodem.port = port;
  110.     xmodem.return_file_name = NULL;
  111.     xmodem.filename = file_name_list;
  112.     xmodem.file_length = 0L;
  113.     xmodem.message_routine = message_routine;
  114.     xmodem.idle_routine = idle_routine;
  115.     xmodem.abort_key = abort_key;
  116.     xmodem.transfer_type = XFER_TYPE_YMODEM_G;
  117.     xmodem.x.xmodem.crc_mode = TRUE;
  118.     _YmodemSend( &xmodem );
  119.     return( xmodem.return_status );
  120. }
  121.  
  122.  
  123.