Files
Digital-Research-Source-Code/CPM OPERATING SYSTEMS/CPM 68K/1.0X SOURCES/v102a/clib/ttyout.c
Sepp J Morris 31738079c4 Upload
Digital Research
2020-11-06 18:50:37 +01:00

42 lines
1.6 KiB
C

/***************************************************************************
*
* _ t t y o u t F u n c t i o n
* -------------------------------
*
* Function "_ttyout" is called to perform "write" operations to the
* console device.
*
* Calling Sequence:
* ret = _ttyout(buffer);
*
* Where:
* buffer -> the output buffer (byte 0 is count)
* ret = count on return
****************************************************************************/
#include "portab.h"
#include "osif.h"
WORD _ttyout(buf) /***************************/
/* */
REG BYTE *buf; /* -> 1st char output */
{ /***************************/
REG WORD ii; /* counter for '$' check */
WORD count; /* = # bytes to xfer */
BYTE *cp; /* ptr for '$' check */
/* */
count = *buf++; /* Get num bytes to output */
buf[count] = '$'; /* Terminate string */
for(ii=0, cp=buf; ii<count; ++ii) /* Check for internal '$' */
if( buf[ii] == '$' ) /* Found one? */
{ /* Yes... */
if( *cp != '$' ) /* If '$' not at start */
__OSIF(C_WRITESTR,cp); /* Print the string */
__OSIF(CONOUT,'$'); /* And output the '$' */
cp = &buf[ii+1]; /* Reset start of string */
} /******** */
if( cp != &buf[ii] ) /* Assuming we haven't yet */
__OSIF(C_WRITESTR,cp); /* Output the rest */
/* */
return(count); /* return original count */
} /***************************/