mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-01 11:32:48 -05:00
Introduce a typedef for frontend handles.
This is another major source of unexplained 'void *' parameters throughout the code. In particular, the currently unused testback.c actually gave the wrong pointer type to its internal store of the frontend handle - it cast the input void * to a Terminal *, from which it got implicitly cast back again when calling from_backend, and nobody noticed. Now it uses the right type internally as well as externally.
This commit is contained in:
@ -99,7 +99,7 @@ int main(int argc, char **argv)
|
||||
fprintf(stderr, "GtkApplication frontend doesn't work pre-GTK3\n");
|
||||
return 1;
|
||||
}
|
||||
GtkWidget *make_gtk_toplevel_window(void *frontend) { return NULL; }
|
||||
GtkWidget *make_gtk_toplevel_window(Frontend *frontend) { return NULL; }
|
||||
void launch_duplicate_session(Conf *conf) {}
|
||||
void launch_new_session(void) {}
|
||||
void launch_saved_session(const char *str) {}
|
||||
@ -204,7 +204,7 @@ WIN_ACTION_LIST(WIN_ACTION_ENTRY)
|
||||
};
|
||||
|
||||
static GtkApplication *app;
|
||||
GtkWidget *make_gtk_toplevel_window(void *frontend)
|
||||
GtkWidget *make_gtk_toplevel_window(Frontend *frontend)
|
||||
{
|
||||
GtkWidget *win = gtk_application_window_new(app);
|
||||
g_action_map_add_action_entries(G_ACTION_MAP(win),
|
||||
|
@ -221,7 +221,7 @@ static gint idle_toplevel_callback_func(gpointer data)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void notify_toplevel_callback(void *frontend)
|
||||
static void notify_toplevel_callback(void *vctx)
|
||||
{
|
||||
if (!idle_fn_scheduled) {
|
||||
toplevel_callback_idle_id =
|
||||
|
@ -3442,7 +3442,7 @@ struct verify_ssh_host_key_result_ctx {
|
||||
char *keystr;
|
||||
void (*callback)(void *callback_ctx, int result);
|
||||
void *callback_ctx;
|
||||
void *frontend;
|
||||
Frontend *frontend;
|
||||
};
|
||||
|
||||
static void verify_ssh_host_key_result_callback(void *vctx, int result)
|
||||
@ -3483,7 +3483,7 @@ static void verify_ssh_host_key_result_callback(void *vctx, int result)
|
||||
sfree(ctx);
|
||||
}
|
||||
|
||||
int verify_ssh_host_key(void *frontend, char *host, int port,
|
||||
int verify_ssh_host_key(Frontend *frontend, char *host, int port,
|
||||
const char *keytype, char *keystr, char *fingerprint,
|
||||
void (*callback)(void *ctx, int result), void *ctx)
|
||||
{
|
||||
@ -3560,7 +3560,7 @@ int verify_ssh_host_key(void *frontend, char *host, int port,
|
||||
struct simple_prompt_result_ctx {
|
||||
void (*callback)(void *callback_ctx, int result);
|
||||
void *callback_ctx;
|
||||
void *frontend;
|
||||
Frontend *frontend;
|
||||
enum DialogSlot dialog_slot;
|
||||
};
|
||||
|
||||
@ -3584,7 +3584,7 @@ static void simple_prompt_result_callback(void *vctx, int result)
|
||||
* Ask whether the selected algorithm is acceptable (since it was
|
||||
* below the configured 'warn' threshold).
|
||||
*/
|
||||
int askalg(void *frontend, const char *algtype, const char *algname,
|
||||
int askalg(Frontend *frontend, const char *algtype, const char *algname,
|
||||
void (*callback)(void *ctx, int result), void *ctx)
|
||||
{
|
||||
static const char msg[] =
|
||||
@ -3616,7 +3616,7 @@ int askalg(void *frontend, const char *algtype, const char *algname,
|
||||
return -1; /* dialog still in progress */
|
||||
}
|
||||
|
||||
int askhk(void *frontend, const char *algname, const char *betteralgs,
|
||||
int askhk(Frontend *frontend, const char *algname, const char *betteralgs,
|
||||
void (*callback)(void *ctx, int result), void *ctx)
|
||||
{
|
||||
static const char msg[] =
|
||||
@ -4059,7 +4059,7 @@ void logevent_dlg(void *estuff, const char *string)
|
||||
}
|
||||
}
|
||||
|
||||
int askappend(void *frontend, Filename *filename,
|
||||
int askappend(Frontend *frontend, Filename *filename,
|
||||
void (*callback)(void *ctx, int result), void *ctx)
|
||||
{
|
||||
static const char msgtemplate[] =
|
||||
|
@ -549,7 +549,7 @@ int do_cmdline(int argc, char **argv, int do_everything, Conf *conf)
|
||||
return err;
|
||||
}
|
||||
|
||||
GtkWidget *make_gtk_toplevel_window(void *frontend)
|
||||
GtkWidget *make_gtk_toplevel_window(Frontend *frontend)
|
||||
{
|
||||
return gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
}
|
||||
|
322
unix/gtkwin.c
322
unix/gtkwin.c
File diff suppressed because it is too large
Load Diff
16
unix/unix.h
16
unix/unix.h
@ -175,7 +175,7 @@ void launch_saved_session(const char *str);
|
||||
void session_window_closed(void);
|
||||
void window_setup_error(const char *errmsg);
|
||||
#ifdef MAY_REFER_TO_GTK_IN_HEADERS
|
||||
GtkWidget *make_gtk_toplevel_window(void *frontend);
|
||||
GtkWidget *make_gtk_toplevel_window(Frontend *frontend);
|
||||
#endif
|
||||
|
||||
const struct Backend_vtable *select_backend(Conf *conf);
|
||||
@ -189,16 +189,16 @@ enum MenuAction {
|
||||
MA_RESTART_SESSION, MA_CHANGE_SETTINGS, MA_CLEAR_SCROLLBACK,
|
||||
MA_RESET_TERMINAL, MA_EVENT_LOG
|
||||
};
|
||||
void app_menu_action(void *frontend, enum MenuAction);
|
||||
void app_menu_action(Frontend *frontend, enum MenuAction);
|
||||
|
||||
/* Things pty.c needs from pterm.c */
|
||||
const char *get_x_display(void *frontend);
|
||||
int font_dimension(void *frontend, int which);/* 0 for width, 1 for height */
|
||||
int get_windowid(void *frontend, long *id);
|
||||
const char *get_x_display(Frontend *frontend);
|
||||
int font_dimension(Frontend *frontend, int which);/* 0 for width, 1 for height */
|
||||
int get_windowid(Frontend *frontend, long *id);
|
||||
|
||||
/* Things gtkdlg.c needs from pterm.c */
|
||||
#ifdef MAY_REFER_TO_GTK_IN_HEADERS
|
||||
GtkWidget *get_window(void *frontend);
|
||||
GtkWidget *get_window(Frontend *frontend);
|
||||
enum DialogSlot {
|
||||
DIALOG_SLOT_RECONFIGURE,
|
||||
DIALOG_SLOT_NETWORK_PROMPT,
|
||||
@ -207,8 +207,8 @@ enum DialogSlot {
|
||||
DIALOG_SLOT_CONNECTION_FATAL,
|
||||
DIALOG_SLOT_LIMIT /* must remain last */
|
||||
};
|
||||
void register_dialog(void *frontend, enum DialogSlot slot, GtkWidget *dialog);
|
||||
void unregister_dialog(void *frontend, enum DialogSlot slot);
|
||||
void register_dialog(Frontend *frontend, enum DialogSlot slot, GtkWidget *dialog);
|
||||
void unregister_dialog(Frontend *frontend, enum DialogSlot slot);
|
||||
#endif
|
||||
|
||||
/* Things pterm.c needs from gtkdlg.c */
|
||||
|
@ -63,15 +63,15 @@ void cleanup_exit(int code)
|
||||
exit(code);
|
||||
}
|
||||
|
||||
void set_busy_status(void *frontend, int status)
|
||||
void set_busy_status(Frontend *frontend, int status)
|
||||
{
|
||||
}
|
||||
|
||||
void update_specials_menu(void *frontend)
|
||||
void update_specials_menu(Frontend *frontend)
|
||||
{
|
||||
}
|
||||
|
||||
void notify_remote_exit(void *frontend)
|
||||
void notify_remote_exit(Frontend *frontend)
|
||||
{
|
||||
}
|
||||
|
||||
@ -113,7 +113,7 @@ static int block_and_read(int fd, void *buf, size_t len)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int verify_ssh_host_key(void *frontend, char *host, int port,
|
||||
int verify_ssh_host_key(Frontend *frontend, char *host, int port,
|
||||
const char *keytype, char *keystr, char *fingerprint,
|
||||
void (*callback)(void *ctx, int result), void *ctx)
|
||||
{
|
||||
@ -223,7 +223,7 @@ int verify_ssh_host_key(void *frontend, char *host, int port,
|
||||
* Ask whether the selected algorithm is acceptable (since it was
|
||||
* below the configured 'warn' threshold).
|
||||
*/
|
||||
int askalg(void *frontend, const char *algtype, const char *algname,
|
||||
int askalg(Frontend *frontend, const char *algtype, const char *algname,
|
||||
void (*callback)(void *ctx, int result), void *ctx)
|
||||
{
|
||||
static const char msg[] =
|
||||
@ -270,7 +270,7 @@ int askalg(void *frontend, const char *algtype, const char *algname,
|
||||
}
|
||||
}
|
||||
|
||||
int askhk(void *frontend, const char *algname, const char *betteralgs,
|
||||
int askhk(Frontend *frontend, const char *algname, const char *betteralgs,
|
||||
void (*callback)(void *ctx, int result), void *ctx)
|
||||
{
|
||||
static const char msg[] =
|
||||
@ -327,7 +327,7 @@ int askhk(void *frontend, const char *algname, const char *betteralgs,
|
||||
* Ask whether to wipe a session log file before writing to it.
|
||||
* Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
|
||||
*/
|
||||
int askappend(void *frontend, Filename *filename,
|
||||
int askappend(Frontend *frontend, Filename *filename,
|
||||
void (*callback)(void *ctx, int result), void *ctx)
|
||||
{
|
||||
static const char msgtemplate[] =
|
||||
@ -410,7 +410,7 @@ void console_provide_logctx(LogContext *logctx)
|
||||
console_logctx = logctx;
|
||||
}
|
||||
|
||||
void logevent(void *frontend, const char *string)
|
||||
void logevent(Frontend *frontend, const char *string)
|
||||
{
|
||||
struct termios cf;
|
||||
if ((flags & FLAG_STDERR) && (flags & FLAG_VERBOSE))
|
||||
@ -546,7 +546,7 @@ int console_get_userpass_input(prompts_t *p)
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
void frontend_keypress(void *handle)
|
||||
void frontend_keypress(Frontend *frontend)
|
||||
{
|
||||
/*
|
||||
* This is nothing but a stub, in console code.
|
||||
|
@ -42,7 +42,7 @@ void nonfatal(const char *p, ...)
|
||||
va_end(ap);
|
||||
fputc('\n', stderr);
|
||||
}
|
||||
void connection_fatal(void *frontend, const char *p, ...)
|
||||
void connection_fatal(Frontend *frontend, const char *p, ...)
|
||||
{
|
||||
va_list ap;
|
||||
fprintf(stderr, "FATAL ERROR: ");
|
||||
@ -93,7 +93,7 @@ FontSpec *platform_default_fontspec(const char *name) { return fontspec_new("");
|
||||
Filename *platform_default_filename(const char *name) { return filename_from_str(""); }
|
||||
char *x_get_default(const char *key) { return NULL; }
|
||||
void log_eventlog(LogContext *logctx, const char *event) {}
|
||||
int from_backend(void *frontend, int is_stderr, const void *data, int datalen)
|
||||
int from_backend(Frontend *fe, int is_stderr, const void *data, int datalen)
|
||||
{ assert(!"only here to satisfy notional call from backend_socket_log"); }
|
||||
|
||||
/*
|
||||
|
@ -58,7 +58,7 @@ void nonfatal(const char *p, ...)
|
||||
fputc('\n', stderr);
|
||||
postmsg(&cf);
|
||||
}
|
||||
void connection_fatal(void *frontend, const char *p, ...)
|
||||
void connection_fatal(Frontend *frontend, const char *p, ...)
|
||||
{
|
||||
struct termios cf;
|
||||
va_list ap;
|
||||
@ -132,7 +132,7 @@ int term_ldisc(Terminal *term, int mode)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
void frontend_echoedit_update(void *frontend, int echo, int edit)
|
||||
void frontend_echoedit_update(Frontend *frontend, int echo, int edit)
|
||||
{
|
||||
/* Update stdin read mode to reflect changes in line discipline. */
|
||||
struct termios mode;
|
||||
@ -190,7 +190,7 @@ static char *get_ttychar(struct termios *t, int index)
|
||||
return dupprintf("^<%d>", c);
|
||||
}
|
||||
|
||||
char *get_ttymode(void *frontend, const char *mode)
|
||||
char *get_ttymode(Frontend *frontend, const char *mode)
|
||||
{
|
||||
/*
|
||||
* Propagate appropriate terminal modes from the local terminal,
|
||||
@ -400,7 +400,7 @@ int try_output(int is_stderr)
|
||||
return bufchain_size(&stdout_data) + bufchain_size(&stderr_data);
|
||||
}
|
||||
|
||||
int from_backend(void *frontend_handle, int is_stderr,
|
||||
int from_backend(Frontend *frontend, int is_stderr,
|
||||
const void *data, int len)
|
||||
{
|
||||
if (is_stderr) {
|
||||
@ -413,7 +413,7 @@ int from_backend(void *frontend_handle, int is_stderr,
|
||||
}
|
||||
}
|
||||
|
||||
int from_backend_untrusted(void *frontend_handle, const void *data, int len)
|
||||
int from_backend_untrusted(Frontend *frontend, const void *data, int len)
|
||||
{
|
||||
/*
|
||||
* No "untrusted" output should get here (the way the code is
|
||||
@ -423,7 +423,7 @@ int from_backend_untrusted(void *frontend_handle, const void *data, int len)
|
||||
return 0; /* not reached */
|
||||
}
|
||||
|
||||
int from_backend_eof(void *frontend_handle)
|
||||
int from_backend_eof(Frontend *frontend)
|
||||
{
|
||||
assert(outgoingeof == EOF_NO);
|
||||
outgoingeof = EOF_PENDING;
|
||||
|
@ -71,7 +71,7 @@ static int pty_signal_pipe[2] = { -1, -1 }; /* obviously bogus initial val */
|
||||
struct pty_tag {
|
||||
Conf *conf;
|
||||
int master_fd, slave_fd;
|
||||
void *frontend;
|
||||
Frontend *frontend;
|
||||
char name[FILENAME_MAX];
|
||||
pid_t child_pid;
|
||||
int term_width, term_height;
|
||||
@ -729,7 +729,7 @@ static void pty_uxsel_setup(Pty pty)
|
||||
* Also places the canonical host name into `realhost'. It must be
|
||||
* freed by the caller.
|
||||
*/
|
||||
static const char *pty_init(void *frontend, Backend **backend_handle,
|
||||
static const char *pty_init(Frontend *frontend, Backend **backend_handle,
|
||||
Conf *conf, const char *host, int port,
|
||||
char **realhost, int nodelay, int keepalive)
|
||||
{
|
||||
|
@ -18,7 +18,7 @@
|
||||
#define SERIAL_MAX_BACKLOG 4096
|
||||
|
||||
typedef struct serial_backend_data {
|
||||
void *frontend;
|
||||
Frontend *frontend;
|
||||
int fd;
|
||||
int finished;
|
||||
int inbufsize;
|
||||
@ -288,7 +288,7 @@ static const char *serial_configure(Serial serial, Conf *conf)
|
||||
* Also places the canonical host name into `realhost'. It must be
|
||||
* freed by the caller.
|
||||
*/
|
||||
static const char *serial_init(void *frontend_handle, Backend **backend_handle,
|
||||
static const char *serial_init(Frontend *frontend, Backend **backend_handle,
|
||||
Conf *conf,
|
||||
const char *host, int port, char **realhost,
|
||||
int nodelay, int keepalive)
|
||||
@ -301,7 +301,7 @@ static const char *serial_init(void *frontend_handle, Backend **backend_handle,
|
||||
serial->backend.vt = &serial_backend;
|
||||
*backend_handle = &serial->backend;
|
||||
|
||||
serial->frontend = frontend_handle;
|
||||
serial->frontend = frontend;
|
||||
serial->finished = FALSE;
|
||||
serial->inbufsize = 0;
|
||||
bufchain_init(&serial->output_data);
|
||||
|
@ -66,7 +66,7 @@ Filename *platform_default_filename(const char *name)
|
||||
return filename_from_str("");
|
||||
}
|
||||
|
||||
char *get_ttymode(void *frontend, const char *mode) { return NULL; }
|
||||
char *get_ttymode(Frontend *frontend, const char *mode) { return NULL; }
|
||||
|
||||
int get_userpass_input(prompts_t *p, bufchain *input)
|
||||
{
|
||||
|
Reference in New Issue
Block a user