mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-10 15:53:47 -05:00
Make lots of generic data parameters into 'void *'.
This is a cleanup I started to notice a need for during the BinarySink work. It removes a lot of faffing about casting things to char * or unsigned char * so that some API will accept them, even though lots of such APIs really take a plain 'block of raw binary data' argument and don't care what C thinks the signedness of that data might be - they may well reinterpret it back and forth internally. So I've tried to arrange for all the function call APIs that ought to have a void * (or const void *) to have one, and those that need to do pointer arithmetic on the parameter internally can cast it back at the top of the function. That saves endless ad-hoc casts at the call sites.
This commit is contained in:
46
telnet.c
46
telnet.c
@ -206,7 +206,7 @@ typedef struct telnet_tag {
|
||||
|
||||
#define SB_DELTA 1024
|
||||
|
||||
static void c_write(Telnet telnet, const char *buf, int len)
|
||||
static void c_write(Telnet telnet, const void *buf, int len)
|
||||
{
|
||||
int backlog;
|
||||
backlog = from_backend(telnet->frontend, 0, buf, len);
|
||||
@ -236,7 +236,7 @@ static void send_opt(Telnet telnet, int cmd, int option)
|
||||
b[0] = IAC;
|
||||
b[1] = cmd;
|
||||
b[2] = option;
|
||||
telnet->bufsize = sk_write(telnet->s, (char *)b, 3);
|
||||
telnet->bufsize = sk_write(telnet->s, b, 3);
|
||||
log_option(telnet, "client", cmd, option);
|
||||
}
|
||||
|
||||
@ -377,7 +377,7 @@ static void process_subneg(Telnet telnet)
|
||||
n = 4 + strlen(termspeed);
|
||||
b[n] = IAC;
|
||||
b[n + 1] = SE;
|
||||
telnet->bufsize = sk_write(telnet->s, (char *)b, n + 2);
|
||||
telnet->bufsize = sk_write(telnet->s, b, n + 2);
|
||||
logevent(telnet->frontend, "server:\tSB TSPEED SEND");
|
||||
logbuf = dupprintf("client:\tSB TSPEED IS %s", termspeed);
|
||||
logevent(telnet->frontend, logbuf);
|
||||
@ -401,7 +401,7 @@ static void process_subneg(Telnet telnet)
|
||||
termtype[n]);
|
||||
b[n + 4] = IAC;
|
||||
b[n + 5] = SE;
|
||||
telnet->bufsize = sk_write(telnet->s, (char *)b, n + 6);
|
||||
telnet->bufsize = sk_write(telnet->s, b, n + 6);
|
||||
b[n + 4] = 0;
|
||||
logevent(telnet->frontend, "server:\tSB TTYPE SEND");
|
||||
logbuf = dupprintf("client:\tSB TTYPE IS %s", b + 4);
|
||||
@ -491,7 +491,7 @@ static void process_subneg(Telnet telnet)
|
||||
}
|
||||
b[n++] = IAC;
|
||||
b[n++] = SE;
|
||||
telnet->bufsize = sk_write(telnet->s, (char *)b, n);
|
||||
telnet->bufsize = sk_write(telnet->s, b, n);
|
||||
if (n == 6) {
|
||||
logbuf = dupprintf("client:\tSB %s IS <nothing>",
|
||||
telopt(telnet->sb_opt));
|
||||
@ -853,11 +853,11 @@ static int telnet_send(void *handle, const char *buf, int len)
|
||||
|
||||
while (p < end && iswritable(*p))
|
||||
p++;
|
||||
telnet->bufsize = sk_write(telnet->s, (char *)q, p - q);
|
||||
telnet->bufsize = sk_write(telnet->s, q, p - q);
|
||||
|
||||
while (p < end && !iswritable(*p)) {
|
||||
telnet->bufsize =
|
||||
sk_write(telnet->s, (char *)(*p == IAC ? iac : cr), 2);
|
||||
sk_write(telnet->s, *p == IAC ? iac : cr, 2);
|
||||
p++;
|
||||
}
|
||||
}
|
||||
@ -903,7 +903,7 @@ static void telnet_size(void *handle, int width, int height)
|
||||
if (b[n-1] == IAC) b[n++] = IAC; /* duplicate any IAC byte occurs */
|
||||
b[n++] = IAC;
|
||||
b[n++] = SE;
|
||||
telnet->bufsize = sk_write(telnet->s, (char *)b, n);
|
||||
telnet->bufsize = sk_write(telnet->s, b, n);
|
||||
logbuf = dupprintf("client:\tSB NAWS %d,%d",
|
||||
telnet->term_width, telnet->term_height);
|
||||
logevent(telnet->frontend, logbuf);
|
||||
@ -925,51 +925,51 @@ static void telnet_special(void *handle, Telnet_Special code)
|
||||
switch (code) {
|
||||
case TS_AYT:
|
||||
b[1] = AYT;
|
||||
telnet->bufsize = sk_write(telnet->s, (char *)b, 2);
|
||||
telnet->bufsize = sk_write(telnet->s, b, 2);
|
||||
break;
|
||||
case TS_BRK:
|
||||
b[1] = BREAK;
|
||||
telnet->bufsize = sk_write(telnet->s, (char *)b, 2);
|
||||
telnet->bufsize = sk_write(telnet->s, b, 2);
|
||||
break;
|
||||
case TS_EC:
|
||||
b[1] = EC;
|
||||
telnet->bufsize = sk_write(telnet->s, (char *)b, 2);
|
||||
telnet->bufsize = sk_write(telnet->s, b, 2);
|
||||
break;
|
||||
case TS_EL:
|
||||
b[1] = EL;
|
||||
telnet->bufsize = sk_write(telnet->s, (char *)b, 2);
|
||||
telnet->bufsize = sk_write(telnet->s, b, 2);
|
||||
break;
|
||||
case TS_GA:
|
||||
b[1] = GA;
|
||||
telnet->bufsize = sk_write(telnet->s, (char *)b, 2);
|
||||
telnet->bufsize = sk_write(telnet->s, b, 2);
|
||||
break;
|
||||
case TS_NOP:
|
||||
b[1] = NOP;
|
||||
telnet->bufsize = sk_write(telnet->s, (char *)b, 2);
|
||||
telnet->bufsize = sk_write(telnet->s, b, 2);
|
||||
break;
|
||||
case TS_ABORT:
|
||||
b[1] = ABORT;
|
||||
telnet->bufsize = sk_write(telnet->s, (char *)b, 2);
|
||||
telnet->bufsize = sk_write(telnet->s, b, 2);
|
||||
break;
|
||||
case TS_AO:
|
||||
b[1] = AO;
|
||||
telnet->bufsize = sk_write(telnet->s, (char *)b, 2);
|
||||
telnet->bufsize = sk_write(telnet->s, b, 2);
|
||||
break;
|
||||
case TS_IP:
|
||||
b[1] = IP;
|
||||
telnet->bufsize = sk_write(telnet->s, (char *)b, 2);
|
||||
telnet->bufsize = sk_write(telnet->s, b, 2);
|
||||
break;
|
||||
case TS_SUSP:
|
||||
b[1] = SUSP;
|
||||
telnet->bufsize = sk_write(telnet->s, (char *)b, 2);
|
||||
telnet->bufsize = sk_write(telnet->s, b, 2);
|
||||
break;
|
||||
case TS_EOR:
|
||||
b[1] = EOR;
|
||||
telnet->bufsize = sk_write(telnet->s, (char *)b, 2);
|
||||
telnet->bufsize = sk_write(telnet->s, b, 2);
|
||||
break;
|
||||
case TS_EOF:
|
||||
b[1] = xEOF;
|
||||
telnet->bufsize = sk_write(telnet->s, (char *)b, 2);
|
||||
telnet->bufsize = sk_write(telnet->s, b, 2);
|
||||
break;
|
||||
case TS_EOL:
|
||||
/* In BINARY mode, CR-LF becomes just CR -
|
||||
@ -981,8 +981,8 @@ static void telnet_special(void *handle, Telnet_Special code)
|
||||
break;
|
||||
case TS_SYNCH:
|
||||
b[1] = DM;
|
||||
telnet->bufsize = sk_write(telnet->s, (char *)b, 1);
|
||||
telnet->bufsize = sk_write_oob(telnet->s, (char *)(b + 1), 1);
|
||||
telnet->bufsize = sk_write(telnet->s, b, 1);
|
||||
telnet->bufsize = sk_write_oob(telnet->s, b + 1, 1);
|
||||
break;
|
||||
case TS_RECHO:
|
||||
if (telnet->opt_states[o_echo.index] == INACTIVE ||
|
||||
@ -1000,7 +1000,7 @@ static void telnet_special(void *handle, Telnet_Special code)
|
||||
case TS_PING:
|
||||
if (telnet->opt_states[o_they_sga.index] == ACTIVE) {
|
||||
b[1] = NOP;
|
||||
telnet->bufsize = sk_write(telnet->s, (char *)b, 2);
|
||||
telnet->bufsize = sk_write(telnet->s, b, 2);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
Reference in New Issue
Block a user