1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-01 11:32:48 -05:00

Get rid of lots of implicit pointer types.

All the main backend structures - Ssh, Telnet, Pty, Serial etc - now
describe structure types themselves rather than pointers to them. The
same goes for the codebase-wide trait types Socket and Plug, and the
supporting types SockAddr and Pinger.

All those things that were typedefed as pointers are older types; the
newer ones have the explicit * at the point of use, because that's
what I now seem to be preferring. But whichever one of those is
better, inconsistently using a mixture of the two styles is worse, so
let's make everything consistent.

A few types are still implicitly pointers, such as Bignum and some of
the GSSAPI types; generally this is either because they have to be
void *, or because they're typedefed differently on different
platforms and aren't always pointers at all. Can't be helped. But I've
got rid of the main ones, at least.
This commit is contained in:
Simon Tatham
2018-10-04 19:10:23 +01:00
parent bf61af1919
commit 96ec2c2500
42 changed files with 595 additions and 596 deletions

View File

@ -24,7 +24,7 @@ sel *asel;
sel_rfd *netr, *ptyr, *sigr;
int ptyfd;
sel_wfd *netw, *ptyw;
Telnet telnet;
Telnet *telnet;
#define BUF 65536

View File

@ -172,7 +172,7 @@ static const struct Opt *const opts[] = {
&o_echo, &o_we_sga, &o_they_sga, &o_naws, &o_ttype, &o_oenv, &o_nenv, NULL
};
struct telnet_tag {
struct Telnet {
int opt_states[NUM_OPTS];
int sb_opt, sb_len;
@ -203,7 +203,7 @@ struct telnet_tag {
#define SB_DELTA 1024
static void send_opt(Telnet telnet, int cmd, int option)
static void send_opt(Telnet *telnet, int cmd, int option)
{
unsigned char b[3];
@ -213,7 +213,7 @@ static void send_opt(Telnet telnet, int cmd, int option)
sel_write(telnet->net, b, 3);
}
static void deactivate_option(Telnet telnet, const struct Opt *o)
static void deactivate_option(Telnet *telnet, const struct Opt *o)
{
if (telnet->opt_states[o->index] == REQUESTED ||
telnet->opt_states[o->index] == ACTIVE)
@ -224,11 +224,11 @@ static void deactivate_option(Telnet telnet, const struct Opt *o)
/*
* Generate side effects of enabling or disabling an option.
*/
static void option_side_effects(Telnet telnet, const struct Opt *o, int enabled)
static void option_side_effects(Telnet *telnet, const struct Opt *o, int enabled)
{
}
static void activate_option(Telnet telnet, const struct Opt *o)
static void activate_option(Telnet *telnet, const struct Opt *o)
{
if (o->option == TELOPT_NEW_ENVIRON ||
o->option == TELOPT_OLD_ENVIRON ||
@ -245,7 +245,7 @@ static void activate_option(Telnet telnet, const struct Opt *o)
option_side_effects(telnet, o, 1);
}
static void done_option(Telnet telnet, int option)
static void done_option(Telnet *telnet, int option)
{
if (option == TELOPT_OLD_ENVIRON)
telnet->old_environ_done = 1;
@ -260,7 +260,7 @@ static void done_option(Telnet telnet, int option)
}
}
static void refused_option(Telnet telnet, const struct Opt *o)
static void refused_option(Telnet *telnet, const struct Opt *o)
{
done_option(telnet, o->option);
if (o->send == WILL && o->option == TELOPT_NEW_ENVIRON &&
@ -272,7 +272,7 @@ static void refused_option(Telnet telnet, const struct Opt *o)
option_side_effects(telnet, o, 0);
}
static void proc_rec_opt(Telnet telnet, int cmd, int option)
static void proc_rec_opt(Telnet *telnet, int cmd, int option)
{
const struct Opt *const *o;
@ -323,7 +323,7 @@ static void proc_rec_opt(Telnet telnet, int cmd, int option)
send_opt(telnet, (cmd == WILL ? DONT : WONT), option);
}
static void process_subneg(Telnet telnet)
static void process_subneg(Telnet *telnet)
{
int var, value, n;
@ -400,7 +400,7 @@ static void process_subneg(Telnet telnet)
}
}
void telnet_from_net(Telnet telnet, char *buf, int len)
void telnet_from_net(Telnet *telnet, char *buf, int len)
{
while (len--) {
int c = (unsigned char) *buf++;
@ -497,11 +497,11 @@ void telnet_from_net(Telnet telnet, char *buf, int len)
}
}
Telnet telnet_new(sel_wfd *net, sel_wfd *pty)
Telnet *telnet_new(sel_wfd *net, sel_wfd *pty)
{
Telnet telnet;
Telnet *telnet;
telnet = snew(struct telnet_tag);
telnet = snew(Telnet);
telnet->sb_buf = NULL;
telnet->sb_size = 0;
telnet->state = TOP_LEVEL;
@ -532,13 +532,13 @@ Telnet telnet_new(sel_wfd *net, sel_wfd *pty)
return telnet;
}
void telnet_free(Telnet telnet)
void telnet_free(Telnet *telnet)
{
sfree(telnet->sb_buf);
sfree(telnet);
}
void telnet_from_pty(Telnet telnet, char *buf, int len)
void telnet_from_pty(Telnet *telnet, char *buf, int len)
{
unsigned char *p, *end;
static const unsigned char iac[2] = { IAC, IAC };
@ -563,7 +563,7 @@ void telnet_from_pty(Telnet telnet, char *buf, int len)
}
}
int telnet_shell_ok(Telnet telnet, struct shell_data *shdata)
int telnet_shell_ok(Telnet *telnet, struct shell_data *shdata)
{
if (telnet->shell_ok)
*shdata = telnet->shdata; /* structure copy */

View File

@ -7,7 +7,7 @@
#include "sel.h"
typedef struct telnet_tag *Telnet;
typedef struct Telnet Telnet;
struct shell_data {
char **envvars; /* array of "VAR=value" terms */
@ -18,24 +18,24 @@ struct shell_data {
/*
* Create and destroy a Telnet structure.
*/
Telnet telnet_new(sel_wfd *net, sel_wfd *pty);
void telnet_free(Telnet telnet);
Telnet *telnet_new(sel_wfd *net, sel_wfd *pty);
void telnet_free(Telnet *telnet);
/*
* Process data read from the pty.
*/
void telnet_from_pty(Telnet telnet, char *buf, int len);
void telnet_from_pty(Telnet *telnet, char *buf, int len);
/*
* Process Telnet protocol data received from the network.
*/
void telnet_from_net(Telnet telnet, char *buf, int len);
void telnet_from_net(Telnet *telnet, char *buf, int len);
/*
* Return true if pre-shell-startup negotiations are complete and
* it's safe to start the shell subprocess now. On a true return,
* also fills in the shell_data structure.
*/
int telnet_shell_ok(Telnet telnet, struct shell_data *shdata);
int telnet_shell_ok(Telnet *telnet, struct shell_data *shdata);
#endif /* FIXME_TELNET_H */