home *** CD-ROM | disk | FTP | other *** search
- /*
- * ASCIIR.C
- *
- * Contains: AsciiReceive()
- *
- * The Greenleaf Comm Library
- *
- * Copyright (C) 1989-90 Greenleaf Software Inc. All Rights Reserved.
- *
- */
-
- #include <stdio.h>
- #include "gf.h"
- #include "asiports.h"
- #include "xfer.h"
- #include "_xfer.h"
-
- /*
- * int AsciiReceive( int port,
- * char *file_name,
- * void ( *message_routine )( char *message ),
- * void ( *idle_routine )( XFER *status_block ),
- * void ( *echo_routine )( int c ),
- * char strip_lf,
- * unsigned int abort_key )
- *
- * ARGUMENTS
- *
- * int port: This is the com port where the transfer
- * will be performed. It should be open.
- *
- * char *file_name: The file to be opened which will receive
- * all the downloaded characters..
- *
- * void ( *message_routine )( char * ):A routine to print character messages
- * sent out by the driver. NULL for no
- * routine present.
- *
- * void ( *idle_routine )( XFER * ): An idle routine. It gets a parameter
- * block pointer, enabling it to print
- * out statistics. NULL for no routine.
- *
- * void ( *echo_routine )( int c ): During ASCII transfers, it is often
- * useful to be able to see what the
- * remote end is sending. This function
- * allows the program to print the
- * characters, one at a time, as
- * they are received.
- *
- * char strip_lf: This flag indicates whether line feed
- * characters should be stripped from
- * the incoming data. A lot of times
- * each line should just be terminated
- * with a CR, not an LF also.
- *
- * unsigned int abort_key: A user defined abort key. Control X
- * conventionally, but ESC is good too.
- * Note that in this case, hitting
- * the abort key will not return an
- * error code, as this is really one of
- * only two legitimate ways to stop an
- * ASCII file transfer.
- *
- * DESCRIPTION
- *
- * This routine calls the driver routine to perform an ASCII file
- * download. Note that ASCII downloads have no handshaking.
- * This means the receiver has to be able to suck in the data as fast
- * as possible. If RTS/CTS or XON/XOFF flow control are turned on,
- * they will work properly, and provide a usable means of flow control.
- * The download terminates normally when either the user hits the
- * abort key, or a timeout occurs. The timeout constant is defined in
- * XFER.H.
- *
- * SIDE EFFECTS
- *
- * File may have been transfered.
- *
- * RETURNS
- *
- * This routine returns the xfer status word that was set up
- * by the driver routine. The interpretation of the return values
- * is described in the include file, "XFER.H", which also contains
- * their definitions.
- *
- * AUTHOR
- * Mark Nelson 26-Sep-1989 20:57:40.92
- *
- * MODIFICATIONS
- *
- */
- int GF_CONV AsciiReceive( int port,
- char *file_name,
- void (GF_CDECL *message_routine )( char *message ),
- void (GF_CDECL *idle_routine )( XFER *status_block ),
- void (GF_CDECL *echo_routine )( int c ),
- char strip_lf,
- unsigned int abort_key )
- {
- XFER ascii;
-
- ascii.port = port;
- ascii.return_file_name = NULL;
- ascii.filename = file_name;
- ascii.file_length = 0L;
- ascii.message_routine = message_routine;
- ascii.idle_routine = idle_routine;
- ascii.abort_key = abort_key;
- ascii.transfer_type = XFER_TYPE_ASCII;
- ascii.x.ascii.received_character_printer = echo_routine;
- ascii.x.ascii.strip_lf = strip_lf;
- _AsciiReceive( &ascii );
- if ( ascii.return_status == XFER_RETURN_KEYBOARD_ABORT )
- return( XFER_RETURN_SUCCESS );
- else
- return( ascii.return_status );
- }
-
-