static char sccsid
[] = "@(#)imsg.c 5.4 (Berkeley) %G%";
/* to talk to both eunice and x.25 without also screwing up tcp/ip
* we must adaptively choose what character to end the msg with
* The idea is that initially we send ....\000\n
* Then, after they have sent us a message, we use the first character
* this is the initial read message routine -
* used before a protocol is agreed upon.
* FAIL - no more messages
* SUCCESS - message returned
register char *msg
= amsg
;
DEBUG(5, "imsg looking for SYNC<", CNULL
);
if (read(fn
, &c
, 1) != 1)
if (c
== '\n' || c
== '\r')
DEBUG(5, (isprint(c
) || isspace(c
)) ? "%c" : "\\%o",
DEBUG(5, ">\nimsg input<", CNULL
);
} else if (foundsync
!= SUCCESS
)
if (c
== '\n' || c
== '\0') {
DEBUG(9, "\nUsing \\%o as End of message char\n", Mend
);
/* MAXFULLNAME should really be passed in as a parameter */
if (nchars
++ > MAXFULLNAME
) {
DEBUG(1, "buffer overrun in imsg", CNULL
);
DEBUG(5, ">got %d characters\n", strlen(amsg
));
* this is the initial write message routine -
* used before a protocol is agreed upon.
*c
= '\0'; /* avoid pdp 11/23,40 auto-incr stack trap bug */
DEBUG(5, "omsg <%s>\n", buf
);
write(fn
, buf
, (int)(c
- buf
));