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

  1. /*
  2.  * YMG.C
  3.  *
  4.  * Contains:     YmodemSend()
  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.  * int YmodemSend( int port,
  21.  *                 char *file_name_list,
  22.  *                 void ( *message_routine )( char * ),
  23.  *                 void ( *idle_routine )( XFER * ),
  24.  *                 unsigned int abort_key )
  25.  *
  26.  * ARGUMENTS
  27.  *
  28.  * int port:                           The port can be any opened COM port.
  29.  *                                     Take note of the fact that XMODEM file
  30.  *                                     transfers must have a totally transparent
  31.  *                                     eight bit connection.  This means that
  32.  *                                     The port must be opened with eight bits,
  33.  *                                     and XON/XOFF handshaking must be turned
  34.  *                                     off.  In addition, the buffer sizes
  35.  *                                     should be large enough to accomodate the
  36.  *                                     largest XMODEM buffer, which is about
  37.  *                                     1030 bytes.
  38.  *
  39.  *  char *file_name_list:              This is a pointer to a string containing
  40.  *                                     a list of file names.  The file names
  41.  *                                     can be separated by spaces, commas,
  42.  *                                     or semicolons.  The driver will do its
  43.  *                                     best to send them one at a time.
  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 YMODEM file send.
  79.  * YMODEM batch allows for multiple files to be sent during a single session,
  80.  * and that is handled here by allowing multiple files to be specified
  81.  * in the file_name parameter.  The file names can be separated by single
  82.  * commas, semicolons, or spaces.
  83.  *
  84.  * SIDE EFFECTS
  85.  *
  86.  * File(s) may have been transfered.
  87.  *
  88.  * RETURNS
  89.  *
  90.  * The routine returns one of the defined XFER_RETURN codes defined
  91.  * in XFER.H.
  92.  *
  93.  * AUTHOR
  94.  *  Mark Nelson          28-Aug-1989  20:57:40.92
  95.  *
  96.  * MODIFICATIONS
  97.  *
  98.  */
  99.  
  100. int GF_CONV YmodemSend( int port,
  101.                 char *file_name_list,
  102.                 void ( GF_CDECL *message_routine )( char *message ),
  103.                 void ( GF_CDECL *idle_routine )( XFER *status_block ),
  104.                 unsigned int abort_key )
  105. {
  106.     XFER xmodem;
  107.  
  108.     xmodem.port = port;
  109.     xmodem.return_file_name = NULL;
  110.     xmodem.filename = file_name_list;
  111.     xmodem.file_length = 0L;
  112.     xmodem.message_routine = message_routine;
  113.     xmodem.idle_routine = idle_routine;
  114.     xmodem.abort_key = abort_key;
  115.     xmodem.transfer_type = XFER_TYPE_YMODEM;
  116.     xmodem.x.xmodem.crc_mode = TRUE;
  117.     _YmodemSend( &xmodem );
  118.     return( xmodem.return_status );
  119. }
  120.  
  121.  
  122.