1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-06-30 19:12:48 -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:
Simon Tatham
2020-03-10 21:06:29 +00:00
parent ade10f1304
commit b4e1bca2c3
80 changed files with 1647 additions and 1528 deletions

View File

@ -256,34 +256,34 @@ static const char *wintw_get_title(TermWin *, bool icon);
static bool wintw_is_utf8(TermWin *);
static const TermWinVtable windows_termwin_vt = {
wintw_setup_draw_ctx,
wintw_draw_text,
wintw_draw_cursor,
wintw_draw_trust_sigil,
wintw_char_width,
wintw_free_draw_ctx,
wintw_set_cursor_pos,
wintw_set_raw_mouse_mode,
wintw_set_scrollbar,
wintw_bell,
wintw_clip_write,
wintw_clip_request_paste,
wintw_refresh,
wintw_request_resize,
wintw_set_title,
wintw_set_icon_title,
wintw_set_minimised,
wintw_is_minimised,
wintw_set_maximised,
wintw_move,
wintw_set_zorder,
wintw_palette_get,
wintw_palette_set,
wintw_palette_reset,
wintw_get_pos,
wintw_get_pixels,
wintw_get_title,
wintw_is_utf8,
.setup_draw_ctx = wintw_setup_draw_ctx,
.draw_text = wintw_draw_text,
.draw_cursor = wintw_draw_cursor,
.draw_trust_sigil = wintw_draw_trust_sigil,
.char_width = wintw_char_width,
.free_draw_ctx = wintw_free_draw_ctx,
.set_cursor_pos = wintw_set_cursor_pos,
.set_raw_mouse_mode = wintw_set_raw_mouse_mode,
.set_scrollbar = wintw_set_scrollbar,
.bell = wintw_bell,
.clip_write = wintw_clip_write,
.clip_request_paste = wintw_clip_request_paste,
.refresh = wintw_refresh,
.request_resize = wintw_request_resize,
.set_title = wintw_set_title,
.set_icon_title = wintw_set_icon_title,
.set_minimised = wintw_set_minimised,
.is_minimised = wintw_is_minimised,
.set_maximised = wintw_set_maximised,
.move = wintw_move,
.set_zorder = wintw_set_zorder,
.palette_get = wintw_palette_get,
.palette_set = wintw_palette_set,
.palette_reset = wintw_palette_reset,
.get_pos = wintw_get_pos,
.get_pixels = wintw_get_pixels,
.get_title = wintw_get_title,
.is_utf8 = wintw_is_utf8,
};
static TermWin wintw[1];
@ -339,27 +339,27 @@ static bool win_seat_set_trust_status(Seat *seat, bool trusted);
static bool win_seat_get_cursor_position(Seat *seat, int *x, int *y);
static const SeatVtable win_seat_vt = {
win_seat_output,
win_seat_eof,
win_seat_get_userpass_input,
win_seat_notify_remote_exit,
win_seat_connection_fatal,
win_seat_update_specials_menu,
win_seat_get_ttymode,
win_seat_set_busy_status,
win_seat_verify_ssh_host_key,
win_seat_confirm_weak_crypto_primitive,
win_seat_confirm_weak_cached_hostkey,
win_seat_is_utf8,
nullseat_echoedit_update,
nullseat_get_x_display,
nullseat_get_windowid,
win_seat_get_window_pixel_size,
win_seat_stripctrl_new,
win_seat_set_trust_status,
nullseat_verbose_yes,
nullseat_interactive_yes,
win_seat_get_cursor_position,
.output = win_seat_output,
.eof = win_seat_eof,
.get_userpass_input = win_seat_get_userpass_input,
.notify_remote_exit = win_seat_notify_remote_exit,
.connection_fatal = win_seat_connection_fatal,
.update_specials_menu = win_seat_update_specials_menu,
.get_ttymode = win_seat_get_ttymode,
.set_busy_status = win_seat_set_busy_status,
.verify_ssh_host_key = win_seat_verify_ssh_host_key,
.confirm_weak_crypto_primitive = win_seat_confirm_weak_crypto_primitive,
.confirm_weak_cached_hostkey = win_seat_confirm_weak_cached_hostkey,
.is_utf8 = win_seat_is_utf8,
.echoedit_update = nullseat_echoedit_update,
.get_x_display = nullseat_get_x_display,
.get_windowid = nullseat_get_windowid,
.get_window_pixel_size = win_seat_get_window_pixel_size,
.stripctrl_new = win_seat_stripctrl_new,
.set_trust_status = win_seat_set_trust_status,
.verbose = nullseat_verbose_yes,
.interactive = nullseat_interactive_yes,
.get_cursor_position = win_seat_get_cursor_position,
};
static WinGuiSeat wgs = { .seat.vt = &win_seat_vt,
.logpolicy.vt = &win_gui_logpolicy_vt };