/* <kgbdef.h>
 *
 *	Key Grant Block definitions
 */
#ifndef _KGBDEF_H
#define _KGBDEF_H
/*
   Format of records in the rights database file.  These records (1)
   associate identifier codes with names, and (2) list the holders of
   all identifiers in the system.
 */
#define KGB$V_RESOURCE		0
#define KGB$V_DYNAMIC		1
#define KGB$V_NOACCESS		2
#define KGB$V_SUBSYSTEM		3
#define KGB$V_IMPERSONATE	4
#define KGB$V_HOLDER_HIDDEN	5
#define KGB$V_NAME_HIDDEN	6
#define KGB$M_RESOURCE		(1<<KGB$V_RESOURCE)	/* 0x01 */
#define KGB$M_DYNAMIC		(1<<KGB$V_DYNAMIC)	/* 0x02 */
#define KGB$M_NOACCESS		(1<<KGB$V_NOACCESS)	/* 0x04 */
#define KGB$M_SUBSYSTEM		(1<<KGB$V_SUBSYSTEM)	/* 0x08 */
#define KGB$M_IMPERSONATE	(1<<KGB$V_IMPERSONATE)	/* 0x10 */
#define KGB$M_HOLDER_HIDDEN	(1<<KGB$V_HOLDER_HIDDEN) /*0x20 */
#define KGB$M_NAME_HIDDEN	(1<<KGB$V_NAME_HIDDEN)	/* 0x40 */
#define KGB$K_HOLD_RECORD	16	/* end of holder record */
#define KGB$K_IDENT_RECORD	48	/* end of identifier record */
#define KGB$K_LEVEL1		257	/* version 1 structure level */
#define KGB$K_MAINT_RECORD	64	/* end of maintenance record */
#define KGB$K_NUMBER_OF_ATTRIBUTES 7
struct kgbdef {
    unsigned long kgb$l_identifier;	/* binary identifier code */
    union {
	unsigned long kgb$l_attributes; /* attribute bit definitions */
	struct {
	    unsigned kgb$v_resource	: 1; /* resource may be charged to identifier */
	    unsigned kgb$v_dynamic	: 1; /* identifier may be enabled or disabled */
	    unsigned kgb$v_noaccess	: 1; /* identifier will not be used in protection checks */
	    unsigned kgb$v_subsystem	: 1; /* identifier denotes active protected subsystem */
	    unsigned kgb$v_impersonate	: 1; /* identifier can be used for impersonation */
	    unsigned kgb$v_holder_hidden: 1; /* holder records are restricted */
	    unsigned kgb$v_name_hidden	: 1; /* $IDTOASC or $ASCTOID translation is restricted */
	    unsigned			: 1;
	} kgb$r_attr_bits;
    } kgb$r_attr_overlay;
    unsigned int kgb$q_holder[2];	/* holder identifier */
    char kgb$t_name[32];		/* identifier name (blank filled string) */
    unsigned short kgb$w_level;		/* file structure level */
    unsigned	: 16;			/* short fill; */
    unsigned int kgb$q_sys_id[2];	/* system identifier */
    unsigned long kgb$l_next_id;	/* next available identifier */
};

/* Define the environmental rights ID values */
#define KGB$K_BATCH_ID		0x80000001LU	/* batch ID value */
#define KGB$K_DIALUP_ID		0x80000002LU	/* dialup ID value */
#define KGB$K_INTERACTIVE_ID	0x80000003LU	/* interactive ID value */
#define KGB$K_LOCAL_ID		0x80000004LU	/* local ID value */
#define KGB$K_NETWORK_ID	0x80000005LU	/* network ID value */
#define KGB$K_REMOTE_ID		0x80000006LU	/* remote ID value */
#define KGB$K_DECWINDOWS_ID	0x80000007LU	/* DECwindows ID value */
#define KGB$K_LAST_ENV_ID	0x80000008LU

/* Define the range of environmental identifiers. */
#define KGB$K_BASE_ENV_ID	0x80000001LU
#define KGB$K_NUMBER_OF_ENV_IDS 7

/* Define the restricted range of system identifiers as lowest id
   (%x800000000) to %x80010000. */
#define KGB$K_RESTRICTED_RANGE	0x80010000LU

/* Define the various access class ranges. */
#define KGB$K_SEC_LEVEL_BASE		0x800003E8LU
#define KGB$K_INT_LEVEL_BASE		0x800004E8LU
#define KGB$K_SEC_CATEGORY_BASE		0x800005E8LU
#define KGB$K_INT_CATEGORY_BASE		0x80000628LU
#define KGB$K_SEC_ACCESS_CLASS_BASE	0x800003E8LU
#define KGB$K_SEC_ACCESS_CLASS_END	0x80000668LU

/* Define the values for the optional $GRANTID/$REVOKID FLAGS argument. */
#define KGB$K_PROCESS	0	/* local rights */
#define KGB$K_SYSTEM	1	/* system rights */
#define KGB$K_EXTENDED	2	/* local rights (extended) */
#define KGB$K_IMAGE	3	/* image (protected subsystem) rights */
#define KGB$K_MAX_SEG	4
#define KGB$K_SUBSYSTEM 3	/* image (protected subsystem) rights */

#endif	/*_KGBDEF_H*/