mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-16 02:27:32 -05:00
Change vtable defs to use C99 designated initialisers.
This is a sweeping change applied across the whole code base by a spot of Emacs Lisp. Now, everywhere I declare a vtable filled with function pointers (and the occasional const data member), all the members of the vtable structure are initialised by name using the '.fieldname = value' syntax introduced in C99. We were already using this syntax for a handful of things in the new key-generation progress report system, so it's not new to the code base as a whole. The advantage is that now, when a vtable only declares a subset of the available fields, I can initialise the rest to NULL or zero just by leaving them out. This is most dramatic in a couple of the outlying vtables in things like psocks (which has a ConnectionLayerVtable containing only one non-NULL method), but less dramatically, it means that the new 'flags' field in BackendVtable can be completely left out of every backend definition except for the SUPDUP one which defines it to a nonzero value. Similarly, the test_for_upstream method only used by SSH doesn't have to be mentioned in the rest of the backends; network Plugs for listening sockets don't have to explicitly null out 'receive' and 'sent', and vice versa for 'accepting', and so on. While I'm at it, I've normalised the declarations so they don't use the unnecessarily verbose 'struct' keyword. Also a handful of them weren't const; now they are.
This commit is contained in:
114
ssh2connection.c
114
ssh2connection.c
@ -22,16 +22,16 @@ static bool ssh2_connection_want_user_input(PacketProtocolLayer *ppl);
|
||||
static void ssh2_connection_got_user_input(PacketProtocolLayer *ppl);
|
||||
static void ssh2_connection_reconfigure(PacketProtocolLayer *ppl, Conf *conf);
|
||||
|
||||
static const struct PacketProtocolLayerVtable ssh2_connection_vtable = {
|
||||
ssh2_connection_free,
|
||||
ssh2_connection_process_queue,
|
||||
ssh2_connection_get_specials,
|
||||
ssh2_connection_special_cmd,
|
||||
ssh2_connection_want_user_input,
|
||||
ssh2_connection_got_user_input,
|
||||
ssh2_connection_reconfigure,
|
||||
ssh_ppl_default_queued_data_size,
|
||||
"ssh-connection",
|
||||
static const PacketProtocolLayerVtable ssh2_connection_vtable = {
|
||||
.free = ssh2_connection_free,
|
||||
.process_queue = ssh2_connection_process_queue,
|
||||
.get_specials = ssh2_connection_get_specials,
|
||||
.special_cmd = ssh2_connection_special_cmd,
|
||||
.want_user_input = ssh2_connection_want_user_input,
|
||||
.got_user_input = ssh2_connection_got_user_input,
|
||||
.reconfigure = ssh2_connection_reconfigure,
|
||||
.queued_data_size = ssh_ppl_default_queued_data_size,
|
||||
.name = "ssh-connection",
|
||||
};
|
||||
|
||||
static SshChannel *ssh2_lportfwd_open(
|
||||
@ -65,31 +65,31 @@ static void ssh2_enable_x_fwd(ConnectionLayer *cl);
|
||||
static void ssh2_enable_agent_fwd(ConnectionLayer *cl);
|
||||
static void ssh2_set_wants_user_input(ConnectionLayer *cl, bool wanted);
|
||||
|
||||
static const struct ConnectionLayerVtable ssh2_connlayer_vtable = {
|
||||
ssh2_rportfwd_alloc,
|
||||
ssh2_rportfwd_remove,
|
||||
ssh2_lportfwd_open,
|
||||
ssh2_session_open,
|
||||
ssh2_serverside_x11_open,
|
||||
ssh2_serverside_agent_open,
|
||||
ssh2_add_x11_display,
|
||||
ssh2_add_sharing_x11_display,
|
||||
ssh2_remove_sharing_x11_display,
|
||||
ssh2_send_packet_from_downstream,
|
||||
ssh2_alloc_sharing_channel,
|
||||
ssh2_delete_sharing_channel,
|
||||
ssh2_sharing_queue_global_request,
|
||||
ssh2_sharing_no_more_downstreams,
|
||||
ssh2_agent_forwarding_permitted,
|
||||
ssh2_terminal_size,
|
||||
ssh2_stdout_unthrottle,
|
||||
ssh2_stdin_backlog,
|
||||
ssh2_throttle_all_channels,
|
||||
ssh2_ldisc_option,
|
||||
ssh2_set_ldisc_option,
|
||||
ssh2_enable_x_fwd,
|
||||
ssh2_enable_agent_fwd,
|
||||
ssh2_set_wants_user_input,
|
||||
static const ConnectionLayerVtable ssh2_connlayer_vtable = {
|
||||
.rportfwd_alloc = ssh2_rportfwd_alloc,
|
||||
.rportfwd_remove = ssh2_rportfwd_remove,
|
||||
.lportfwd_open = ssh2_lportfwd_open,
|
||||
.session_open = ssh2_session_open,
|
||||
.serverside_x11_open = ssh2_serverside_x11_open,
|
||||
.serverside_agent_open = ssh2_serverside_agent_open,
|
||||
.add_x11_display = ssh2_add_x11_display,
|
||||
.add_sharing_x11_display = ssh2_add_sharing_x11_display,
|
||||
.remove_sharing_x11_display = ssh2_remove_sharing_x11_display,
|
||||
.send_packet_from_downstream = ssh2_send_packet_from_downstream,
|
||||
.alloc_sharing_channel = ssh2_alloc_sharing_channel,
|
||||
.delete_sharing_channel = ssh2_delete_sharing_channel,
|
||||
.sharing_queue_global_request = ssh2_sharing_queue_global_request,
|
||||
.sharing_no_more_downstreams = ssh2_sharing_no_more_downstreams,
|
||||
.agent_forwarding_permitted = ssh2_agent_forwarding_permitted,
|
||||
.terminal_size = ssh2_terminal_size,
|
||||
.stdout_unthrottle = ssh2_stdout_unthrottle,
|
||||
.stdin_backlog = ssh2_stdin_backlog,
|
||||
.throttle_all_channels = ssh2_throttle_all_channels,
|
||||
.ldisc_option = ssh2_ldisc_option,
|
||||
.set_ldisc_option = ssh2_set_ldisc_option,
|
||||
.enable_x_fwd = ssh2_enable_x_fwd,
|
||||
.enable_agent_fwd = ssh2_enable_agent_fwd,
|
||||
.set_wants_user_input = ssh2_set_wants_user_input,
|
||||
};
|
||||
|
||||
static char *ssh2_channel_open_failure_error_text(PktIn *pktin)
|
||||
@ -132,28 +132,28 @@ static void ssh2channel_x11_sharing_handover(
|
||||
int protomajor, int protominor, const void *initial_data, int initial_len);
|
||||
static void ssh2channel_hint_channel_is_simple(SshChannel *c);
|
||||
|
||||
static const struct SshChannelVtable ssh2channel_vtable = {
|
||||
ssh2channel_write,
|
||||
ssh2channel_write_eof,
|
||||
ssh2channel_initiate_close,
|
||||
ssh2channel_unthrottle,
|
||||
ssh2channel_get_conf,
|
||||
ssh2channel_window_override_removed,
|
||||
ssh2channel_x11_sharing_handover,
|
||||
ssh2channel_send_exit_status,
|
||||
ssh2channel_send_exit_signal,
|
||||
ssh2channel_send_exit_signal_numeric,
|
||||
ssh2channel_request_x11_forwarding,
|
||||
ssh2channel_request_agent_forwarding,
|
||||
ssh2channel_request_pty,
|
||||
ssh2channel_send_env_var,
|
||||
ssh2channel_start_shell,
|
||||
ssh2channel_start_command,
|
||||
ssh2channel_start_subsystem,
|
||||
ssh2channel_send_serial_break,
|
||||
ssh2channel_send_signal,
|
||||
ssh2channel_send_terminal_size_change,
|
||||
ssh2channel_hint_channel_is_simple,
|
||||
static const SshChannelVtable ssh2channel_vtable = {
|
||||
.write = ssh2channel_write,
|
||||
.write_eof = ssh2channel_write_eof,
|
||||
.initiate_close = ssh2channel_initiate_close,
|
||||
.unthrottle = ssh2channel_unthrottle,
|
||||
.get_conf = ssh2channel_get_conf,
|
||||
.window_override_removed = ssh2channel_window_override_removed,
|
||||
.x11_sharing_handover = ssh2channel_x11_sharing_handover,
|
||||
.send_exit_status = ssh2channel_send_exit_status,
|
||||
.send_exit_signal = ssh2channel_send_exit_signal,
|
||||
.send_exit_signal_numeric = ssh2channel_send_exit_signal_numeric,
|
||||
.request_x11_forwarding = ssh2channel_request_x11_forwarding,
|
||||
.request_agent_forwarding = ssh2channel_request_agent_forwarding,
|
||||
.request_pty = ssh2channel_request_pty,
|
||||
.send_env_var = ssh2channel_send_env_var,
|
||||
.start_shell = ssh2channel_start_shell,
|
||||
.start_command = ssh2channel_start_command,
|
||||
.start_subsystem = ssh2channel_start_subsystem,
|
||||
.send_serial_break = ssh2channel_send_serial_break,
|
||||
.send_signal = ssh2channel_send_signal,
|
||||
.send_terminal_size_change = ssh2channel_send_terminal_size_change,
|
||||
.hint_channel_is_simple = ssh2channel_hint_channel_is_simple,
|
||||
};
|
||||
|
||||
static void ssh2_channel_check_close(struct ssh2_channel *c);
|
||||
|
Reference in New Issue
Block a user