4dad4168b0c36fa4415757501fa9ed82a485aeee
[spider.git] / src / sel.h
1 /*
2  * sel.c
3  * 
4  * util routines for do the various select activities
5  * 
6  * Copyright 1996 (c) D-J Koopman
7  * 
8  * $Header$
9  * 
10  * $Log$
11  * Revision 1.4  2002-01-27 15:35:33  minima
12  * try to fix EOF on standard input problems
13  *
14  * Revision 1.3  2000/07/20 14:16:00  minima
15  * can use Sourceforge now!
16  * added user->qra cleaning
17  * added 4 digit qra to user broadcast dxspots if available
18  *
19  * Revision 1.2  2000/03/26 14:22:59  djk
20  * removed some irrelevant log info
21  *
22  * Revision 1.1  2000/03/26 00:03:30  djk
23  * first cut of client
24  *
25  * Revision 1.1  1997/01/03 23:44:31  djk
26  * initial workings
27  *
28  *
29  */
30
31 #ifndef _SEL_H
32 #define _SEL_H
33
34 static char _sel_h_rcsid[] = "$Id$";
35
36 #include "chain.h"
37
38 typedef struct {
39         int cnum;                                                  /* from open */
40         short err;                                                 /* error flag, to delay closing if required */
41         short sort;                                                /* this thing's sort */
42         short flags;                                               /* fdset flags */
43         char *name;                                                /* device name */
44         void *fcb;                                                 /* any fcb associated with this thing */
45         reft *msgbase;                                     /* any messages for this port */
46         int (*handler)();                                  /* the handler for this thingy */
47         int (*closehandler)();          /* special close handler */
48 } sel_t;
49
50 extern sel_t *sel;
51 extern int sel_max;
52 extern int sel_top;
53 extern int sel_inuse;
54 extern time_t sel_systime;
55 extern struct timeval sel_tv;
56
57 #define SEL_INPUT 1
58 #define SEL_OUTPUT 2
59 #define SEL_ERROR 4
60 #define SEL_IOALL 7
61
62 void sel_init(int, long, long);                                    /* initialise the select thing */
63 void sel_run();                                            /* run the select multiplexor */
64 sel_t *sel_open(int, void *, char *, int (*)(), int, int);/*  initialise a slot */
65 void sel_closehandler(sel_t *, void (*)());     /* post a closehandler for this cnum */
66
67 void sel_close(sel_t *);
68 int sel_error(sel_t *, int);               /* set/clear error flag */
69
70 #endif