home *** CD-ROM | disk | FTP | other *** search
- /* asiputs.c
- *
- * The Greenleaf Comm Library
- *
- * Copyright (C) 1985-1990 Greenleaf Software Inc. All Rights Reserved.
- *
- * unsigned asiputs( port, str, option )
- * int port; - Port 0..MAX_PORT
- * char *str; - Source String
- * int option; - Defines termination sequence (See Below)
- *
- * DESCRIPTION
- *
- * Transmits a string in interrupt mode using repeated calls to asiputc().
- * The source string must be NULL terminated.
- *
- * Characters are read from the source string and sent to the Transmitter
- * Buffer one at at time until the NULL is read on the source string OR
- * the Transmitter Buffer is full, whichever happens first.
- *
- * When the source termination has been read, the "option" argument is
- * checked to determine what to send as a termination sequence. This
- * sequence, if any, is sent to the Transmitter Buffer to end the
- * operation.
- * option value Sequence to send
- * ------------ ----------------
- * -1 None
- * -2 Carriage Return / Line Feed (0x0D,0x0A)
- * 0x00..0xff Value of option (00..ff)
- *
- * SIDE EFFECTS
- * none, this function calls the asiputc() function for each character
- * in the string. All optional modes set for asiputc() also apply for
- * asputs().
- *
- * RETURNS
- * The return value always indicates the number of characters SUCCESSFULLY
- * transmitted. The global variable _aserror can be examined to determine
- * if an error was detected. _aserror == 0 if no errors were detected.
- *
- * _aserror =
- *
- * Value Meaning
- * ----- -------
- * ASSUCCESS No errors detected
- * ASINVPORT Requested port is out of range
- * ASNOTSETUP Requested port not setup with asifirst()
- * ASBUFRFULL Transmit buffer became full
- * ASINVPAR Option parameter invalid
- *
- * MODIFICATIONS
- * 10-29-85 David Nienhiser
- * Modified for release 2.0
- * Added third parameter "option"
- */
- #include <stdio.h>
- #include "gf.h"
- #include "asiports.h"
-
- unsigned GF_CONV asiputs(port,string,option)
- int port,option;
- char *string;
- {
- unsigned xmit_count;
-
- if ( option < -2 || option > 255) {
- _aserror = ASINVPAR;
- return(0);
- }
-
- /********************************************************
- * First, send all the chars in the string while the *
- * buffer is not full. If the buffer becomes full, *
- * return right then, ASBUFRFULL *
- ********************************************************/
- for (xmit_count=0;*string;++string,++xmit_count)
- if ((_aserror=asiputc(port,((int)*string & 255) ))!=ASSUCCESS)
- return(xmit_count);
-
- /********************************************************
- * If option is 00..FF, send it and bump counter *
- ********************************************************/
- if(option >= 0) {
- if ((_aserror=asiputc(port,option))!=ASSUCCESS)
- return(xmit_count);
- else
- ++xmit_count;
- }
-
- /********************************************************
- * If option is -2, send CR,LF sequence now *
- ********************************************************/
- if (option == -2) {
- if ((_aserror=asiputc(port,CR))!=ASSUCCESS)
- return(xmit_count);
- else
- ++xmit_count;
- if ((_aserror=asiputc(port,LF))!=ASSUCCESS)
- return(xmit_count);
- else
- ++xmit_count;
- }
-
- /********************************************************
- * Option is -1 so send nothing further. *
- ********************************************************/
- return (xmit_count);
- }
-
-