]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Change uxsel_input_add's return type from int to pointer.
authorSimon Tatham <anakin@pobox.com>
Sun, 16 Aug 2015 11:50:46 +0000 (12:50 +0100)
committerSimon Tatham <anakin@pobox.com>
Sun, 16 Aug 2015 12:11:51 +0000 (13:11 +0100)
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.

unix/gtkwin.c
unix/unix.h
unix/uxpgnt.c
unix/uxplink.c
unix/uxsel.c
unix/uxsftp.c

index 726a7d2cddee438e857bd6d687766f68bf9c0dee..78adcc5e88d5259f5f43ad9820390f2a195b0884 100644 (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)
index b2c45788267f4eae0740541981875d747453900d..d7bed49aed3644765de10554141d775702af29f9 100644 (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;
index bfd4f0ffe3e6a018c6e44468f28dc8e288482a84..2f9826b840c0bb6e7585eba524162dd4e55387f3 100644 (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.
index 64c3cabcdacc66afd58e6ec87b9684e14725a863..40b126615e31f3b3662a29ac8585ba2e4c100b84 100644 (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.
index e2979c9a01e6aed34f27c5f2bf440bb5dd083717..fa48507fced4a0590fa557a192d411c9c6888fca 100644 (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);
     }
index 21d7f40fb94aa1136d5e7bdb66c083170f8bd66a..7039b69b5c2d1ace1663b0c00a529a03ee5a449e 100644 (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)
 {