home *** CD-ROM | disk | FTP | other *** search
- /* asputc.c
- *
- * The Greenleaf Comm Library
- *
- * Copyright (C) 1985-1990 Greenleaf Software Inc. All Rights Reserved.
- *
- * int asputc( port, c )
- * int port; - Port 0..MAX_PORT-1
- * char c;
- *
- * DESCRIPTION
- * this function transmits a character via "polled" mode.
- *
- * SIDE EFFECTS
- * Turns off interrupts while sending.
- *
- * RETURNS
- *
- * Value Meaning
- * ------ -------
- * ASSUCCESS Successful (No error(s))
- * ASINVPORT Requested port is out of range
- * ASNOTSETUP Requested port not setup with asifirst()
- * ASNOCTS CTS was not active
- *
- * MODIFICATIONS
- *
- * 10-29-85 ""
- * Modified for release 2.0
- * 26-FEB-1987 17:37:04.46
- * Modified to use new asputc() function.
- */
- #include <stdio.h>
- #include "gf.h"
- #include "asiports.h"
-
- int GF_CONV asputc( port,character )
- int port,
- character;
- {
- int iret,timeout,finished;
- unsigned pv=0;
- struct PORT_TABLE *p;
-
- if((p=_aschkcnl(port))==NULL)
- return(_aserror);
- if(p->chmode_bits.is_txint) {
- pv|=ASOUT;
- asihold(port,ASOUT);
- }
- if(p->chmode_bits.is_rxint)
- pv|=ASIN;
- timeout=p->aswtime;
- if(p->chmode_bits.is_ascii)
- character&=0x007f;
- for(finished=0;!finished;) {
- if(p->aswmodem && (iscts(port,DIRECT)==0)) {
- iret = ASNOCTS;
- ++finished;
- continue;
- }
- if(_asputc(p->base_8250,character)==ASSUCCESS) {
- iret = ASSUCCESS;
- ++finished;
- continue;
- }
- if(!timeout) {
- iret= ASTIMEOUT;
- ++finished;
- continue;
- }
- timer(1);
- --timeout;
- }
- if(pv)
- asiresume(port,pv);
- return(iret);
- }
-
-