1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-25 01:02:24 +00:00

Change uxsel_input_add's return type from int to pointer.

In case a front end needs to store more than an integer id to be
returned to uxsel_input_remove, we now return a pointer to a
frontend-defined structure.
This commit is contained in:
Simon Tatham 2015-08-16 12:50:46 +01:00
parent 0413cc856c
commit b5423b51d4
6 changed files with 25 additions and 14 deletions

View File

@ -3218,17 +3218,26 @@ int do_cmdline(int argc, char **argv, int do_everything, int *allow_launch,
return err;
}
int uxsel_input_add(int fd, int rwx) {
struct uxsel_id {
int id;
};
uxsel_id *uxsel_input_add(int fd, int rwx) {
uxsel_id *id = snew(uxsel_id);
int flags = 0;
if (rwx & 1) flags |= GDK_INPUT_READ;
if (rwx & 2) flags |= GDK_INPUT_WRITE;
if (rwx & 4) flags |= GDK_INPUT_EXCEPTION;
assert(flags);
return gdk_input_add(fd, flags, fd_input_func, NULL);
id->id = gdk_input_add(fd, flags, fd_input_func, NULL);
return id;
}
void uxsel_input_remove(int id) {
gdk_input_remove(id);
void uxsel_input_remove(uxsel_id *id) {
gdk_input_remove(id->id);
sfree(id);
}
char *setup_fonts_ucs(struct gui_data *inst)

View File

@ -118,6 +118,7 @@ void premsg(struct termios *);
void postmsg(struct termios *);
/* The interface used by uxsel.c */
typedef struct uxsel_id uxsel_id;
void uxsel_init(void);
typedef int (*uxsel_callback_fn)(int fd, int event);
void uxsel_set(int fd, int rwx, uxsel_callback_fn callback);
@ -126,8 +127,8 @@ int select_result(int fd, int event);
int first_fd(int *state, int *rwx);
int next_fd(int *state, int *rwx);
/* The following are expected to be provided _to_ uxsel.c by the frontend */
int uxsel_input_add(int fd, int rwx); /* returns an id */
void uxsel_input_remove(int id);
uxsel_id *uxsel_input_add(int fd, int rwx); /* returns an id */
void uxsel_input_remove(uxsel_id *id);
/* uxcfg.c */
struct controlbox;

View File

@ -88,8 +88,8 @@ void pageant_log(void *ctx, const char *fmt, va_list ap)
* In Pageant our selects are synchronous, so these functions are
* empty stubs.
*/
int uxsel_input_add(int fd, int rwx) { return 0; }
void uxsel_input_remove(int id) { }
uxsel_id *uxsel_input_add(int fd, int rwx) { return NULL; }
void uxsel_input_remove(uxsel_id *id) { }
/*
* More stubs.

View File

@ -533,8 +533,8 @@ void sigwinch(int signum)
* In Plink our selects are synchronous, so these functions are
* empty stubs.
*/
int uxsel_input_add(int fd, int rwx) { return 0; }
void uxsel_input_remove(int id) { }
uxsel_id *uxsel_input_add(int fd, int rwx) { return NULL; }
void uxsel_input_remove(uxsel_id *id) { }
/*
* Short description of parameters.

View File

@ -19,7 +19,7 @@ struct fd {
int fd;
int rwx; /* 4=except 2=write 1=read */
uxsel_callback_fn callback;
int id; /* for uxsel_input_remove */
uxsel_id *id; /* for uxsel_input_remove */
};
static tree234 *fds;
@ -80,7 +80,8 @@ void uxsel_del(int fd)
{
struct fd *oldfd = find234(fds, &fd, uxsel_fd_findcmp);
if (oldfd) {
uxsel_input_remove(oldfd->id);
if (oldfd->id)
uxsel_input_remove(oldfd->id);
del234(fds, oldfd);
sfree(oldfd);
}

View File

@ -26,8 +26,8 @@
* In PSFTP our selects are synchronous, so these functions are
* empty stubs.
*/
int uxsel_input_add(int fd, int rwx) { return 0; }
void uxsel_input_remove(int id) { }
uxsel_id *uxsel_input_add(int fd, int rwx) { return NULL; }
void uxsel_input_remove(uxsel_id *id) { }
char *x_get_default(const char *key)
{