/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/*                                                                        */
/*                                                                        */
/* Licensed Materials - Property of IBM                                   */
/*                                                                        */
/* Restricted Materials of IBM                                            */
/*                                                                        */
/* (C) COPYRIGHT International Business Machines Corp. 1996,2019          */
/* All Rights Reserved                                                    */
/*                                                                        */
/* US Government Users Restricted Rights - Use, duplication or            */
/* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.      */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */

/*===========================================================================*/
/*                                                                           */
/* Module Name:  ha_emapi.h                                                  */
/*                                                                           */
/* Description:                                                              */
/*                                                                           */
/*     Interface definitions of the Event Manager API needed by              */
/* Event Manager API clients and the Event Manager API library.              */
/*                                                                           */
/*     This file is formatted to be viewed with tab stops set to 4.          */
/*===========================================================================*/

/* sccsid = "@(#)41   1.14   src/rsct/pem/emcommon/ha_emapi.h, emcommon, rsct_rady, rady2035a 2/13/19 17:05:04" */

#ifndef _HA_EMAPI_H
#define _HA_EMAPI_H

#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

/*---------------------------------------------------------------------------*/
/*  Event Manager API Versioning.                                            */
/*---------------------------------------------------------------------------*/

/*
 *  HA_EM_VERSION identifies the version of the Event Manager Application
 *  Programming Interface desired by a client.  If the client has not
 *  specified a particular version, version 1 is used.  The current valid
 *  versions are 1 and 2.
 */

#ifndef HA_EM_VERSION
#define HA_EM_VERSION			1
#endif  /* HA_EM_VERSION */
 
#if (HA_EM_VERSION < 1) || (HA_EM_VERSION > 2)
#error "HA_EM_VERSION MUST BE AN INTEGER BETWEEN 1 AND 2, INCLUSIVE."
#endif

/*
 *  The following macros convert references to the generic names of EMAPI
 *  routines, like ha_em_start_session(), to references to version specific 
 *  EMAPI routines, like ha_em_start_session_1().  The version used during
 *  conversion is determined by the value of HA_EM_VERSION.  Note that these
 *  macros can deal with the different versions of a routine having different
 *  arguments.
 */

#define ha_em_start_session													\
	HA_EM_ROUTINE_VERSION(ha_em_start_session, HA_EM_VERSION)

#define ha_em_restart_session												\
	HA_EM_ROUTINE_VERSION(ha_em_restart_session, HA_EM_VERSION)

#define ha_em_end_session													\
	HA_EM_ROUTINE_VERSION(ha_em_end_session, HA_EM_VERSION)

#define ha_em_send_command													\
	HA_EM_ROUTINE_VERSION(ha_em_send_command, HA_EM_VERSION)

#define ha_em_receive_response												\
	HA_EM_ROUTINE_VERSION(ha_em_receive_response, HA_EM_VERSION)

#define ha_em_get_ecgid														\
	HA_EM_ROUTINE_VERSION(ha_em_get_ecgid, HA_EM_VERSION)

#define HA_EM_ROUTINE_VERSION(routine, version)								\
	HA_EM_ROUTINE_VERSION_GLUE(routine, version)

#define HA_EM_ROUTINE_VERSION_GLUE(routine, version)						\
	routine ## _ ## version


/*---------------------------------------------------------------------------*/
/*  Event Manager API Include Files.                                         */
/*---------------------------------------------------------------------------*/

#include <ha_emapi_base.h>


/*---------------------------------------------------------------------------*/
/*  Event Manager API constants.                                             */
/*---------------------------------------------------------------------------*/

/*
 *  Event Manager error values.
 */

#if (HA_EM_VERSION == 2) || defined(HA_EM_ALL_VERSIONS)
#define HA_EM_EGETDOMAINFO	1		/* Could not get domain information      */
#endif

#if (HA_EM_VERSION == 1) || defined(HA_EM_ALL_VERSIONS)
#define HA_EM_EGETPARTINFO	1		/* Could not get partition information   */
#endif

