Having created and used uxsel, it actually turns out to be
[sgt/putty] / unix / uxsel.c
index aaedc02..7142acb 100644 (file)
@@ -19,6 +19,7 @@ struct fd {
     int fd;
     int rwx;                          /* 4=except 2=write 1=read */
     uxsel_callback_fn callback;
+    int id;                           /* for uxsel_input_remove */
 };
 
 static tree234 *fds;
@@ -70,17 +71,20 @@ void uxsel_set(int fd, int rwx, uxsel_callback_fn callback)
 
     oldfd = find234(fds, newfd, NULL);
     if (oldfd) {
+       uxsel_input_remove(oldfd->id);
        del234(fds, oldfd);
        sfree(oldfd);
     }
 
     add234(fds, newfd);
+    newfd->id = uxsel_input_add(fd, rwx);
 }
 
 void uxsel_del(int fd)
 {
     struct fd *oldfd = find234(fds, &fd, uxsel_fd_findcmp);
     if (oldfd) {
+       uxsel_input_remove(oldfd->id);
        del234(fds, oldfd);
        sfree(oldfd);
     }