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