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

  1. /*
  2.  * ASCIIS.C
  3.  *
  4.  * Contains:          AsciiSend()
  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.  * int AsciiSend( int port,
  20.  *                char *file_name,
  21.  *                void ( *message_routine )( char *message ),
  22.  *                void ( *idle_routine )( XFER *status_block ),
  23.  *                void ( *echo_routine )( int c ),
  24.  *                char strip_lf,
  25.  *                int line_delay,
  26.  *                unsigned int abort_key )
  27.  *
  28.  * ARGUMENTS
  29.  *
  30.  *  int port:                          This is the com port where the transfer
  31.  *                                     will be performed.  It should be open.
  32.  *
  33.  *  char *file_name:                   The file to be opened and uploaded.
  34.  *
  35.  *  void ( *message_routine )( char * ):A routine to print character messages
  36.  *                                      sent out by the driver.  NULL for no
  37.  *                                      routine present.
  38.  *
  39.  *  void ( *idle_routine )( XFER * ):  An idle routine.  It gets a parameter
  40.  *                                     block pointer, enabling it to print
  41.  *                                     out statistics.  NULL for no routine.
  42.  *
  43.  *  void ( *echo_routine )( int c ):   During ASCII transfers, it is often
  44.  *                                     useful to be able to see what the
  45.  *                                     remote end is printing as it echos
  46.  *                                     characters being sent.  This function
  47.  *                                     allows the program to print the
  48.  *                                     echoed characters, one at a time, as
  49.  *                                     they are received.
  50.  *
  51.  *  char strip_lf:                     This flag indicates whether line feed
  52.  *                                     characters should be stripped from
  53.  *                                     the file being sent.  A lot of times
  54.  *                                     each line should just be terminated
  55.  *                                     with a CR, not an LF also.
  56.  *
  57.  * int line_delay:                     This is a count in ticks (not seconds)
  58.  *                                     for how long the sender driver should
  59.  *                                     delay after each line is sent.  A 'line'
  60.  *                                     is defined as a string of characters
  61.  *                                     that either ends with a CR, LF or
  62.  *                                     reaches 80 characters.
  63.  *
  64.  *  unsigned int abort_key:            A user defined abort key.  Control X
  65.  *                                     conventionally, but ESC is good too.
  66.  *
  67.  * DESCRIPTION
  68.  *
  69.  * This routine calls the driver routine to perform an ASCII file
  70.  * upload.  Note that ASCII uploads have no handshaking.  The only option
  71.  * the user has to control the flow is a fixed tick delay after each line
  72.  * is sent.  Some pacing is enforced by that fact that the input buffer
  73.  * is continually being read and flushed, this enforces a sort-of
  74.  * handshaking.  In addition, if XON/XOFF handshakins is turned on, it will
  75.  * work properly during ASCII transfers.
  76.  *
  77.  * SIDE EFFECTS
  78.  *
  79.  * File may have been transfered.
  80.  *
  81.  * RETURNS
  82.  *
  83.  * This routine returns the xfer status word that was set up
  84.  * by the driver routine.  The interpretation of the return values
  85.  * is described in the include file, "XFER.H", which also contains
  86.  * their definitions.
  87.  *
  88.  * AUTHOR
  89.  *  Mark Nelson          28-Aug-1989  20:57:40.92
  90.  *
  91.  * MODIFICATIONS
  92.  *
  93.  */
  94. int GF_CONV AsciiSend( int port,
  95.                char *file_name,
  96.                void ( GF_CDECL *message_routine )( char *message ),
  97.                void ( GF_CDECL *idle_routine )( XFER *status_block ),
  98.                void ( GF_CDECL *echo_routine )( int c ),
  99.                char strip_lf,
  100.                int line_delay,
  101.                unsigned int abort_key )
  102. {
  103.     XFER ascii;
  104.  
  105.     ascii.port = port;
  106.     ascii.return_file_name = NULL;
  107.     ascii.filename = file_name;
  108.     ascii.file_length = 0L ;
  109.     ascii.message_routine = message_routine;
  110.     ascii.idle_routine = idle_routine;
  111.     ascii.abort_key = abort_key;
  112.     ascii.transfer_type = XFER_TYPE_ASCII;
  113.     ascii.x.ascii.strip_lf = strip_lf;
  114.     ascii.x.ascii.received_character_printer = echo_routine;
  115.     ascii.x.ascii.delay_ticks_per_line = line_delay;
  116.     _AsciiSend( &ascii );
  117.     return( ascii.return_status );
  118. }
  119.  
  120.  
  121.