#ifndef _LIBSYSEVENT_IMPL_H
#define _LIBSYSEVENT_IMPL_H
#ifdef __cplusplus
extern "C" {
#endif
#define CHAN_PATH "/var/run/sysevent_channels"
#define REG_DOOR "reg_door"
#define MAX_SUBSCRIPTION_SZ 1024
typedef struct sysevent_impl_handle {
int sh_bound;
int sh_type;
uint32_t sh_id;
int sh_door_desc;
char *sh_door_name;
char *sh_channel_name;
char *sh_channel_path;
void *sh_priv_data;
mutex_t sh_lock;
} sysevent_impl_hdl_t;
typedef struct sysevent_queue {
struct sysevent_queue *sq_next;
sysevent_t *sq_ev;
} sysevent_queue_t;
typedef struct subscriber_priv {
cond_t sp_cv;
mutex_t sp_qlock;
char *sp_door_name;
thread_t sp_handler_tid;
struct sysevent_queue *sp_evq_head;
struct sysevent_queue *sp_evq_tail;
void (*sp_func)(sysevent_t *ev);
} subscriber_priv_t;
typedef struct subscriber_data {
int sd_flag;
char *sd_door_name;
} subscriber_data_t;
typedef struct publisher_priv {
struct class_lst *pp_class_hash[CLASS_HASH_SZ + 1];
subscriber_data_t *pp_subscriber_list[MAX_SUBSCRIBERS + 1];
} publisher_priv_t;
#define ACTIVE 1
#define SEND_AGAIN 2
#define SYSEVENT_IMPL_HNDL(sehp) ((sysevent_impl_hdl_t *)(void *)(sehp))
#define SH_BOUND(sehp) (SYSEVENT_IMPL_HNDL(sehp)->sh_bound)
#define SH_TYPE(sehp) (SYSEVENT_IMPL_HNDL(sehp)->sh_type)
#define SH_RESULT(sehp) (SYSEVENT_IMPL_HNDL(sehp)->sh_result)
#define SH_ID(sehp) (SYSEVENT_IMPL_HNDL(sehp)->sh_id)
#define SH_DOOR_DESC(sehp) (SYSEVENT_IMPL_HNDL(sehp)->sh_door_desc)
#define SH_DOOR_NAME(sehp) (SYSEVENT_IMPL_HNDL(sehp)->sh_door_name)
#define SH_CHANNEL_NAME(sehp) (SYSEVENT_IMPL_HNDL(sehp)->sh_channel_name)
#define SH_CHANNEL_PATH(sehp) (SYSEVENT_IMPL_HNDL(sehp)->sh_channel_path)
#define SH_LOCK(sehp) (&(SYSEVENT_IMPL_HNDL(sehp)->sh_lock))
#define SH_PRIV_DATA(sehp) (SYSEVENT_IMPL_HNDL(sehp)->sh_priv_data)
#define SH_CLASS_HASH(sehp) (((publisher_priv_t *) \
SH_PRIV_DATA(sehp))->pp_class_hash)
#define SH_SUBSCRIBER(sehp, id) (((publisher_priv_t *) \
SH_PRIV_DATA(sehp))->pp_subscriber_list[id])
typedef struct evchan_subscriber evchan_subscr_t;
typedef struct evchan_sub_head {
evchan_subscr_t *evchan_sub_next;
} evchan_sub_head_t;
typedef struct evchan_impl_handle {
pid_t ev_pid;
int ev_fd;
mutex_t ev_lock;
evchan_sub_head_t ev_sub;
} evchan_impl_hdl_t;
#define EVCHAN_IMPL_HNDL(evcp) ((evchan_impl_hdl_t *)(void *)(evcp))
#define EV_PID(evcp) (EVCHAN_IMPL_HNDL(evcp)->ev_pid)
#define EV_FD(evcp) (EVCHAN_IMPL_HNDL(evcp)->ev_fd)
#define EV_LOCK(evcp) (&(EVCHAN_IMPL_HNDL(evcp)->ev_lock))
#define EV_SUB(evcp) (&(EVCHAN_IMPL_HNDL(evcp)->ev_sub))
#define EV_SUB_NEXT(evcp) (EVCHAN_IMPL_HNDL(evcp)->ev_sub.evchan_sub_next)
struct sysevent_subattr_impl {
door_xcreate_server_func_t *xs_thrcreate;
void *xs_thrcreate_cookie;
door_xcreate_thrsetup_func_t *xs_thrsetup;
void *xs_thrsetup_cookie;
pthread_attr_t *xs_thrattr;
sigset_t xs_sigmask;
};
struct evchan_subscriber {
evchan_subscr_t *evsub_next;
evchan_impl_hdl_t *ev_subhead;
int evsub_door_desc;
char *evsub_sid;
void *evsub_cookie;
int (*evsub_func)(sysevent_t *, void *);
struct sysevent_subattr_impl *evsub_attr;
uint32_t evsub_state;
};
#define EVCHAN_SUB_STATE_ACTIVE 1
#define EVCHAN_SUB_STATE_CLOSING 2
#define EVCHAN_SUBSCR(subp) ((evchan_subscr_t *)(subp))
#define EVCH_ISCHANCHAR(c) (isalnum(c) || (c) == '.' || (c) == ':' || \
(c) == '-' || (c) == '_')
#ifdef __cplusplus
}
#endif
#endif