#include #include #include #define ERROR (-1) #define DLE 0x10 #define TIMEOUT 30 /* * get a non-protocolled message from the other side */ imsg(buf) register char *buf; { extern int Debug; char *first; register c; while (1) { c = receive(TIMEOUT); if (c == ERROR) return EOF; else if ((c &= 0x7f) == DLE) break; else if (Debug > 4) putc(c, stderr); } first = buf; while ((c=receive(TIMEOUT)) != ERROR) { if ((c &= 0x7f) == DLE) buf = first; else if ((*buf++ = c) == '\n' || c == '\0') { *buf = 0; return 0; } } return ERROR; } /* imsg */ /* * write a non-protocoled msg to the other machine. */ void omsg(msg) char *msg; { va_list ptr; char pkt[128]; ttyout(DLE); va_start(ptr, msg); vsprintf(pkt, msg, ptr); va_end(ptr); ttywrite(pkt, strlen(pkt)); ttywrite("\000\n", 2); } /* omsg */