#define HA_EM_EGETNODNUM	2		/* Could not determine host node number  */
#define HA_EM_ESDROPEN		3		/* Could not establish a SDR session     */
#define HA_EM_ESDRGET		4		/* Could not obtain needed info from SDR */
#define HA_EM_ENOMEM		5		/* Could not allocate needed memory      */
#define HA_EM_ESYSCALL		6		/* Unexpected system call error          */
#define HA_EM_EEXIST		7		/* Unexpected re-use of file descriptor  */
#define HA_EM_ECONNREFUSED	8		/* Connection to E.M. daemon refused     */
#define HA_EM_ENOCONNECT	9		/* Connection error to E.M. daemon       */
#define HA_EM_ECONNLOST		10		/* Connection lost with E.M. daemon      */
#define HA_EM_EAUTHENT		11		/* Could not authenticate user           */
#define HA_EM_EAUTHOR 		12		/* User not authorized to use E.M. daemon*/
#define HA_EM_ESECSERV 		13		/* Security service error encountered    */
#define HA_EM_ENOENT 		14		/* Specified session does not exist      */
#define HA_EM_EBUSY 		15		/* Specified session is busy             */
#define HA_EM_EINVALID		16		/* Invalid parameter specified           */
#define HA_EM_ENOTOWNER		17		/* The process does not own the session  */
#define HA_EM_EUNEXPECTED	18		/* Unexpected condition occurred         */
#define HA_EM_EUNUSABLE		19		/* Specified session has become unusable */
#define HA_EM_ECONNECTED	20		/* Session restart not permitted         */
#define HA_EM_ENOSECDAEMON	21		/* E.M. daemon does not support security */
#define HA_EM_ENOSECCLIENT	22		/* Client does not support security		 */
#define HA_EM_EAUTHENTDAE	23		/* EMAPI could not authenticate daemon   */

/*
 *  Event Manager Domain Type Values.
 */

#if (HA_EM_VERSION == 2) || defined(HA_EM_ALL_VERSIONS)
#define HA_EM_DOMAIN_SP		1		/* The SP domain                         */
#define HA_EM_DOMAIN_HACMP	2		/* The HACMP domain                      */
#endif


/*---------------------------------------------------------------------------*/
/*  Event Manager API type and structure definitions.                        */
/*---------------------------------------------------------------------------*/

/*
 *  One event registration request is made through a ha_em_rb_reg
 *  (Event Manager Request Block: REGister) structure.  This structure is
 *  included in the ha_em_res_blk union, defined later in this file.
 */

struct ha_em_rb_reg {
	char		*em_name;			/* input:  resource variable name        */
	char		*em_rsrc_ID;		/* input:  resource ID                   */
	char		*em_expr;			/* input:  experssion                    */
	char		*em_raexpr;			/* input:  re-arm expression             */
	ha_em_eid_t	em_event_id;		/* output: event identifier              */
	void		(*em_cb)(int, struct ha_em_rpb_event *, void *);
									/* input:  callback routine address      */
	void		*em_cb_arg;			/* input:  callback routine argument     */
};

/*
 *  One query request is made through a ha_em_rb_query
 *  (Event Manager Request Block: QUERY) structure.  This structure is
 *  actually defined in ha_emapi_base.h.  It is included in the ha_em_res_blk
 *  union, defined later in this file.
 */

struct ha_em_rb_query;

/*
 *  Multiple requests of a particular type are made through a ha_em_res_blk
 *  (Event Manager REquestS BLocK) union.  All the requests must be of the
 *  same type.  The type of array used depends on the type of the requests
 *  being made.  The number of elements in the array depends on the number
 *  of requests being made.  This union is included in the ha_em_cmd_blk
 *  structure, defined later in this file.
 */

union ha_em_res_blk {
	struct ha_em_rb_reg		em_rb_reg[1];   /* Used to register for events   */
	ha_em_eid_t				em_rb_unreg[1];	/* Used to unregister events     */
	struct ha_em_rb_query	em_rb_query[1];	/* Used to query for information */
};

