1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-03-22 06:38:37 -05:00

Add some missing 'const'.

plug_receive(), sftp_senddata() and handle_gotdata() in particular now
take const pointers. Also fixed 'char *receive_data' in struct
ProxySocket.
This commit is contained in:
Simon Tatham 2019-02-06 20:18:19 +00:00
parent eb16dee2a4
commit 0aa8cf7b0d
22 changed files with 27 additions and 24 deletions

View File

@ -31,7 +31,7 @@ static Filename *xlatlognam(Filename *s, char *hostname, int port,
* isn't open, buffering data if it's in the process of being * isn't open, buffering data if it's in the process of being
* opened asynchronously, etc. * opened asynchronously, etc.
*/ */
static void logwrite(LogContext *ctx, void *data, int len) static void logwrite(LogContext *ctx, const void *data, int len)
{ {
/* /*
* In state L_CLOSED, we call logfopen, which will set the state * In state L_CLOSED, we call logfopen, which will set the state

View File

@ -70,7 +70,7 @@ struct PlugVtable {
/* error_msg is NULL iff it is not an error (ie it closed normally) */ /* error_msg is NULL iff it is not an error (ie it closed normally) */
/* calling_back != 0 iff there is a Plug function */ /* calling_back != 0 iff there is a Plug function */
/* currently running (would cure the fixme in try_send()) */ /* currently running (would cure the fixme in try_send()) */
void (*receive) (Plug *p, int urgent, char *data, int len); void (*receive) (Plug *p, int urgent, const char *data, int len);
/* /*
* - urgent==0. `data' points to `len' bytes of perfectly * - urgent==0. `data' points to `len' bytes of perfectly
* ordinary data. * ordinary data.

View File

@ -17,7 +17,7 @@ static void nullplug_closing(Plug *plug, const char *error_msg, int error_code,
{ {
} }
static void nullplug_receive(Plug *plug, int urgent, char *data, int len) static void nullplug_receive(Plug *plug, int urgent, const char *data, int len)
{ {
} }

View File

@ -755,7 +755,8 @@ static void pageant_conn_log(void *logctx, const char *fmt, va_list ap)
sfree(formatted); sfree(formatted);
} }
static void pageant_conn_receive(Plug *plug, int urgent, char *data, int len) static void pageant_conn_receive(
Plug *plug, int urgent, const char *data, int len)
{ {
struct pageant_conn_state *pc = container_of( struct pageant_conn_state *pc = container_of(
plug, struct pageant_conn_state, plug); plug, struct pageant_conn_state, plug);

View File

@ -192,7 +192,7 @@ static char *ipv6_to_string(ptrlen ipv6)
(unsigned)GET_16BIT_MSB_FIRST(addr + 14)); (unsigned)GET_16BIT_MSB_FIRST(addr + 14));
} }
static void pfd_receive(Plug *plug, int urgent, char *data, int len) static void pfd_receive(Plug *plug, int urgent, const char *data, int len)
{ {
struct PortForwarding *pf = struct PortForwarding *pf =
container_of(plug, struct PortForwarding, plug); container_of(plug, struct PortForwarding, plug);

View File

@ -214,7 +214,7 @@ static void plug_proxy_closing (Plug *p, const char *error_msg,
} }
} }
static void plug_proxy_receive (Plug *p, int urgent, char *data, int len) static void plug_proxy_receive (Plug *p, int urgent, const char *data, int len)
{ {
ProxySocket *ps = container_of(p, ProxySocket, plugimpl); ProxySocket *ps = container_of(p, ProxySocket, plugimpl);

View File

@ -68,7 +68,7 @@ struct ProxySocket {
/* receive */ /* receive */
bool receive_urgent; bool receive_urgent;
char *receive_data; const char *receive_data;
int receive_len; int receive_len;
/* sent */ /* sent */

2
pscp.c
View File

@ -574,7 +574,7 @@ bool sftp_recvdata(char *buf, int len)
{ {
return ssh_scp_recv(buf, len); return ssh_scp_recv(buf, len);
} }
bool sftp_senddata(char *buf, int len) bool sftp_senddata(const char *buf, int len)
{ {
backend_send(backend, buf, len); backend_send(backend, buf, len);
return true; return true;

View File

@ -2493,7 +2493,7 @@ bool sftp_recvdata(char *buf, int len)
return true; return true;
} }
bool sftp_senddata(char *buf, int len) bool sftp_senddata(const char *buf, int len)
{ {
backend_send(backend, buf, len); backend_send(backend, buf, len);
return true; return true;

2
raw.c
View File

@ -89,7 +89,7 @@ static void raw_closing(Plug *plug, const char *error_msg, int error_code,
} }
} }
static void raw_receive(Plug *plug, int urgent, char *data, int len) static void raw_receive(Plug *plug, int urgent, const char *data, int len)
{ {
Raw *raw = container_of(plug, Raw, plug); Raw *raw = container_of(plug, Raw, plug);
c_write(raw, data, len); c_write(raw, data, len);

View File

@ -71,9 +71,11 @@ static void rlogin_closing(Plug *plug, const char *error_msg, int error_code,
} /* Otherwise, the remote side closed the connection normally. */ } /* Otherwise, the remote side closed the connection normally. */
} }
static void rlogin_receive(Plug *plug, int urgent, char *data, int len) static void rlogin_receive(Plug *plug, int urgent, const char *data, int len)
{ {
Rlogin *rlogin = container_of(plug, Rlogin, plug); Rlogin *rlogin = container_of(plug, Rlogin, plug);
if (len == 0)
return;
if (urgent == 2) { if (urgent == 2) {
char c; char c;

2
sftp.h
View File

@ -70,7 +70,7 @@
* sftp_sendbuffer returns the size of the backlog of data in the * sftp_sendbuffer returns the size of the backlog of data in the
* transmit queue. * transmit queue.
*/ */
bool sftp_senddata(char *data, int len); bool sftp_senddata(const char *data, int len);
int sftp_sendbuffer(void); int sftp_sendbuffer(void);
bool sftp_recvdata(char *data, int len); bool sftp_recvdata(char *data, int len);

2
ssh.c
View File

@ -573,7 +573,7 @@ static void ssh_closing(Plug *plug, const char *error_msg, int error_code,
} }
} }
static void ssh_receive(Plug *plug, int urgent, char *data, int len) static void ssh_receive(Plug *plug, int urgent, const char *data, int len)
{ {
Ssh *ssh = container_of(plug, Ssh, plug); Ssh *ssh = container_of(plug, Ssh, plug);

View File

@ -133,7 +133,7 @@ static void server_closing(Plug *plug, const char *error_msg, int error_code,
} }
} }
static void server_receive(Plug *plug, int urgent, char *data, int len) static void server_receive(Plug *plug, int urgent, const char *data, int len)
{ {
server *srv = container_of(plug, server, plug); server *srv = container_of(plug, server, plug);

View File

@ -1754,7 +1754,7 @@ static void share_got_pkt_from_downstream(struct ssh_sharing_connstate *cs,
(c) = (unsigned char)*data++; \ (c) = (unsigned char)*data++; \
} while (0) } while (0)
static void share_receive(Plug *plug, int urgent, char *data, int len) static void share_receive(Plug *plug, int urgent, const char *data, int len)
{ {
ssh_sharing_connstate *cs = container_of( ssh_sharing_connstate *cs = container_of(
plug, ssh_sharing_connstate, plug); plug, ssh_sharing_connstate, plug);

View File

@ -506,7 +506,7 @@ static void process_subneg(Telnet *telnet)
} }
} }
static void do_telnet_read(Telnet *telnet, char *buf, int len) static void do_telnet_read(Telnet *telnet, const char *buf, int len)
{ {
strbuf *outbuf = strbuf_new(); strbuf *outbuf = strbuf_new();
@ -654,7 +654,7 @@ static void telnet_closing(Plug *plug, const char *error_msg, int error_code,
/* Otherwise, the remote side closed the connection normally. */ /* Otherwise, the remote side closed the connection normally. */
} }
static void telnet_receive(Plug *plug, int urgent, char *data, int len) static void telnet_receive(Plug *plug, int urgent, const char *data, int len)
{ {
Telnet *telnet = container_of(plug, Telnet, plug); Telnet *telnet = container_of(plug, Telnet, plug);
if (urgent) if (urgent)

View File

@ -155,7 +155,7 @@ void chan_no_request_response(Channel *chan, bool success) {}
*/ */
static void x11_log(Plug *p, int type, SockAddr *addr, int port, static void x11_log(Plug *p, int type, SockAddr *addr, int port,
const char *error_msg, int error_code) {} const char *error_msg, int error_code) {}
static void x11_receive(Plug *plug, int urgent, char *data, int len) {} static void x11_receive(Plug *plug, int urgent, const char *data, int len) {}
static void x11_sent(Plug *plug, int bufsize) {} static void x11_sent(Plug *plug, int bufsize) {}
static void x11_closing(Plug *plug, const char *error_msg, int error_code, static void x11_closing(Plug *plug, const char *error_msg, int error_code,
bool calling_back) bool calling_back)

View File

@ -45,7 +45,7 @@ typedef struct HandleSocket {
Socket sock; Socket sock;
} HandleSocket; } HandleSocket;
static int handle_gotdata(struct handle *h, void *data, int len) static int handle_gotdata(struct handle *h, const void *data, int len)
{ {
HandleSocket *hs = (HandleSocket *)handle_get_privdata(h); HandleSocket *hs = (HandleSocket *)handle_get_privdata(h);
@ -79,7 +79,7 @@ static int handle_gotdata(struct handle *h, void *data, int len)
} }
} }
static int handle_stderr(struct handle *h, void *data, int len) static int handle_stderr(struct handle *h, const void *data, int len)
{ {
HandleSocket *hs = (HandleSocket *)handle_get_privdata(h); HandleSocket *hs = (HandleSocket *)handle_get_privdata(h);

View File

@ -205,7 +205,7 @@ char *do_select(SOCKET skt, bool startup)
return NULL; return NULL;
} }
int stdin_gotdata(struct handle *h, void *data, int len) int stdin_gotdata(struct handle *h, const void *data, int len)
{ {
if (len < 0) { if (len < 0) {
/* /*

View File

@ -40,7 +40,7 @@ static void serial_terminate(Serial *serial)
} }
} }
static int serial_gotdata(struct handle *h, void *data, int len) static int serial_gotdata(struct handle *h, const void *data, int len)
{ {
Serial *serial = (Serial *)handle_get_privdata(h); Serial *serial = (Serial *)handle_get_privdata(h);
if (len <= 0) { if (len <= 0) {

View File

@ -603,7 +603,7 @@ void init_ucs(Conf *, struct unicode_data *);
#define HANDLE_FLAG_IGNOREEOF 2 #define HANDLE_FLAG_IGNOREEOF 2
#define HANDLE_FLAG_UNITBUFFER 4 #define HANDLE_FLAG_UNITBUFFER 4
struct handle; struct handle;
typedef int (*handle_inputfn_t)(struct handle *h, void *data, int len); typedef int (*handle_inputfn_t)(struct handle *h, const void *data, int len);
typedef void (*handle_outputfn_t)(struct handle *h, int new_backlog); typedef void (*handle_outputfn_t)(struct handle *h, int new_backlog);
struct handle *handle_input_new(HANDLE handle, handle_inputfn_t gotdata, struct handle *handle_input_new(HANDLE handle, handle_inputfn_t gotdata,
void *privdata, int flags); void *privdata, int flags);

View File

@ -726,7 +726,7 @@ static void x11_closing(Plug *plug, const char *error_msg, int error_code,
} }
} }
static void x11_receive(Plug *plug, int urgent, char *data, int len) static void x11_receive(Plug *plug, int urgent, const char *data, int len)
{ {
struct X11Connection *xconn = container_of( struct X11Connection *xconn = container_of(
plug, struct X11Connection, plug); plug, struct X11Connection, plug);