fix console.pl max scroll depth
[spider.git] / src / sel.c
index 2d8972f23ca02b7da2759797566b8304d5e62aad..f476ed744784db6bd4d9394a4442f1c85d1c815a 100755 (executable)
--- a/src/sel.c
+++ b/src/sel.c
@@ -81,6 +81,16 @@ sel_t *sel_open(int cnum, void *fcb, char *name, int (*handler)(), int sort, int
        return sp;
 }
 
+/* 
+ * post a close handler for this connection, to do special things
+ * in the event of this cnum closing, the default is just to close
+ */
+
+void sel_closehandler(sel_t *sp, void (*handler)())
+{
+       sp->closehandler = handler;
+}
+
 /*
  * close (and thus clear down) a slot, it is assumed that you have done whatever
  * you need to do to close the actual device already
@@ -89,6 +99,11 @@ sel_t *sel_open(int cnum, void *fcb, char *name, int (*handler)(), int sort, int
 void sel_close(sel_t *sp)
 {
        if (sp->sort) {
+               if (sp->closehandler) {
+                       (sp->closehandler)(sp);
+               } else {
+                       close(sp->cnum);
+               }
                chain_flush(sp->msgbase);
                free(sp->msgbase);
                free(sp->name);
@@ -183,29 +198,29 @@ int sel_error(sel_t *sp, int err)
        int r = sp->err;
        if (err >= 0)
                sp->err = err;
-       return err;
+       return r;
 }
 
 /*
  * $Log$
- * Revision 1.1  2000-03-26 00:03:30  djk
- * first cut of client
+ * Revision 1.5  2002-01-27 15:35:33  minima
+ * try to fix EOF on standard input problems
  *
- * Revision 1.3  1998/01/02 19:39:59  djk
- * made various changes to cope with glibc
- * fixed problem with extended status in etsi_router
+ * Revision 1.4  2000/07/20 14:16:00  minima
+ * can use Sourceforge now!
+ * added user->qra cleaning
+ * added 4 digit qra to user broadcast dxspots if available
  *
- * Revision 1.2  1997/06/18 18:44:31  djk
- * A working hayes implementation!
+ * Revision 1.3  2000/03/30 22:51:14  djk
+ * fixed connect code in client.pl so it doesn't falsely recognise /spider
+ * /src/client as a 'client' directive.
+ * Tidied up the C client a bit
  *
- * Revision 1.1  1997/01/28 16:14:38  djk
- * moved these into lib as general routines to use with sel
+ * Revision 1.2  2000/03/26 14:22:59  djk
+ * removed some irrelevant log info
  *
- * Revision 1.3  1997/01/15 21:23:26  djk
- * fixed a few minor svlp problems and added the router logging system
- *
- * Revision 1.2  1997/01/13 23:34:56  djk
- * The first working test version of smsd
+ * Revision 1.1  2000/03/26 00:03:30  djk
+ * first cut of client
  *
  * Revision 1.1  1997/01/03 23:44:31  djk
  * initial workings