/*
 *  A block of requests of a particular type are made through a ha_em_cmd_blk
 *  (Event Manager CoMmand BLocK) structure passed to the ha_em_send_command()
 *  routine.  All the requests must be of the same type.  The type of the 
 *  requests are identified in the em_cmd and em_subcmd fields.  The requests
 *  themselves are in an array within the ha_em_res_blk union.
 */

struct ha_em_cmd_blk {
	int 				em_cmd_num_elem;	/* input:  number of requests    */
	short				em_cmd;				/* input:  type of requests      */
	short				em_subcmd;			/* input:  subtype of requests   */
	ha_em_qid_t			em_qid;				/* output: query identifier      */
	void				(*em_qcb)(int, struct ha_em_rsp_blk *, void *);
											/* input:  query callback routine*/
	void				*em_qcb_arg;		/* input:  query callback arg.   */
	union ha_em_res_blk	em_res_blk;			/* the array of requests         */
};

/*
 *  A block of responses of a particular type are delivered through a
 *  ha_em_rsp_blk (Event Manager ReSPonse BLocK) structure passed through
 *  the ha_em_receive_command() routine.  This structure is
 *  actually defined in ha_emapi_base.h.
 */

struct ha_em_rsp_blk;


/*---------------------------------------------------------------------------*/
/*  Event Manager API compatibility definitions.                             */
/*                                                                           */
/*  These definitions are provided to maintain source compatibility with     */
/*  programs written using prior versions of this header file.               */
/*  If these definitions result in inappropriate substitutions, then define  */
/*  the symbol HA_EM_NO_NAME_COMPAT prior to inclusion of this header file.  */
/*  If HA_EM_NO_NAME_COMPAT is defined, the source files that include this   */
/*  header file must be modified to use the new symbol names if the old      */
/*  symbol names are referenced therein.                                     */
/*---------------------------------------------------------------------------*/

#ifndef HA_EM_NO_NAME_COMPAT
#ifndef em_ivector
#define em_ivector em_rsrc_ID		/* replace em_ivector by em_rsrc_ID   */
#endif
#ifndef em_pred
#define em_pred    em_expr			/* replace em_pred by em_expr         */
#endif
#ifndef em_rapred
#define em_rapred  em_raexpr		/* replace em_rapred by em_raexpr     */
#endif
#endif	/* HA_EM_NO_NAME_COMPAT */


/*---------------------------------------------------------------------------*/
/*  Event Manager API function prototypes - Version 2                        */
/*---------------------------------------------------------------------------*/

/*
 *  Function prototypes for functions intended for Event Manager API clients.
 *  Clients should use the generic routine names defined by macros included
 *  in this header file, such as ha_em_start_session(), instead of the version
 *  specific routine names, like ha_em_start_session_2().  Those macros 
 *  convert the generic names to the appropriate version specific names.
 */

#if ((HA_EM_VERSION == 2) || defined(HA_EM_ALL_VERSIONS)) && !defined(_NO_PROTO)

extern int ha_em_start_session_2(		/* Start an Event Manager session    */
	int em_domain_type,					/* input:  session domain type       */
	char *em_domain_name,				/* input:  session domain name       */
	struct ha_em_err_blk *em_errb		/* output: error description block   */
);										/* return: session ID or -1 (error)  */

extern int ha_em_restart_session_2(		/* Restart an Event Manager session  */
	int em_session_fd,					/* input:  old session ID            */
	struct ha_em_err_blk *em_errb		/* output: error description block   */
);										/* return: new ID or -1 (error)      */

extern int ha_em_end_session_2(			/* End an Event Manager session      */
	int em_session_fd,					/* input:  Event Manager session ID  */
	struct ha_em_err_blk *em_errb		/* output: error description block   */
);										/* return: 0 or -1 (error)           */

extern int ha_em_send_command_2(		/* Send an Event Manager command     */
	int em_session_fd,					/* input:  Event Manager session ID  */
	struct ha_em_cmd_blk *em_cmdb,		/* input/output: Command block       */
	struct ha_em_err_blk *em_errb		/* output: error description block   */
);										/* return: 0 or -1 (error)           */

