home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fred Fish Collection 1.5
/
ffcollection-1-5-1992-11.iso
/
ff_disks
/
300-399
/
ff369.lzh
/
VaxTerm
/
src
/
sendem.c
< prev
next >
Wrap
C/C++ Source or Header
|
1990-08-15
|
4KB
|
138 lines
#include <string.h>
#include <exec/types.h>
#include <exec/io.h>
#include <devices/keymap.h>
#include <hardware/blit.h>
#include <graphics/rastport.h>
#include <graphics/text.h>
#include <libraries/dos.h>
#include <intuition/intuition.h>
#include "main.h"
#define SETUPBUF 64
sendstring(register struct console *con,char *cp)
{
writeserial(con,cp,strlen(cp));
return(0);
}
convert(register struct console *con,register char *scp,register LONG len)
{
register USHORT nlen,cnt;
register char *dcp,*cp;
BPTR fp;
char setups[SETUPBUF];
dcp = con->conv;
cp = dcp;
nlen = len;
if (con->tstat & CONVERT) {
cnt = len;
while(cnt--) {
if (*scp & 0x80) {
switch (*scp) {
case IND:
*dcp++ = ESC;
*dcp++ = 'D';
scp++;
nlen++;
break;
case NEL:
*dcp++ = ESC;
*dcp++ = 'E';
scp++;
nlen++;
break;
case HTS:
*dcp++ = ESC;
*dcp++ = 'H';
scp++;
nlen++;
break;
case RI:
*dcp++ = ESC;
*dcp++ = 'M';
scp++;
nlen++;
break;
case SS2:
*dcp++ = ESC;
*dcp++ = 'N';
scp++;
nlen++;
break;
case SS3:
*dcp++ = ESC;
*dcp++ = 'O';
scp++;
nlen++;
break;
case DCS:
*dcp++ = ESC;
*dcp++ = 'P';
scp++;
nlen++;
break;
case CSI:
*dcp++ = ESC;
*dcp++ = '[';
scp++;
nlen++;
break;
case ST:
*dcp++ = ESC;
*dcp++ = '/';
scp++;
nlen++;
break;
default:
*dcp++ = *scp++;
break;
}
}
else *dcp++ = *scp++;
}
}
else memcpy(dcp,scp,len);
while (len--) {
switch (*cp) {
case PLD: if (con->gstat & HOLD) con->gstat &= (MASK - HOLD);
else con->gstat |= HOLD;
*cp = XON;
break;
case PLU: if (con->gstat & PRINT) con->gstat &= (MASK - PRINT);
else {
if (con->prt == NULL) {
if (con->prt = OPEN_FOR_WRITING(PRINTERNAME)) {
if (fp = OPEN_FOR_READING(PRINTERSETUP)) {
do {
cnt = READ(fp,setups,SETUPBUF);
WRITE(con->prt,setups,cnt);
} while (cnt == SETUPBUF);
CLOSEFILE(fp);
}
con->gstat |= PRINT;
}
}
else con->gstat |= PRINT;
}
*cp = XON;
break;
case STS: con->gstat |= SETUP;
*cp = XON;
break;
case PU1: con->gstat |= TRANSFER;
*cp = XON;
break;
case PU2: con->gstat |= SEND_BREAK;
*cp = XON;
break;
default: ;
}
cp++;
}
return((LONG)nlen);
}