- default:
- return current+2;
- }
-}
-/*
- * netclear()
- *
- * We are about to do a TELNET SYNCH operation. Clear
- * the path to the network.
- *
- * Things are a bit tricky since we may have sent the first
- * byte or so of a previous TELNET command into the network.
- * So, we have to scan the network buffer from the beginning
- * until we are up to where we want to be.
- *
- * A side effect of what we do, just to keep things
- * simple, is to clear the urgent data pointer. The principal
- * caller should be setting the urgent data pointer AFTER calling
- * us in any case.
- */
-
-static void
-netclear()
-{
- register char *thisitem, *next;
- char *good;
-#define wewant(p) ((nfrontp > p) && ((*p&0xff) == IAC) && \
- ((*(p+1)&0xff) != EC) && ((*(p+1)&0xff) != EL))
-
- thisitem = netobuf;
-
- while ((next = nextitem(thisitem)) <= nbackp) {
- thisitem = next;
- }
-
- /* Now, thisitem is first before/at boundary. */
-
- good = netobuf; /* where the good bytes go */
-
- while (nfrontp > thisitem) {
- if (wewant(thisitem)) {
- int length;
-
- next = thisitem;
- do {
- next = nextitem(next);
- } while (wewant(next) && (nfrontp > next));
- length = next-thisitem;
- memcpy(good, thisitem, length);
- good += length;
- thisitem = next;
- } else {
- thisitem = nextitem(thisitem);
- }
- }
-
- nbackp = netobuf;
- nfrontp = good; /* next byte to be sent */
- neturg = 0;
-}
-\f
-/*
- * These routines add various telnet commands to the data stream.
- */
-
-void
-xmitAO()
-{
- NET2ADD(IAC, AO);
- if (autoflush) {
- doflush();
- }
-}
-
-
-void
-xmitEL()
-{
- NET2ADD(IAC, EL);
-}
-
-void
-xmitEC()
-{
- NET2ADD(IAC, EC);
-}
-
-
-#if defined(NOT43)
-int
-#else /* defined(NOT43) */
-void
-#endif /* defined(NOT43) */
-dosynch()
-{
- netclear(); /* clear the path to the network */
- NET2ADD(IAC, DM);
- neturg = NETLOC()-1; /* Some systems are off by one XXX */
-
-#if defined(NOT43)
- return 0;
-#endif /* defined(NOT43) */
-}
-
-void
-doflush()
-{
- NET2ADD(IAC, DO);
- NETADD(TELOPT_TM);
- flushline = 1;
- flushout = 1;
- ttyflush();
- /* do printoption AFTER flush, otherwise the output gets tossed... */
- printoption("<SENT", doopt, TELOPT_TM, 0);
-}
-
-void
-intp()
-{
- NET2ADD(IAC, IP);
- if (autoflush) {
- doflush();
- }
- if (autosynch) {
- dosynch();
- }
-}
-
-void
-sendbrk()
-{
- NET2ADD(IAC, BREAK);
- if (autoflush) {
- doflush();
- }
- if (autosynch) {
- dosynch();