extern int ha_em_receive_response_2(	/* Receive an Event Manager response */
	int em_session_fd,					/* input:  Event Manager session ID  */
	struct ha_em_rsp_blk **em_rsp_blk,	/* output: pointer to response block */
	struct ha_em_err_blk *em_errb		/* output: error description block   */
);										/* return: number of responses       */
										/*         (may be 0), or -1 (error) */

extern ha_em_ecgid_t ha_em_get_ecgid_2(	/* Get event command group identifier*/
	ha_em_eid_t em_eid					/* input:  event identifier          */
);										/* return: event command group ID    */

#endif

#if ((HA_EM_VERSION == 2) || defined(HA_EM_ALL_VERSIONS)) && defined(_NO_PROTO)
extern int ha_em_start_session_2();		/* Start an Event Manager session    */
extern int ha_em_restart_session_2();	/* Restart an Event Manager session  */
extern int ha_em_end_session_2();		/* End an Event Manager session      */
extern int ha_em_send_command_2();		/* Send an Event Manager command     */
extern int ha_em_receive_response_2();	/* Receive an Event Manager response */
extern ha_em_ecgid_t ha_em_get_ecgid_2();  /* Get event command group ID     */
#endif


/*---------------------------------------------------------------------------*/
/*  Event Manager API function prototypes - Version 1                        */
/*---------------------------------------------------------------------------*/

/*
 *  Function prototypes for functions intended for Event Manager API clients.
 *  Clients should use the generic routine names defined by macros included
 *  in this header file, such as ha_em_start_session(), instead of the version
 *  specific routine names, like ha_em_start_session_1().  Those macros 
 *  convert the generic names to the appropriate version specific names.
 */

#if ((HA_EM_VERSION == 1) || defined(HA_EM_ALL_VERSIONS)) && !defined(_NO_PROTO)

extern int ha_em_start_session_1(		/* Start an Event Manager session    */
	char *em_part_name,					/* input:  SP partition of session   */
	struct ha_em_err_blk *em_errb		/* output: error description block   */
);										/* return: session ID or -1 (error)  */

extern int ha_em_restart_session_1(		/* Restart an Event Manager session  */
	int em_session_fd,					/* input:  old session ID            */
	struct ha_em_err_blk *em_errb		/* output: error description block   */
);										/* return: new ID or -1 (error)      */

extern int ha_em_end_session_1(			/* End an Event Manager session      */
	int em_session_fd,					/* input:  Event Manager session ID  */
	struct ha_em_err_blk *em_errb		/* output: error description block   */
);										/* return: 0 or -1 (error)           */

extern int ha_em_send_command_1(		/* Send an Event Manager command     */
	int em_session_fd,					/* input:  Event Manager session ID  */
	struct ha_em_cmd_blk *em_cmdb,		/* input/output: Command block       */
	struct ha_em_err_blk *em_errb		/* output: error description block   */
);										/* return: 0 or -1 (error)           */

extern int ha_em_receive_response_1(	/* Receive an Event Manager response */
	int em_session_fd,					/* input:  Event Manager session ID  */
	struct ha_em_rsp_blk **em_rsp_blk,	/* output: pointer to response block */
	struct ha_em_err_blk *em_errb		/* output: error description block   */
);										/* return: number of responses       */
										/*         (may be 0), or -1 (error) */

extern ha_em_ecgid_t ha_em_get_ecgid_1(	/* Get event command group identifier*/
	ha_em_eid_t em_eid					/* input:  event identifier          */
);										/* return: event command group ID    */

#endif

#if ((HA_EM_VERSION == 1) || defined(HA_EM_ALL_VERSIONS)) && defined(_NO_PROTO)
extern int ha_em_start_session_1();		/* Start an Event Manager session    */
extern int ha_em_restart_session_1();	/* Restart an Event Manager session  */
extern int ha_em_end_session_1();		/* End an Event Manager session      */
extern int ha_em_send_command_1();		/* Send an Event Manager command     */
extern int ha_em_receive_response_1();	/* Receive an Event Manager response */
extern ha_em_ecgid_t ha_em_get_ecgid_1();  /* Get event command group ID     */
#endif


#ifdef __cplusplus
}
#endif /* __cplusplus */


#endif  /* _HA_EMAPI_H */