From: Keith Vetter Date: Thu, 25 May 1995 18:34:40 +0000 (+0000) Subject: Windows telnet --fixed eol wrapping and general cleanup X-Git-Tag: krb5-1.0-beta6~1925 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=066683e65ebc6c68543c4b268484ca4fcc214c14;p=krb5.git Windows telnet --fixed eol wrapping and general cleanup git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@5875 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/windows/wintel/auth.c b/src/windows/wintel/auth.c index 6a7db7265..51e5d3f31 100644 --- a/src/windows/wintel/auth.c +++ b/src/windows/wintel/auth.c @@ -2,12 +2,16 @@ * Implements Kerberos 4 authentication */ -#include -#include #ifdef KRB4 + #include + #include + #include + #include "winsock.h" #include "kerberos.h" #endif #ifdef KRB5 + #include + #include #include "krb5.h" #include "des_int.h" #include "com_err.h" @@ -64,7 +68,9 @@ #define KRB_SERVICE_NAME "rcmd" #define KERBEROS_VERSION KERBEROS_V4 - static int k4_auth_send (void); + static int auth_how; + static int k4_auth_send (kstream ks); + static int k4_auth_reply (kstream ks, unsigned char *data, int cnt); #endif #ifdef KRB5 static krb5_data auth; @@ -119,7 +125,7 @@ auth_abort( if (r != KSUCCESS) { strcat(strTmp, "\n"); #ifdef KRB4 - lstrcat(strTmp, krb_get_err_text(r)); + lstrcat(strTmp, krb_get_err_text((int) r)); #endif #ifdef KRB5 lstrcat (strTmp, error_message(r)); @@ -202,7 +208,7 @@ auth_send( } #ifdef KRB4 - r = k4_auth_send (); + r = k4_auth_send (ks); #endif /* KRB4 */ #ifdef KRB5 @@ -392,10 +398,13 @@ auth_decrypt( ** Returns: 0 on failure, 1 on success */ static int -k4_auth_send () { +k4_auth_send ( + kstream ks) +{ int r; // Return value char instance[INST_SZ]; char *realm; + char buf[256]; memset(instance, 0, sizeof(instance)); @@ -432,8 +441,10 @@ k4_auth_send () { return r; } - if (szUserName[0]) // Copy if not there + if (!szUserName[0]) // Copy if not there strcpy (szUserName, cred.pname); + + return(1); } /*+ diff --git a/src/windows/wintel/changelo b/src/windows/wintel/changelo index 59c0eeb76..5812c6478 100644 --- a/src/windows/wintel/changelo +++ b/src/windows/wintel/changelo @@ -1,3 +1,11 @@ +Thu May 25 11:26:14 1995 John Rivlin + + * emul.c - make the eol wrapping to work properly. This fixed + numerous seemingly unrelated scrolling bugs. + * auth.c, intern.c, negotiat.c, screen.c, screen.h, telnet.c + telnet.h: removed level of indirection by using pointers rather + than handles; also cleaned up the formatting. + Thu Apr 27 12:00:00 1995 John Rivlin * edit.c, emul.c, font.c, intern.c, screen.c, telnet.c, screen.h diff --git a/src/windows/wintel/emul.c b/src/windows/wintel/emul.c index 0282866c3..e3f995cb5 100644 --- a/src/windows/wintel/emul.c +++ b/src/windows/wintel/emul.c @@ -3,86 +3,105 @@ #include "windows.h" #include "screen.h" -static int ScreenEmChar( + +static int ScreenEmChars( SCREEN *pScr, - unsigned char c) + char *c, + int len) { /* - Function: Send a character to the virtual screen with no translation. + Function: Send a string of characters to the screen. Placement + continues as long as the stream of characters does not contain any + control chracters or cause wrapping to another line. When a control + character is encountered or wrapping occurs, display stops and a + count of the number of characters is returned. + + Parameters: + pScr - the screen to place the characters on. + + c - the string of characters to place on the screen. + + len - the number of characters contained in the string + + Returns: The number of characters actually placed on the screen. */ - int sx; + int insert; int ocount; int attrib; int extra; - int offend; - char *acurrent; /* pointer to the attributes for characters drawn */ - char *current; /* pointer to the place to put characters */ + int nchars; + char *acurrent; /* place to put attributes */ + char *current; /* place to put characters */ char *start; SCREENLINE *pScrLine; + if (len <= 0) + return(0); + + if (pScr->x != pScr->width - 1) + pScr->bWrapPending = FALSE; + else { + if (pScr->bWrapPending) { + pScr->x = 0; + pScr->bWrapPending = FALSE; + ScreenIndex(pScr); + } + } + pScrLine = GetScreenLineFromY(pScr, pScr->y); if (pScrLine == NULL) - return(-1); - - current = start = &pScrLine->text[pScr->x]; + return(0); + + current = &pScrLine->text[pScr->x]; acurrent = &pScrLine->attrib[pScr->x]; + start = current; + ocount = pScr->x; + extra = 0; attrib = pScr->attrib; insert = pScr->IRM; - ocount = pScr->x; - offend = 0; - extra = 0; - sx = pScr->x; - if (pScr->x > pScr->width) { - if (pScr->DECAWM) { /* check for line wrapping on */ - pScr->x = 0; - ScreenIndex(pScr); - } - else /* no line wrapping */ - pScr->x = pScr->width; - current = start = &pScrLine->text[pScr->x]; - acurrent = &pScrLine->attrib[pScr->x]; - ocount = pScr->x; - sx = pScr->x; - } - if (insert) - ScreenInsChar(pScr, 1); - *current = c; - *acurrent = (char) attrib; - if (pScr->x < pScr->width) { - acurrent++; - current++; - pScr->x++; - } - else { - if(pScr->DECAWM) { + + for (nchars = 0; nchars < len && *c >= 32; nchars++) { + if (insert) + ScreenInsChar(pScr, 1); + + *current = *c; + *acurrent = (char) attrib; + c++; + if (pScr->x < pScr->width - 1) { + acurrent++; + current++; pScr->x++; - offend = 1; } else { - pScr->x = pScr->width; extra = 1; + if (pScr->DECAWM) { + pScr->bWrapPending = TRUE; + nchars++; + break; + } } } - if (insert) - ScreenInsString(pScr, pScr->x - ocount + offend + extra, start); /* actually just decides which RS to use */ - else - ScreenDraw(pScr, sx, pScr->y, pScr->attrib, pScr->x - ocount + offend + extra, start); -} /* ScreenEmChar */ + ScreenDraw(pScr, ocount, pScr->y, pScr->attrib, pScr->x - ocount + extra, start); + + return(nchars); + +} /* ScreenEmChars */ + void ScreenEm( LPSTR c, int len, SCREEN *pScr) { - SCREENLINE *pScrLine; - int escflg; /* vt100 escape level */ + int escflg; /* vt100 escape level */ RECT rc; unsigned int ic; char stat[20]; int i; + int nchars; if (pScr->screen_bottom != pScr->buffer_bottom) { ScreenUnscroll(pScr); @@ -94,7 +113,7 @@ void ScreenEm( escflg = pScr->escflg; #ifdef UM - if (pScr->localprint && len > 0) { /* see if printer needs anything */ + if (pScr->localprint && len > 0) { /* see if printer needs anything */ pcount = send_localprint(c, len); len -= pcount; c += pcount; @@ -105,44 +124,44 @@ void ScreenEm( while((*c < 32) && (escflg == 0) && (len > 0)) { /* look at first character in the vt100 string, if it is a non-printable ascii code */ switch(*c) { - case 0x1b: /* ESC found (begin vt100 control sequence) */ + case 0x1b: /* ESC found (begin vt100 control sequence) */ escflg++; break; - case -1: /* IAC from telnet session */ + case -1: /* IAC from telnet session */ escflg = 6; break; #ifdef CISB - case 0x05: /* CTRL-E found (answerback) */ + case 0x05: /* CTRL-E found (answerback) */ bp_ENQ(); break; #endif - case 0x07: /* CTRL-G found (bell) */ + case 0x07: /* CTRL-G found (bell) */ ScreenBell(pScr); break; - case 0x08: /* CTRL-H found (backspace) */ + case 0x08: /* CTRL-H found (backspace) */ ScreenBackspace(pScr); break; - case 0x09: /* CTRL-I found (tab) */ - ScreenTab(pScr); /* Later change for versatile tabbing */ + case 0x09: /* CTRL-I found (tab) */ + ScreenTab(pScr); /* Later change for versatile tabbing */ break; - case 0x0a: /* CTRL-J found (line feed) */ - case 0x0b: /* CTRL-K found (treat as line feed) */ - case 0x0c: /* CTRL-L found (treat as line feed) */ + case 0x0a: /* CTRL-J found (line feed) */ + case 0x0b: /* CTRL-K found (treat as line feed) */ + case 0x0c: /* CTRL-L found (treat as line feed) */ ScreenIndex(pScr); break; - case 0x0d: /* CTRL-M found (carriage feed) */ + case 0x0d: /* CTRL-M found (carriage feed) */ ScreenCarriageFeed(pScr); break; #if 0 - case 0x0e: /* CTRL-N found (invoke Graphics (G1) character set) */ + case 0x0e: /* CTRL-N found (invoke Graphics (G1) character set) */ if (pScr->G1) pScr->attrib = VSgraph(pScr->attrib); else @@ -150,7 +169,7 @@ void ScreenEm( pScr->charset = 1; break; - case 0x0f: /* CTRL-O found (invoke 'normal' (G0) character set) */ + case 0x0f: /* CTRL-O found (invoke 'normal' (G0) character set) */ if(pScr->G0) pScr->attrib = VSgraph(pScr->attrib); else @@ -160,178 +179,118 @@ void ScreenEm( #endif #ifdef CISB - case 0x10: /* CTRL-P found (undocumented in vt100) */ + case 0x10: /* CTRL-P found (undocumented in vt100) */ bp_DLE(c, len); len = 0; break; #endif #if 0 - case 0x11: /* CTRL-Q found (XON) (unused presently) */ - case 0x13: /* CTRL-S found (XOFF) (unused presently) */ - case 0x18: /* CTRL-X found (CAN) (unused presently) */ - case 0x1a: /* CTRL-Z found (SUB) (unused presently) */ + case 0x11: /* CTRL-Q found (XON) (unused presently) */ + case 0x13: /* CTRL-S found (XOFF) (unused presently) */ + case 0x18: /* CTRL-X found (CAN) (unused presently) */ + case 0x1a: /* CTRL-Z found (SUB) (unused presently) */ break; #endif } /* end switch */ - c++; /* advance to the next character in the string */ - len--; /* decrement the counter */ - - } /* end while */ - - if (escflg == 0) { /* check for normal character to print */ - while ((len > 0) && (*c >= 32)) { /* print out printable ascii chars, if we haven't found an ESCAPE char */ - int sx; - int insert; - int ocount; - int attrib; - int extra; - int offend; - char *acurrent; /* pointer to the attributes for characters drawn */ - char *current; /* pointer to the place to put characters */ - char *start; - - pScrLine = GetScreenLineFromY(pScr, pScr->y); - if (pScrLine == NULL) - return; - - current = start = &pScrLine->text[pScr->x]; - acurrent = &pScrLine->attrib[pScr->x]; - attrib = pScr->attrib; - insert = pScr->IRM; - ocount = pScr->x; - offend = 0; - extra = 0; - sx = pScr->x; - if (pScr->x > pScr->width) { - if (pScr->DECAWM) { /* check for line wrapping on */ - pScr->x = 0; - ScreenIndex(pScr); - } - else /* no line wrapping */ - pScr->x = pScr->width; - current = start = &pScrLine->text[pScr->x]; - acurrent = &pScrLine->attrib[pScr->x]; - ocount = pScr->x; - sx = pScr->x; - } - while ((len > 0) && (*c >= 32) && (offend == 0)) { - if (insert) - ScreenInsChar(pScr, 1); - *current = *c; - *acurrent = (char) attrib; - c++; - len--; - if (pScr->x < pScr->width) { - acurrent++; - current++; - pScr->x++; - } - else { - if (pScr->DECAWM) { - pScr->x++; - offend = 1; - } - else { - pScr->x = pScr->width; - extra = 1; - } - } - } - if (insert) - ScreenInsString(pScr, pScr->x - ocount + offend + extra, start); /* actually just decides which RS to use */ - else - ScreenDraw(pScr, sx, pScr->y, pScr->attrib, pScr->x - ocount + offend + extra, start); - } + c++; /* advance to the next character in the string */ + len--; /* decrement the counter */ + + } /* end while */ + + if (escflg == 0) { /* check for normal character to print */ + nchars = ScreenEmChars(pScr, c, len); + c += nchars; + len -= nchars; } - - while ((len > 0) && (escflg == 1)) { /* ESC character was found */ + + while ((len > 0) && (escflg == 1)) { /* ESC character was found */ switch(*c) { - case 0x08: /* CTRL-H found (backspace) */ + case 0x08: /* CTRL-H found (backspace) */ ScreenBackspace(pScr); break; - case '[': /* mostly cursor movement options, and DEC private stuff following */ + case '[': /* mostly cursor movement options, and DEC private stuff following */ ScreenApClear(pScr); escflg = 2; break; - case '#': /* various screen adjustments */ + case '#': /* various screen adjustments */ escflg = 3; break; - case '(': /* G0 character set options */ + case '(': /* G0 character set options */ escflg = 4; break; - case ')': /* G1 character set options */ + case ')': /* G1 character set options */ escflg = 5; break; - case '>': /* keypad numeric mode (DECKPAM) */ + case '>': /* keypad numeric mode (DECKPAM) */ pScr->DECPAM = 0; escflg = 0; break; - case '=': /* keypad application mode (DECKPAM) */ + case '=': /* keypad application mode (DECKPAM) */ pScr->DECPAM = 1; escflg = 0; break; - case '7': /* save cursor (DECSC) */ + case '7': /* save cursor (DECSC) */ ScreenSaveCursor(pScr); escflg = 0; break; - case '8': /* restore cursor (DECRC) */ + case '8': /* restore cursor (DECRC) */ ScreenRestoreCursor(pScr); escflg = 0; break; #if 0 - case 'c': /* reset to initial state (RIS) */ + case 'c': /* reset to initial state (RIS) */ ScreenReset(pScr); escflg = 0; break; #endif - case 'D': /* index (move down one line) (IND) */ + case 'D': /* index (move down one line) (IND) */ ScreenIndex(pScr); escflg = 0; break; - case 'E': /* next line (move down one line and to first column) (NEL) */ + case 'E': /* next line (move down one line and to first column) (NEL) */ pScr->x = 0; ScreenIndex(pScr); escflg = 0; break; - case 'H': /* horizontal tab set (HTS) */ + case 'H': /* horizontal tab set (HTS) */ pScr->tabs[pScr->x] = 'x'; escflg = 0; break; #ifdef CISB - case 'I': /* undoumented in vt100 */ + case 'I': /* undoumented in vt100 */ bp_ESC_I(); break; #endif - case 'M': /* reverse index (move up one line) (RI) */ + case 'M': /* reverse index (move up one line) (RI) */ ScreenRevIndex(pScr); escflg = 0; break; - case 'Z': /* identify terminal (DECID) */ + case 'Z': /* identify terminal (DECID) */ escflg = 0; break; default: - ScreenEmChar(pScr, 0x1b); /* put the ESC character into the Screen */ - ScreenEmChar(pScr, *c); /* put the next character into the Screen */ + ScreenEmChars(pScr, "\033", 1); /* put the ESC character into the Screen */ + ScreenEmChars(pScr, c, 1); /* put the next character into the Screen */ escflg = 0; break; @@ -344,7 +303,7 @@ void ScreenEm( while((escflg == 2) && (len > 0)) { /* '[' handling */ switch(*c) { - case 0x08: /* backspace */ + case 0x08: /* backspace */ ScreenBackspace(pScr); break; @@ -357,22 +316,23 @@ void ScreenEm( case '6': case '7': case '8': - case '9': /* numeric parameters */ + case '9': /* numeric parameters */ if (pScr->parms[pScr->parmptr] < 0) pScr->parms[pScr->parmptr] = 0; pScr->parms[pScr->parmptr] *= 10; pScr->parms[pScr->parmptr] += *c - '0'; break; - case '?': /* vt100 mode change */ + case '?': /* vt100 mode change */ pScr->parms[pScr->parmptr++] = -2; break; - case ';': /* parameter divider */ + case ';': /* parameter divider */ pScr->parmptr++; break; - case 'A': /* cursor up (CUU) */ + case 'A': /* cursor up (CUU) */ + pScr->bWrapPending = FALSE; rc.left = pScr->x * pScr->cxChar; rc.right = (pScr->x + 1) * pScr->cxChar; rc.top = pScr->cyChar * pScr->y; @@ -389,7 +349,8 @@ void ScreenEm( SendMessage(pScr->hWnd, WM_PAINT, NULL, NULL); break; - case 'B': /* cursor down (CUD) */ + case 'B': /* cursor down (CUD) */ + pScr->bWrapPending = FALSE; rc.left = pScr->x * pScr->cxChar; rc.right = (pScr->x + 1) * pScr->cxChar; rc.top = pScr->cyChar * pScr->y; @@ -406,7 +367,8 @@ void ScreenEm( SendMessage(pScr->hWnd, WM_PAINT, NULL, NULL); break; - case 'C': /* cursor forward (right) (CUF) */ + case 'C': /* cursor forward (right) (CUF) */ + pScr->bWrapPending = FALSE; rc.left = pScr->x * pScr->cxChar; rc.right = (pScr->x + 1) * pScr->cxChar; rc.top = pScr->cyChar * pScr->y; @@ -423,7 +385,8 @@ void ScreenEm( SendMessage(pScr->hWnd, WM_PAINT, NULL, NULL); break; - case 'D': /* cursor backward (left) (CUB) */ + case 'D': /* cursor backward (left) (CUB) */ + pScr->bWrapPending = FALSE; rc.left = pScr->x * pScr->cxChar; rc.right = (pScr->x + 1) * pScr->cxChar; rc.top = pScr->cyChar * pScr->y; @@ -438,8 +401,9 @@ void ScreenEm( SendMessage(pScr->hWnd, WM_PAINT, NULL, NULL); break; - case 'f': /* horizontal & vertical position (HVP) */ - case 'H': /* cursor position (CUP) */ + case 'f': /* horizontal & vertical position (HVP) */ + case 'H': /* cursor position (CUP) */ + pScr->bWrapPending = FALSE; rc.left = pScr->x * pScr->cxChar; rc.right = (pScr->x + 1) * pScr->cxChar; rc.top = pScr->cyChar * pScr->y; @@ -447,25 +411,25 @@ void ScreenEm( InvalidateRect(pScr->hWnd, &rc, TRUE); pScr->x = pScr->parms[1] - 1; pScr->y = pScr->parms[0] - 1; - ScreenRange(pScr); /* make certain the cursor position is valid */ + ScreenRange(pScr); /* make certain the cursor position is valid */ escflg = 0; SendMessage(pScr->hWnd, WM_PAINT, NULL, NULL); break; - case 'J': /* erase in display (ED) */ + case 'J': /* erase in display (ED) */ switch(pScr->parms[0]) { case -1: - case 0: /* erase from active position to end of screen */ + case 0: /* erase from active position to end of screen */ ScreenEraseToEndOfScreen(pScr); break; - case 1: /* erase from start of screen to active position */ + case 1: /* erase from start of screen to active position */ #if 0 ScreenEraseToPosition(pScr); #endif break; - case 2: /* erase whole screen */ + case 2: /* erase whole screen */ ScreenEraseScreen(pScr); break; @@ -476,18 +440,18 @@ void ScreenEm( escflg = 0; break; - case 'K': /* erase in line (EL) */ + case 'K': /* erase in line (EL) */ switch(pScr->parms[0]) { case -1: - case 0: /* erase to end of line */ + case 0: /* erase to end of line */ ScreenEraseToEOL(pScr); break; - case 1: /* erase to beginning of line */ + case 1: /* erase to beginning of line */ ScreenEraseToBOL(pScr); break; - case 2: /* erase whole line */ + case 2: /* erase whole line */ ScreenEraseLine(pScr, -1); break; @@ -498,21 +462,21 @@ void ScreenEm( escflg = 0; break; - case 'L': /* insert n lines preceding current line (IL) */ + case 'L': /* insert n lines preceding current line (IL) */ if (pScr->parms[0] < 1) pScr->parms[0] = 1; ScreenInsLines(pScr, pScr->parms[0], -1); escflg = 0; break; - case 'M': /* delete n lines from current position downward (DL) */ + case 'M': /* delete n lines from current position downward (DL) */ if (pScr->parms[0] < 1) pScr->parms[0] = 1; ScreenDelLines(pScr, pScr->parms[0], -1); escflg = 0; break; - case 'P': /* delete n chars from cursor to the left (DCH) */ + case 'P': /* delete n chars from cursor to the left (DCH) */ if (pScr->parms[0] < 1) pScr->parms[0] = 1; ScreenDelChars(pScr, pScr->parms[0]); @@ -520,19 +484,19 @@ void ScreenEm( break; #if 0 - case 'R': /* receive cursor position status from host */ + case 'R': /* receive cursor position status from host */ break; #endif #if 0 - case 'c': /* device attributes (DA) */ + case 'c': /* device attributes (DA) */ ScreenSendIdent(); escflg = 0; break; #endif - case 'g': /* tabulation clear (TBC) */ - if (pScr->parms[0] == 3) /* clear all tabs */ + case 'g': /* tabulation clear (TBC) */ + if (pScr->parms[0] == 3)/* clear all tabs */ ScreenTabClear(pScr); else if (pScr->parms[0] <= 0) /* clear tab stop at active position */ @@ -540,12 +504,12 @@ void ScreenEm( escflg = 0; break; - case 'h': /* set mode (SM) */ + case 'h': /* set mode (SM) */ // ScreenSetOption(pScr,1); escflg = 0; break; - case 'i': /* toggle printer */ + case 'i': /* toggle printer */ #if 0 if(pScr->parms[pScr->parmptr] == 5) pScr->localprint = 1; @@ -555,12 +519,12 @@ void ScreenEm( escflg = 0; break; - case 'l': /* reset mode (RM) */ + case 'l': /* reset mode (RM) */ // ScreenSetOption(pScr,0); escflg = 0; break; - case 'm': /* select graphics rendition (SGR) */ + case 'm': /* select graphics rendition (SGR) */ { int temp = 0; @@ -575,15 +539,15 @@ void ScreenEm( escflg = 0; break; - case 'n': /* device status report (DSR) */ + case 'n': /* device status report (DSR) */ switch (pScr->parms[0]) { #if 0 - case 0: /* response from vt100; ready, no malfunctions */ - case 3: /* response from vt100; malfunction, retry */ + case 0: /* response from vt100; ready, no malfunctions */ + case 3: /* response from vt100; malfunction, retry */ #endif - case 5: /* send status */ - case 6: /* send active position */ - wsprintf(stat, "\033[%d;%dR", pScr->y, pScr->x); + case 5: /* send status */ + case 6: /* send active position */ + wsprintf(stat, "\033[%d;%dR", pScr->y + 1, pScr->x + 1); for (i = 0; stat[i]; i++) SendMessage(pScr->hwndTel, WM_MYSCREENCHAR, stat[i], (LPARAM) pScr); break; @@ -591,11 +555,11 @@ void ScreenEm( escflg = 0; break; - case 'q': /* load LEDs (unsupported) (DECLL) */ + case 'q': /* load LEDs (unsupported) (DECLL) */ escflg = 0; break; - case 'r': /* set top & bottom margins (DECSTBM) */ + case 'r': /* set top & bottom margins (DECSTBM) */ if (pScr->parms[0] < 0) pScr->top = 0; else @@ -622,14 +586,14 @@ void ScreenEm( pScr->y = 0; #if 0 if (pScr->DECORG) - pScr->y = pScr->top; /* origin mode relative */ + pScr->y = pScr->top; /* origin mode relative */ #endif escflg = 0; break; #if 0 - case 'x': /* request/report terminal parameters (DECREQTPARM/DECREPTPARM) */ - case 'y': /* invoke confidence test (DECTST) */ + case 'x': /* request/report terminal parameters (DECREQTPARM/DECREPTPARM) */ + case 'y': /* invoke confidence test (DECTST) */ break; #endif @@ -653,19 +617,19 @@ void ScreenEm( while ((escflg == 3) && (len > 0)) { /* # Handling */ switch (*c) { - case 0x08: /* backspace */ + case 0x08: /* backspace */ ScreenBackspace(pScr); break; #if 0 - case '3': /* top half of double line (DECDHL) */ - case '4': /* bottom half of double line (DECDHL) */ - case '5': /* single width line (DECSWL) */ - case '6': /* double width line (DECDWL) */ + case '3': /* top half of double line (DECDHL) */ + case '4': /* bottom half of double line (DECDHL) */ + case '5': /* single width line (DECSWL) */ + case '6': /* double width line (DECDWL) */ break; #endif - case '8': /* screen alignment display (DECALN) */ + case '8': /* screen alignment display (DECALN) */ ScreenAlign(pScr); escflg = 0; break; @@ -683,7 +647,7 @@ void ScreenEm( while ((escflg == 4) && (len > 0)) { /* ( Handling (GO character set) */ switch (*c) { - case 0x08: /* backspace */ + case 0x08: /* backspace */ ScreenBackspace(pScr); break; @@ -719,7 +683,7 @@ void ScreenEm( while((escflg == 5) && (len > 0)) { /* ) Handling (G1 handling) */ switch (*c) { - case 0x08: /* backspace */ + case 0x08: /* backspace */ ScreenBackspace(pScr); break; @@ -755,33 +719,33 @@ void ScreenEm( ic = (unsigned char) *c; switch (escflg) { - case 6: /* Handling IAC xx */ - if (ic == 255) /* if IAC */ + case 6: /* Handling IAC xx */ + if (ic == 255) /* if IAC */ escflg = 0; - else if (ic == 250) /* if SB */ + else if (ic == 250) /* if SB */ escflg = 7; else escflg = 9; break; - case 7: /* Handling IAC SB xx */ - if (ic == 255) /* if IAC */ + case 7: /* Handling IAC SB xx */ + if (ic == 255) /* if IAC */ escflg = 8; break; - case 8: /* Handling IAC SB IAC xx */ - if (ic == 255) /* if IAC IAC */ + case 8: /* Handling IAC SB IAC xx */ + if (ic == 255) /* if IAC IAC */ escflg = 7; - else if (ic == 240) /* if IAC SE */ + else if (ic == 240) /* if IAC SE */ escflg = 0; break; - case 9: /* IAC xx xx */ + case 9: /* IAC xx xx */ escflg = 0; break; } - c++; /* advance to the next character in the string */ - len--; /* decrement the counter */ + c++; /* advance to the next character in the string */ + len--; /* decrement the counter */ } if (escflg > 2 && escflg < 6 && len > 0) { diff --git a/src/windows/wintel/intern.c b/src/windows/wintel/intern.c index ab01cb380..703ee0254 100644 --- a/src/windows/wintel/intern.c +++ b/src/windows/wintel/intern.c @@ -163,6 +163,7 @@ void ScreenReset( pScr->parmptr = 0; pScr->escflg = 0; pScr->DECAWM = 1; + pScr->bWrapPending = FALSE; pScr->DECCKM = 0; pScr->DECPAM = 0; /* pScr->DECORG = 0; */ @@ -217,6 +218,8 @@ void ScreenDelLines( RECT rc; HDC hDC; + pScr->bWrapPending = FALSE; + if (s < 0) s = pScr->y; @@ -305,8 +308,7 @@ void ScreenInsLines( RECT rc; HDC hDC; -// wsprintf(strTmp, "ScreenInsLine (n=%d s=%d)", n, s); -// OutputDebugString(strTmp); + pScr->bWrapPending = FALSE; if (s < 0) s = pScr->y; @@ -386,7 +388,9 @@ void ScreenIndex( if (pScr->y >= pScr->bottom) ScreenScroll(pScr); else - pScr->y++; + pScr->y++; + + pScr->bWrapPending = FALSE; } /* ScreenIndex */ @@ -396,11 +400,13 @@ void ScreenWrapNow( int *xp, int *yp) { - if (pScr->x > pScr->width) { + if (pScr->bWrapPending && pScr->x >= pScr->width - 1) { pScr->x = 0; ScreenIndex(pScr); } + pScr->bWrapPending = FALSE; + *xp = pScr->x; *yp = pScr->y; @@ -446,6 +452,8 @@ void ScreenDelChars( SCREENLINE *pScrLine; RECT rc; + pScr->bWrapPending = FALSE; + pScrLine = GetScreenLineFromY(pScr, y); width = pScr->width - x - n; @@ -476,6 +484,7 @@ void ScreenRevIndex( SCREENLINE *pScrLine; SCREENLINE *pTopLine; + pScr->bWrapPending = FALSE; pScrLine = GetScreenLineFromY(pScr, pScr->y); pTopLine = GetScreenLineFromY(pScr, pScr->top); @@ -565,16 +574,11 @@ void ScreenEraseToEndOfScreen( void ScreenRange( SCREEN *pScr) { - int wrap = 0; - - if (pScr->DECAWM) - wrap = 1; - if (pScr->x < 0) pScr->x = 0; - if (pScr->x > pScr->width + wrap) - pScr->x = pScr->width + wrap; + if (pScr->x >= pScr->width) + pScr->x = pScr->width - 1; if (pScr->y < 0) pScr->y = 0; @@ -707,9 +711,6 @@ int ScreenInsChar( SCREENLINE *pScrLine; RECT rc; -// ScreenWrapNow(&i,&j); /* JEM- Why is this here? comment out for now */ - -// OutputDebugString("OOPS-InsChar!"); pScrLine = GetScreenLineFromY(pScr, pScr->y); if (pScrLine == NULL) return(-1); @@ -721,13 +722,8 @@ int ScreenInsChar( memset(&pScrLine->attrib[pScr->x], ScreenClearAttrib, x); memset(&pScrLine->text[pScr->x], ' ', x); - - for(i = pScr->x; i < pScr->x + x; i++) { - pScrLine->text[i] = ' '; - pScrLine->attrib[i] = ScreenClearAttrib; - } rc.left = pScr->cxChar * x; - rc.right = (pScr->cxChar * x) + (pScr->cxChar * (x + pScr->x)); + rc.right = pScr->cxChar * (x + pScr->x); rc.top = pScr->cyChar * (pScr->y - 1); rc.bottom = pScr->cyChar * pScr->y; InvalidateRect(pScr->hWnd, &rc, TRUE); @@ -736,37 +732,6 @@ int ScreenInsChar( } /* ScreenInsChar */ -void ScreenInsString( - SCREEN *pScr, - int len, - char *start) -{ - SCREENLINE *pScrLine; - int idx; - RECT rc; - - if (pScr->VSIDC) - return; - - pScrLine = GetScreenLineFromY(pScr, pScr->y); - if (pScrLine == NULL) - return; - - for(idx = pScr->x; idx < pScr->x + len; idx++) { - pScrLine->text[idx] = start[idx]; - pScrLine->attrib[idx] = pScr->attrib; - } - rc.left = pScr->cxChar * pScr->x; - rc.right = pScr->cxChar * pScr->x + pScr->cxChar * (pScr->x + len); - rc.top = pScr->cyChar * pScr->y; - rc.bottom = pScr->cyChar * (pScr->y + 1); - - InvalidateRect(pScr->hWnd, &rc, TRUE); - SendMessage(pScr->hWnd, WM_PAINT, NULL, NULL); - -} /* ScreenInsString */ - - void ScreenSaveCursor( SCREEN *pScr) { diff --git a/src/windows/wintel/negotiat.c b/src/windows/wintel/negotiat.c index abace443f..58bf97d90 100644 --- a/src/windows/wintel/negotiat.c +++ b/src/windows/wintel/negotiat.c @@ -201,10 +201,10 @@ start_negotiation(kstream ks) if(tw->mapoutput) { netprintf(tw->pnum,"%c%c%c",IAC,DOTEL,BINARY); /* set the flag indicating we wanted server to start transmitting binary */ - tw->uwantbinary=1; + tw->uwantbinary=1; netprintf(tw->pnum,"%c%c%c",IAC,WILLTEL,BINARY); /* set the flag indicating we want to start transmitting binary */ - tw->iwantbinary=1; + tw->iwantbinary=1; } /* end if */ #endif @@ -746,7 +746,9 @@ parse_subnegotiat(kstream ks,int end_sub) { default: break; } /* end switch */ -} /* end parse_subnegotiat() */ +} /* parse_subnegotiat */ + + /*+******************************************************************** * Function : send_naws * Purpose : Send a window size sub-negotiation. @@ -755,8 +757,9 @@ parse_subnegotiat(kstream ks,int end_sub) { * Returns : none **********************************************************************/ void -send_naws(CONNECTION *con) { - unsigned char buf[13]; +send_naws(CONNECTION *con) +{ + unsigned char buf[40]; int len; wsprintf(buf, "%c%c%c", IAC, SB, NAWS); @@ -779,10 +782,11 @@ send_naws(CONNECTION *con) { TelnetSend(con->ks, buf, len, 0); -#ifdef NEGOTIATEDEBUG -/// wsprintf(buf, "SEND: SB NAWS %d %d %d %d IAC SE\r\n", -/// HIBYTE(con->width), LOBYTE(con->width), -/// HIBYTE(con->height), LOBYTE(con->height)); -/// OutputDebugString(buf); -#endif + #ifdef NEGOTIATEDEBUG + wsprintf(buf, "SEND: SB NAWS %d %d %d %d IAC SE\r\n", + HIBYTE(con->width), LOBYTE(con->width), + HIBYTE(con->height), LOBYTE(con->height)); + OutputDebugString(buf); + #endif + } /* send_naws */ diff --git a/src/windows/wintel/screen.c b/src/windows/wintel/screen.c index 75d90d3a7..da1fc1b23 100644 --- a/src/windows/wintel/screen.c +++ b/src/windows/wintel/screen.c @@ -193,6 +193,7 @@ SCREEN *InitNewScreen( scr->Oldy = 0; scr->attrib = 0; scr->DECAWM = 1; + scr->bWrapPending = FALSE; scr->top = 0; scr->bottom = scr->height-1; scr->parmptr = 0; @@ -1061,13 +1062,7 @@ void ScreenBackspace(SCREEN *pScr) { RECT rc; - #if 0 - hDC = GetDC(fpScr->hWnd); - assert(hDC != NULL); - SelectObject(hDC, fpScr->ghSelectedFont); - TextOut(hDC, pScr->x * pScr->cxChar, pScr->y * pScr->cyChar, " ", 1); - ReleaseDC(pScr->hWnd, hDC); - #endif + pScr->bWrapPending = FALSE; rc.left = pScr->x * pScr->cxChar; rc.right = (pScr->x + 1) * pScr->cxChar; rc.top = pScr->cyChar * pScr->y; @@ -1091,15 +1086,12 @@ void ScreenTab( HDC hDC; num_spaces = TAB_SPACES - (pScr->x % TAB_SPACES); - if (pScr->x + num_spaces >= pScr->width) { - ScreenScroll(pScr); - num_spaces -= pScr->width - pScr->x; - pScr->x = 0; - } + if (pScr->x + num_spaces >= pScr->width) + num_spaces = pScr->width - pScr->x; pScrLine = GetScreenLineFromY(pScr, pScr->y); if (pScrLine == NULL) return; - for (idx = 0; idxx++) { + for (idx = 0; idx < num_spaces; idx++, pScr->x++) { if (!pScrLine->text[pScr->x]) iTest=1; if (iTest) @@ -1110,7 +1102,10 @@ void ScreenTab( SelectObject(hDC, pScr->hSelectedFont); TextOut(hDC, (pScr->x - num_spaces) * pScr->cxChar, pScr->y * pScr->cyChar, pScrLine->text + pScr->x - num_spaces, num_spaces); - ReleaseDC(pScr->hWnd, hDC); + ReleaseDC(pScr->hWnd, hDC); + if (pScr->x >= pScr->width) + pScr->x = pScr->width - 1; + pScr->bWrapPending = FALSE; } /* ScreenTab */ @@ -1118,6 +1113,7 @@ void ScreenTab( void ScreenCarriageFeed( SCREEN *pScr) { + pScr->bWrapPending = FALSE; pScr->x = 0; } /* ScreenCarriageFeed */ diff --git a/src/windows/wintel/screen.h b/src/windows/wintel/screen.h index a8599cf14..0864e0366 100644 --- a/src/windows/wintel/screen.h +++ b/src/windows/wintel/screen.h @@ -76,6 +76,7 @@ typedef struct SCREEN { int Pattrib; int VSIDC; // Insert/Delete character mode 0=draw line int DECAWM; // AutoWrap mode 0=off + BOOL bWrapPending; // AutoWrap mode is on - wrap on next character int DECCKM; // Cursor key mode int DECPAM; // keyPad Application mode int IRM; // Insert/Replace mode @@ -237,11 +238,6 @@ intern.c SCREEN *pScr, int x); - void ScreenInsString( - SCREEN *pScr, - int len, - char *start); - void ScreenSaveCursor( SCREEN *pScr); diff --git a/src/windows/wintel/telnet.c b/src/windows/wintel/telnet.c index ee4683e58..7bcd3d2da 100644 --- a/src/windows/wintel/telnet.c +++ b/src/windows/wintel/telnet.c @@ -35,7 +35,7 @@ static char hostdata[MAXGETHOSTSTRUCT]; static SCREEN *pScr; static int debug = 1; -char __near strTmp[1024]; // Scratch buffer +char strTmp[1024]; // Scratch buffer BOOL bAutoConnection = FALSE; int port_no = 23; char szUserName[64]; // Used in auth.c diff --git a/src/windows/wintel/telnet.h b/src/windows/wintel/telnet.h index 5694f9f5f..3a69dd1f2 100644 --- a/src/windows/wintel/telnet.h +++ b/src/windows/wintel/telnet.h @@ -33,7 +33,7 @@ extern void parse( extern void send_naws( CONNECTION *con); -extern char __near strTmp[]; +extern char strTmp[1024]; #define DEF_WIDTH 80 #define DEF_HEIGHT 24