-
Notifications
You must be signed in to change notification settings - Fork 64
/
notify.h
112 lines (98 loc) · 3.89 KB
/
notify.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
stripped-down version of <xview/notify.h>
(c) Copyright 1989, 1990, 1991 Sun Microsystems, Inc. Sun design
patents pending in the U.S. and foreign countries. OPEN LOOK is
a trademark of USL. Used by written permission of the owners.
*/
/*
* Client notification function return values for notifier to client calls.
*/
typedef enum notify_value {
NOTIFY_DONE = 0, /* Handled notification */
NOTIFY_IGNORED = 1, /* Did nothing about notification */
NOTIFY_UNEXPECTED = 2 /* Notification not expected */
} Notify_value;
typedef enum notify_error {
NOTIFY_OK = 0, /* Success */
NOTIFY_UNKNOWN_CLIENT = 1, /* Client argument unknown to notifier */
NOTIFY_NO_CONDITION = 2, /* Client not registered for given
* condition
*/
NOTIFY_BAD_ITIMER = 3, /* Itimer type unknown */
NOTIFY_BAD_SIGNAL = 4, /* Signal number out of range */
NOTIFY_NOT_STARTED = 5, /* Notify_stop called & notifier not
* started
*/
NOTIFY_DESTROY_VETOED = 6, /* Some client didn't want to die when
* called notify_die(DESTROY_CHECKING)
*/
NOTIFY_INTERNAL_ERROR = 7, /* Something wrong in the notifier */
NOTIFY_SRCH = 8, /* No such process */
NOTIFY_BADF = 9, /* Bad file number */
NOTIFY_NOMEM = 10, /* Not enough core */
NOTIFY_INVAL = 11, /* Invalid argument */
NOTIFY_FUNC_LIMIT = 12 /* Too many interposition functions */
} Notify_error;
typedef enum notify_signal_mode {
NOTIFY_SYNC = 0,
NOTIFY_ASYNC = 1
} Notify_signal_mode;
/*
* Opaque client handle.
*/
typedef unsigned long Notify_client;
/*
* A pointer to functions returning a Notify_value.
*/
typedef Notify_value (*Notify_func)(Notify_client client);
typedef Notify_value (*Notify_func_input)(Notify_client client, int fd);
typedef Notify_value (*Notify_func_signal)(Notify_client client, int
signal, Notify_signal_mode mode);
#define NOTIFY_FUNC_NULL ((Notify_func)0)
#define NOTIFY_FUNC_INPUT_NULL ((Notify_func_input)0)
#define NOTIFY_FUNC_SIGNAL_NULL ((Notify_func_signal)0)
/*
* Establish event handler for file descriptor 'fd'. The handler
* 'func' is called whenever 'fd' is ready for input. Calling
* notify_set_input_func with func=NOTIFY_FUNC_NULL removes
* the handler. Return 'func' on success, NOTIFY_FUNC_NULL
* on failure.
*/
extern Notify_func_input notify_set_input_func (Notify_client nclient,
Notify_func_input func, int fd);
/*
* Establish event handler for file descriptor 'fd'. The handler
* 'func' is called whenever 'fd' is ready for output. Calling
* notify_set_input_func with func=NOTIFY_FUNC_NULL removes
* the handler. Return 'func' on success, NOTIFY_FUNC_NULL
* on failure.
*/
extern Notify_func notify_set_output_func (Notify_client nclient,
Notify_func func, int fd);
/*
* Establish event handler that is called periodically.
* The function 'func' is called every 'interval' milliseconds.
* To change the period, call the function with the original
* 'client' and 'func' values, and a changed value of 'interval'.
* An interval value of 0 disables the periodic invocation of
* 'func'. No return value.
*/
extern void notify_set_periodic_func(Notify_client client, Notify_func
func, int interval);
/*
* Main loop. Never exits unless notify_stop() is called.
*/
extern Notify_error notify_start(void);
/*
* Abort event handler.
*/
extern Notify_error notify_stop(void);
/*
* Establish signal handler.
*/
extern Notify_func_signal notify_set_signal_func(Notify_client nclient,
Notify_func_signal func, int sig, Notify_signal_mode mode);
/*
* Initialize Readfds (flag = 0), Writefds (1), Exceptfds (2).
*/
extern void notify_set_socket(int sock, int flag);