home *** CD-ROM | disk | FTP | other *** search
- /* asputs.c
- *
- * The Greenleaf Comm Library
- *
- * Copyright (C) 1985-1990 Greenleaf Software Inc. All Rights Reserved.
- *
- * unsigned asputs( port, str, option)
- * int port; - Port 0..MAX_PORT-1
- * char *str; - String to transmit
- * int option; - Defines termination sent, see below.
- *
- * DESCRIPTION
- * This function transmits a string using the polled mode.
- * The source string (pointed to by "str") must be NULL terminated.
- * Characters are read from the source string and transmitted one at
- * a time until the NULL is read. Then the "option" argument determines
- * what is sent next.
- * option value What is sent
- * -1 Nothing
- * -2 Carriage Return/Line Feed sequence
- * (0x0D,0x0A)
- * 0x00..0xff value of option itself (00..ff)
- *
- * SIDE EFFECTS
- * This function simply calls the asputc() function for each character
- * transmitted. All optional modes set for asputc() 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
- * ASINVPORT Requested port is out of range
- * ASNOTSETUP Requested port not setup with asifirst()
- * ASTIMEOUT Function timed out waiting for character
- * ASNOCD CD (Carrier detect) not active
- * ASNODSR DSR (Data set ready) not active
- *
- * MODIFICATIONS
- * 10-29-85 ""
- * Modified for release 2.0
- */
- #include <stdio.h>
- #include "gf.h"
- #include "asiports.h"
-
- unsigned GF_CONV asputs(port,string,option)
- int port,option;
- char *string;
- {
- unsigned xmit_count;
-
-
- if (option < -2 || option > 255) {
- _aserror = ASINVPAR;
- return (0);
- }
-
- /********************************************************
- * First, send all the characters you can. If there is *
- * an error, return then with the count so far. *
- ********************************************************/
- for(xmit_count=0;*string;++string,++xmit_count) {
- if ((_aserror=asputc(port,(int)*string&255))!=ASSUCCESS)
- return(xmit_count);
- }
-
- /********************************************************
- * If option is 00..FF, send it and bump counter *
- ********************************************************/
- if(option >= 0) {
- if ((_aserror=asputc(port,option))!=ASSUCCESS)
- return(xmit_count);
- else
- ++xmit_count;
- }
-
- /********************************************************
- * If option is -2, send CR,LF sequence now *
- ********************************************************/
- if(option == -2) {
- if ((_aserror=asputc(port,0x0d))!=ASSUCCESS)
- return(xmit_count);
- else
- ++xmit_count;
- if ((_aserror=asputc(port,0x0a))!=ASSUCCESS)
- return(xmit_count);
- else
- ++xmit_count;
- }
-
- /********************************************************
- * Option is -1 so send nothing further. *
- ********************************************************/
- return (xmit_count);
- }
-
-