/*
 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#ifndef	_LIBCONTRACT_H
#define	_LIBCONTRACT_H

#pragma ident	"@(#)libcontract.h	1.1	04/07/15 SMI"

#include <sys/types.h>
#include <sys/contract.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef void *ct_stathdl_t;
typedef void *ct_evthdl_t;

/*
 * Common routines
 */
extern int ct_tmpl_activate(int);
extern int ct_tmpl_clear(int);
extern int ct_tmpl_create(int, ctid_t *);
extern int ct_tmpl_set_cookie(int, uint64_t);
extern int ct_tmpl_get_cookie(int, uint64_t *);
extern int ct_tmpl_set_critical(int, uint_t);
extern int ct_tmpl_get_critical(int, uint_t *);
extern int ct_tmpl_set_informative(int, uint_t);
extern int ct_tmpl_get_informative(int, uint_t *);

extern int ct_ctl_adopt(int);
extern int ct_ctl_abandon(int);
extern int ct_ctl_ack(int, ctevid_t);
extern int ct_ctl_qack(int, ctevid_t);
extern int ct_ctl_newct(int, ctevid_t, int);

extern int ct_status_read(int, int, ct_stathdl_t *);
extern void ct_status_free(ct_stathdl_t);

extern ctid_t ct_status_get_id(ct_stathdl_t);
extern zoneid_t ct_status_get_zoneid(ct_stathdl_t);
extern const char *ct_status_get_type(ct_stathdl_t);
extern id_t ct_status_get_holder(ct_stathdl_t);
extern ctstate_t ct_status_get_state(ct_stathdl_t);
extern int ct_status_get_nevents(ct_stathdl_t);
extern int ct_status_get_ntime(ct_stathdl_t);
extern int ct_status_get_qtime(ct_stathdl_t);
extern ctevid_t ct_status_get_nevid(ct_stathdl_t);
extern uint_t ct_status_get_informative(ct_stathdl_t);
extern uint_t ct_status_get_critical(ct_stathdl_t);
extern uint64_t ct_status_get_cookie(ct_stathdl_t);

extern int ct_event_read(int, ct_evthdl_t *);
extern int ct_event_read_critical(int, ct_evthdl_t *);
extern int ct_event_reset(int);
extern int ct_event_reliable(int);
extern void ct_event_free(ct_evthdl_t);

extern uint_t ct_event_get_flags(ct_evthdl_t);
extern ctid_t ct_event_get_ctid(ct_evthdl_t);
extern ctevid_t ct_event_get_evid(ct_evthdl_t);
extern uint_t ct_event_get_type(ct_evthdl_t);
extern int ct_event_get_nevid(ct_evthdl_t, ctevid_t *);
extern int ct_event_get_newct(ct_evthdl_t, ctid_t *);

/*
 * Process contract routines
 */
extern int ct_pr_tmpl_set_transfer(int, ctid_t);
extern int ct_pr_tmpl_set_fatal(int, uint_t);
extern int ct_pr_tmpl_set_param(int, uint_t);

extern int ct_pr_tmpl_get_transfer(int, ctid_t *);
extern int ct_pr_tmpl_get_fatal(int, uint_t *);
extern int ct_pr_tmpl_get_param(int, uint_t *);

extern int ct_pr_event_get_pid(ct_evthdl_t, pid_t *);
extern int ct_pr_event_get_ppid(ct_evthdl_t, pid_t *);
extern int ct_pr_event_get_signal(ct_evthdl_t, int *);
extern int ct_pr_event_get_sender(ct_evthdl_t, pid_t *);
extern int ct_pr_event_get_senderct(ct_evthdl_t, ctid_t *);
extern int ct_pr_event_get_exitstatus(ct_evthdl_t, int *);
extern int ct_pr_event_get_pcorefile(ct_evthdl_t, const char **);
extern int ct_pr_event_get_gcorefile(ct_evthdl_t, const char **);
extern int ct_pr_event_get_zcorefile(ct_evthdl_t, const char **);

extern int ct_pr_status_get_param(ct_stathdl_t, uint_t *);
extern int ct_pr_status_get_fatal(ct_stathdl_t, uint_t *);
extern int ct_pr_status_get_members(ct_stathdl_t, pid_t **, uint_t *);
extern int ct_pr_status_get_contracts(ct_stathdl_t, ctid_t **, uint_t *);

#ifdef __cplusplus
}
#endif

#endif /* _LIBCONTRACT_H */
