Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Commit

Permalink
Robert de Bath's Big Patch, part 1
Browse files Browse the repository at this point in the history
[originally from svn r516]
  • Loading branch information
sgtatham committed Jul 26, 2000
1 parent 1657255 commit 0d5d390
Show file tree
Hide file tree
Showing 11 changed files with 1,214 additions and 685 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ CFLAGS = /nologo /W3 /YX /O2 /Yd /D_WINDOWS /DDEBUG /ML /Fd
# LFLAGS = /debug

# Use MSVC DLL
# CFLAGS = /nologo /W3 /YX /O2 /Yd /D_WINDOWS /DDEBUG /ML /Fd
# CFLAGS = /nologo /W3 /YX /O2 /Yd /D_WINDOWS /DDEBUG /MD /Fd

# Disable debug and incremental linking
LFLAGS = /incremental:no
Expand Down
12 changes: 3 additions & 9 deletions ldisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,8 @@
*/

static void c_write (char *buf, int len) {
while (len--) {
int new_head = (inbuf_head + 1) & INBUF_MASK;
if (new_head != inbuf_reap) {
inbuf[inbuf_head] = *buf++;
inbuf_head = new_head;
}
}
while (len--)
c_write1(*buf++);
}

static char *term_buf = NULL;
Expand All @@ -34,8 +29,7 @@ static int plen(unsigned char c) {
static void pwrite(unsigned char c) {
if ((c >= 32 && c <= 126) ||
(c >= 160)) {
char cc = (char)c;
c_write(&cc, 1);
c_write1(c);
} else if (c < 128) {
char cc[2];
cc[1] = (c == 127 ? '?' : c + 0x40);
Expand Down
41 changes: 25 additions & 16 deletions putty.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ GLOBAL HINSTANCE putty_inst;
#define ATTR_INVALID 0x20000000UL
#define ATTR_WRAPPED 0x10000000UL

#define LATTR_NORM 0x00000000UL
#define LATTR_WIDE 0x01000000UL
#define LATTR_TOP 0x02000000UL
#define LATTR_BOT 0x03000000UL
#define LATTR_MODE 0x03000000UL

#define ATTR_ASCII 0x00000000UL /* normal ASCII charset ESC ( B */
#define ATTR_GBCHR 0x00100000UL /* UK variant charset ESC ( A */
#define ATTR_LINEDRW 0x00200000UL /* line drawing charset ESC ( 0 */
Expand Down Expand Up @@ -49,10 +55,11 @@ GLOBAL int rows, cols, savelines;

GLOBAL int font_width, font_height;

#define c_write1(_C) do { if (inbuf_head >= INBUF_SIZE) term_out(); \
inbuf[inbuf_head++] = (_C) ; } while(0)
#define INBUF_SIZE 2048
#define INBUF_MASK (INBUF_SIZE-1)
GLOBAL unsigned char inbuf[INBUF_SIZE];
GLOBAL int inbuf_head, inbuf_reap;
GLOBAL int inbuf_head;

#define OUTBUF_SIZE 2048
#define OUTBUF_MASK (OUTBUF_SIZE-1)
Expand All @@ -61,19 +68,14 @@ GLOBAL int outbuf_head, outbuf_reap;

GLOBAL int has_focus;

GLOBAL int app_cursor_keys, app_keypad_keys;
GLOBAL int app_cursor_keys, app_keypad_keys, vt52_mode;
GLOBAL int repeat_off, cr_lf_return;

GLOBAL int seen_key_event;
GLOBAL int seen_disp_event;

GLOBAL int session_closed;

typedef enum {
US_NONE = 0, US_KEY = 1, US_DISP = 2, US_BOTH = 3
} Unscroll_Trigger;

GLOBAL Unscroll_Trigger unscroll_event;

GLOBAL char *logfile;

/*
Expand Down Expand Up @@ -143,35 +145,40 @@ typedef struct {
/* Keyboard options */
int bksp_is_delete;
int rxvt_homeend;
int linux_funkeys;
int funky_type;
int app_cursor;
int app_keypad;
int nethack_keypad;
int alt_f4; /* is it special? */
int alt_space; /* is it special? */
int ldisc_term;
int blink_cur;
int beep;
int scroll_on_key;
/* Terminal options */
int savelines;
int dec_om;
int wrap_mode;
int lfhascr;
int blink_cur;
int beep;
int scrollbar;
int locksize;
int bce;
int blinktext;
int win_name_always;
int width, height;
char font[64];
int fontisbold;
int fontheight;
int fontcharset;
VT_Mode vtmode;
/* Colour options */
int try_palette;
int bold_colour;
unsigned char colours[22][3];
/* Selection options */
int mouse_is_xterm;
short wordness[256];
/* russian language translation */
/* translations */
VT_Mode vtmode;
int xlat_enablekoiwin;
int xlat_88592w1250;
int xlat_capslockcyr;
Expand All @@ -198,7 +205,7 @@ struct RSAKey; /* be a little careful of scope */
* Exports from window.c.
*/
void request_resize (int, int, int);
void do_text (Context, int, int, char *, int, unsigned long);
void do_text (Context, int, int, char *, int, unsigned long, int);
void set_title (char *);
void set_icon (char *);
void set_sbar (int, int, int);
Expand All @@ -210,7 +217,7 @@ void write_clip (void *, int);
void get_clip (void **, int *);
void optimised_move (int, int, int);
void fatalbox (char *, ...);
void beep (void);
void beep (int);
#define OPTIMISE_IS_SCROLL 1

/*
Expand Down Expand Up @@ -252,6 +259,8 @@ void term_deselect (void);
void term_update (void);
void term_invalidate(void);
void term_blink(int set_cursor);
void term_paste(void);
void term_nopaste(void);

/*
* Exports from raw.c.
Expand Down
14 changes: 2 additions & 12 deletions raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

static SOCKET s = INVALID_SOCKET;

#define iswritable(x) ( (x) != IAC && (x) != CR )

static void raw_size(void);

static int sb_opt, sb_len;
Expand Down Expand Up @@ -50,16 +48,8 @@ static void s_write (void *buf, int len) {
}

static void c_write (char *buf, int len) {
while (len--) {
int new_head = (inbuf_head + 1) & INBUF_MASK;
if (new_head != inbuf_reap) {
inbuf[inbuf_head] = *buf++;
inbuf_head = new_head;
} else {
term_out();
if( inbuf_head == inbuf_reap ) len++; else break;
}
}
while (len--)
c_write1(*buf++);
}

/*
Expand Down
12 changes: 2 additions & 10 deletions ssh.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,8 @@ static void c_write (char *buf, int len) {
if (len > 0) { fwrite(buf, len, 1, stderr); fputc('\n', stderr); }
return;
}
while (len--) {
int new_head = (inbuf_head + 1) & INBUF_MASK;
if (new_head != inbuf_reap) {
inbuf[inbuf_head] = *buf++;
inbuf_head = new_head;
} else {
term_out();
if( inbuf_head == inbuf_reap ) len++; else break;
}
}
while (len--)
c_write1(*buf++);
}

struct Packet {
Expand Down
30 changes: 9 additions & 21 deletions telnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,19 +165,6 @@ static void s_write (void *buf, int len) {
try_write();
}

static void c_write (char *buf, int len) {
while (len--) {
int new_head = (inbuf_head + 1) & INBUF_MASK;
if (new_head != inbuf_reap) {
inbuf[inbuf_head] = *buf++;
inbuf_head = new_head;
} else {
term_out();
if( inbuf_head == inbuf_reap ) len++; else break;
}
}
}

static void log_option (char *sender, int cmd, int option) {
char buf[50];
sprintf(buf, "%s:\t%s %s", sender,
Expand Down Expand Up @@ -384,7 +371,6 @@ static enum {
} telnet_state = TOPLEVEL;

static void do_telnet_read (char *buf, int len) {
unsigned char b[10];

while (len--) {
int c = (unsigned char) *buf++;
Expand All @@ -397,9 +383,8 @@ static void do_telnet_read (char *buf, int len) {
else if (c == IAC)
telnet_state = SEENIAC;
else {
b[0] = c;
if (!in_synch)
c_write (b, 1);
c_write1(c);

#if 1
/* I can't get the F***ing winsock to insert the urgent IAC
Expand Down Expand Up @@ -431,8 +416,7 @@ static void do_telnet_read (char *buf, int len) {
else {
/* ignore everything else; print it if it's IAC */
if (c == IAC) {
b[0] = c;
c_write(b,1);
c_write1(c);
}
telnet_state = TOPLEVEL;
}
Expand Down Expand Up @@ -467,8 +451,8 @@ static void do_telnet_read (char *buf, int len) {
char *newbuf;
sb_size += SB_DELTA;
newbuf = (sb_buf ?
realloc(sb_buf, sb_size) :
malloc(sb_size));
srealloc(sb_buf, sb_size) :
smalloc(sb_size));
if (newbuf)
sb_buf = newbuf;
else
Expand Down Expand Up @@ -608,7 +592,11 @@ static char *telnet_init (HWND hwnd, char *host, int port, char **realhost) {
*/
static int telnet_msg (WPARAM wParam, LPARAM lParam) {
int ret;
char buf[256];
/* This needs to be larger than the packet size now that inbuf
* cannot overflow, in fact the fewer calls we make to windows
* the faster we will run!
*/
char buf[16384];

/*
* Because reading less than the whole of the available pending
Expand Down
Loading

0 comments on commit 0d5d390

Please sign in to comment.