/* <dtidef.h>
 *
 *	DTI flag definitions
 */
#ifndef _DTIDEF_H
#define _DTIDEF_H

/* Item list definitions */
#define DTI$_ENDITEM		0	/* end of item list code */
#define DTI$_TRANSACTION_INFORMATION 1	/* active transaction list */
#define DTI$_CURRENT_TID	2	/* current transaction identifier */
#define DTI$_MEMBERSHIP_COUNT	3	/* # members still in transaction */
#define DTI$_BRANCH_COUNT	4	/* # branches still in transaction */
#define DTI$_ROOT_NODE_NAME	5	/* root node */
#define DTI$_STARTING_TIME	6	/* transaction start time */
#define dti$K_MAX_ITEM_CODE	6
/* Transaction states */
#define DTI$K_NULL		0
#define DTI$K_STARTING		1	/* starting state */
#define DTI$K_ACTIVE		2	/* active state */
#define DTI$K_ONE_P_COMMITTING	3	/* committing (one-phase) */
#define DTI$K_PREPARING		4	/* preparing state */
#define DTI$K_PREPARED		5	/* prepared state */
#define DTI$K_COMMITTING	6	/* committing state */
#define DTI$K_COMMITTED		7	/* committed state */
#define DTI$K_ONE_P_COMMITTED	8	/* committed (one-phase) */
#define DTI$K_ABORTING		9	/* aborting state */
#define DTI$K_ABORTED		10	/* aborted or forgotten state */
/* SET item codes */
#define DTI$K_ILLEGAL		0	/* make code 0 illegal */
#define DTI$K_DELETE_TRANSACTION 1	/* delete transaction */
#define DTI$K_DELETE_RM_NAME	2	/* delete resource manager */
#define DTI$K_MODIFY_STATE	3	/* modify transaction state */
#define DTI$K_DELETE_BRANCH_NODE 4	/* delete branch node */
#define DTI$K_SET_CURRENT_TID	5	/* set the current transaction identifier */
#define DTI$K_MAX_SET_CODE	5
/* Search list codes */
#define DTI$V_SEARCH_STARTING	0
#define DTI$V_SEARCH_ACTIVE	1
#define DTI$V_SEARCH_1P_COMITTING 2
#define DTI$V_SEARCH_PREPARING	3
#define DTI$V_SEARCH_PREPARED	4
#define DTI$V_SEARCH_COMMITTING 5
#define DTI$V_SEARCH_COMMITTED	6
#define DTI$V_SEARCH_1P_COMMITTED 7
#define DTI$V_SEARCH_ABORTING	8
#define DTI$V_SEARCH_ABORTED	9
#define DTI$M_SEARCH_STARTING	(1<<DTI$V_SEARCH_STARTING)	/* 0x01 */
#define DTI$M_SEARCH_ACTIVE	(1<<DTI$V_SEARCH_ACTIVE)	/* 0x02 */
#define DTI$M_SEARCH_1P_COMITTING (1<<DTI$V_SEARCH_1P_COMITTING) /* 0x04 */
#define DTI$M_SEARCH_PREPARING	(1<<DTI$V_SEARCH_PREPARING)	/* 0x08 */
#define DTI$M_SEARCH_PREPARED	(1<<DTI$V_SEARCH_PREPARED)	/* 0x10 */
#define DTI$M_SEARCH_COMMITTING (1<<DTI$V_SEARCH_COMMITTING)	/* 0x20 */
#define DTI$M_SEARCH_COMMITTED	(1<<DTI$V_SEARCH_COMMITTED)	/* 0x40 */
#define DTI$M_SEARCH_1P_COMMITTED (1<<DTI$V_SEARCH_1P_COMMITTED) /* 0x80 */
#define DTI$M_SEARCH_ABORTING	(1<<DTI$V_SEARCH_ABORTING)	/* 0x0100 */
#define DTI$M_SEARCH_ABORTED	(1<<DTI$V_SEARCH_ABORTED)	/* 0x0200 */
/* Search item list definitions */
#define DTI$_ENDSEARCH		0	/* end of search list */
#define DTI$_SEARCH_AS_NODE	1	/* search as node */
#define DTI$_SEARCH_CURRENT_TID 2	/* search current transaction identifier */
#define DTI$_SEARCH_TID		3	/* search transaction identifier */
#define DTI$_SEARCH_RM_NAME	4	/* search resource manager */
#define DTI$_SEARCH_BRANCH_NAME 5	/* search branch node names */
#define DTI$_SEARCH_STATE	6	/* search state */
#define DTI$_SEARCH_RESOLVED_STATE 7	/* search resolved state */
#define DTI$K_MAX_SEARCH_CODE	7
struct dtisearchdef {
    unsigned dti$v_search_starting	: 1; /* starting state */
    unsigned dti$v_search_active	: 1; /* active state */
    unsigned dti$v_search_1p_comitting	: 1; /* 1P Committing state */
    unsigned dti$v_search_preparing	: 1; /* preparing state */
    unsigned dti$v_search_prepared	: 1; /* prepared state */
    unsigned dti$v_search_committing	: 1; /* committing state */
    unsigned dti$v_search_committed	: 1; /* committed state */
    unsigned dti$v_search_1p_committed	: 1; /* 1P Committed state */
    unsigned dti$v_search_aborting	: 1; /* aborting state */
    unsigned dti$v_search_aborted	: 1; /* aborted state */
    unsigned				: 6;
};
/* Transaction information record definitions */
#define DTI$V_UPDATE	0
#define DTI$V_LOCAL_RM	1
#define DTI$M_UPDATE	(1<<DTI$V_UPDATE)	/* 0x01 */
#define DTI$M_LOCAL_RM	(1<<DTI$V_LOCAL_RM)	/* 0x02 */
/* the following constant is wrong; the size is actually 84 bytes */
#define DTI$S_TRANSACTION_INFORMATION 82 /* length of transaction information record */
struct dtirecdef {
    union {
	unsigned short dti$w_flags;	/* modifier flags */
	struct {
	    unsigned dti$v_update  : 1; /* delete resource manager from transaction */
	    unsigned dti$v_local_rm: 1; /* participant type (1 = RM, 0 = node) */
	    unsigned		   : 6;
	    unsigned		   : 8; /* padding */
	} dti$r_flags_bits;
    } dti$r_flags_overlay;
    unsigned char dti$b_state;		/* transaction state */
    unsigned char dti$b_part_name_len;	/* length of participant name */
    char dti$t_part_name[32];		/* participant name */
    char dti$t_part_log_id[16];		/* participant log id */
    char dti$t_tid[16];			/* transaction ID */
    unsigned long dti$o_utc_commit_time[4]; /* UTC commit time */
};

#endif	/*_DTIDEF_H*/
