/* <vms/lib/uafdef.h>
 *
 *	LIB - user authorization file format		[not in Starlet]
 */
#ifndef _UAFDEF_H
#define _UAFDEF_H

/*
   User authorization file format

   Note:  With the exception of the username and account name,
   all strings are blank padded counted strings.  Username and
   account name are uncounted, blank padded.
 */
#define UAF$C_USER_ID		1	/* main user ID record */
#define UAF$C_VERSION1		1	/* this version */
#define UAF$C_KEYED_PART	52	/* ISAM keys come this far */
#define UAF$C_MAX_PWD_LENGTH	32	/* maximum plaintext password length */
#define UAF$K_MAX_PWD_LENGTH	32
/* known hash algorithm indices */
#define UAF$C_AD_II		0	/* AUTODIN-II 32 bit crc code */
#define UAF$C_PURDY		1	/* Purdy polynomial over salted input */
#define UAF$C_PURDY_V		2	/* Purdy polynomial + variable length username */
#define UAF$C_PURDY_S		3	/* PURDY_V folded into password length */
#ifndef NO_VMS_V6
#define UAF$C_CURRENT_ALGORITHM 3	/* current DEC algorithm number */
#define UAF$K_CURRENT_ALGORITHM 3
#define UAF$C_PREFERRED_ALGORITHM 127	/* preferred hash algorithm - use current */
#define UAF$K_PREFERRED_ALGORITHM 127
#define UAF$C_PREFERED_ALGORITHM UAF$C_PREFERRED_ALGORITHM
#define UAF$K_PREFERED_ALGORITHM UAF$K_PREFERRED_ALGORITHM
#else
#define UAF$C_PREFERED_ALGORITHM 3	/* prefered hash algorithm */
#define UAF$K_PREFERED_ALGORITHM 3
#endif
#define UAF$C_CUST_ALGORITHM	128	/* customer algorithm division */
#define UAF$K_CUST_ALGORITHM	128

#define UAF$S_USERNAME		32
#define UAF$S_PARENT_ID		8
#define UAF$S_ACCOUNT		32
#define UAF$S_OWNER		32
#define UAF$S_DEFDEV		32
#define UAF$S_DEFDIR		64
#define UAF$S_LGICMD		64
#define UAF$S_DEFCLI		32
#define UAF$S_CLITABLES		32
#define UAF$S_PWD		8
#define UAF$S_PWD2		8
#define UAF$S_EXPIRATION	8
#define UAF$S_PWD_LIFETIME	8
#define UAF$S_PWD_DATE		8
#define UAF$S_PWD2_DATE		8
#define UAF$S_LASTLOGIN_I	8
#define UAF$S_LASTLOGIN_N	8
#define UAF$S_PRIV		8
#define UAF$S_DEF_PRIV		8
#define UAF$S_MIN_CLASS		20
#define UAF$S_MAX_CLASS		20
#define UAF$S_NETWORK_ACCESS_P	3
#define UAF$S_NETWORK_ACCESS_S	3
#define UAF$S_BATCH_ACCESS_P	3
#define UAF$S_BATCH_ACCESS_S	3
#define UAF$S_LOCAL_ACCESS_P	3
#define UAF$S_LOCAL_ACCESS_S	3
#define UAF$S_DIALUP_ACCESS_P	3
#define UAF$S_DIALUP_ACCESS_S	3
#define UAF$S_REMOTE_ACCESS_P	3
#define UAF$S_REMOTE_ACCESS_S	3
#ifndef NO_VMS_V6
#define UAF$S_DEF_CLASS		20
#endif

#define UAF$K_FIXED		644	/* length of fixed portion */
#define UAF$C_FIXED		644
#define UAF$K_LENGTH		1412
#define UAF$C_LENGTH		1412
#define UAF$S_UAFDEF		1412
struct uafdef {
    unsigned char uaf$b_rtype;		/* UAF record type */
    unsigned char uaf$b_version;	/* UAF format version */
    unsigned short uaf$w_usrdatoff;	/* offset of counted string of user data */
    union {
	char uaf$t_username[32];		/* username */
	struct {
	    char uaf$t_username_base[31];
	    unsigned char uaf$t_username_tag;	/* tag to differentiate records */
	} uaf$r_username_fields;
    } uaf$r_username_overlay;
    union {
	unsigned long uaf$l_uic;		/* user ID code */
	struct {
	    unsigned short uaf$w_mem;		/* member subfield */
	    unsigned short uaf$w_grp;		/* group subfield */
	} uaf$r_uic_fields;
    } uaf$r_uic_overlay;
    unsigned long uaf$l_sub_id;		/* user sub-identifier */
    unsigned long uaf$q_parent_id[2];	/* identifier of owner of this account */
    char uaf$t_account[32];		/* account name */
    char uaf$t_owner[32];		/* owner's name */
    char uaf$t_defdev[32];		/* default device */
    char uaf$t_defdir[64];		/* default directory */
    char uaf$t_lgicmd[64];		/* login command file */
    char uaf$t_defcli[32];		/* default command interpreter */
    char uaf$t_clitables[32];		/* user CLI tables */
    union {
	unsigned long uaf$q_pwd[2];	    /* hashed password */
	unsigned long uaf$l_pwd;	    /* 32 bit subfield */
    } uaf$r_pwd;
    unsigned long uaf$q_pwd2[2];	/* second password */
    unsigned short uaf$w_logfails;	/* count of login failures */
    unsigned short uaf$w_salt;		/* random password salt */
    unsigned char uaf$b_encrypt;	/* primary password hash algorithm */
    unsigned char uaf$b_encrypt2;	/* secondary password hash algorithm */
    unsigned char uaf$b_pwd_length;	/* minimum password length */
    unsigned	: 8;			/* char fill; */
    long uaf$q_expiration[2];		/* expiration date for account */
    long uaf$q_pwd_lifetime[2];		/* password lifetime */
    long uaf$q_pwd_date[2];		/* date of password change */
    long uaf$q_pwd2_date[2];		/* date of 2nd password change */
    long uaf$q_lastlogin_i[2];		/* date of last interactive login */
    long uaf$q_lastlogin_n[2];		/* date of last non-interactive login */
    unsigned long uaf$q_priv[2];	/* process privilege vector */
    unsigned long uaf$q_def_priv[2];	/* default process privileges */
    struct {
	unsigned char uaf$b_min_class[20];	/* minimum security class */
    } uaf$r_min_class;
    struct {
	unsigned char uaf$b_max_class[20];	/* maximum security class */
    } uaf$r_max_class;
    union {
	unsigned long uaf$l_flags;	    /* user flags longword */
	struct {
	    unsigned uaf$v_disctly	: 1;	/* no user control-y */
	    unsigned uaf$v_defcli	: 1;	/* only allow user default CLI */
	    unsigned uaf$v_lockpwd	: 1;	/* disable SET PASSWORD command */
	    unsigned uaf$v_restricted	: 1;	/* restricted account (pre-V5.2 CAPTIVE) */
	    unsigned uaf$v_disacnt	: 1;	/* no interactive login */
	    unsigned uaf$v_diswelcom	: 1;	/* skip welcome message */
	    unsigned uaf$v_dismail	: 1;	/* skip new mail message */
	    unsigned uaf$v_nomail	: 1;	/* disable mail delivery */
	    unsigned uaf$v_genpwd	: 1;	/* passwords must be generated */
	    unsigned uaf$v_pwd_expired	: 1;	/* password has expired */
	    unsigned uaf$v_pwd2_expired : 1;	/* 2nd password has expired */
	    unsigned uaf$v_audit	: 1;	/* audit all actions */
	    unsigned uaf$v_disreport	: 1;	/* skip last login messages */
	    unsigned uaf$v_disreconnect : 1;	/* inhibit reconnections */
	    unsigned uaf$v_autologin	: 1;	/* auto-login only */
	    unsigned uaf$v_disforce_pwd_change : 1; /* disable forced password change */
	    unsigned uaf$v_captive	: 1;	/* captive account (no overrides) */
	    unsigned uaf$v_disimage	: 1;	/* disable arbitrary image activation */
	    unsigned uaf$v_dispwddic	: 1;	/* disable password dictionary search */
	    unsigned uaf$v_dispwdhis	: 1;	/* disable password history search */
#ifndef NO_VMS_V6
	    unsigned uaf$v_defclsval	: 1;	/* default classification is valid */
	    unsigned			: 11;	/* padding */
#else
	    unsigned			: 12;	/* padding */
#endif
	} uaf$r_flags_bits;
    } uaf$r_flags_overlay;
 /* note: the access hours are 24-bit wide fields, but not aligned in longwords */
    unsigned char uaf$b_network_access_p[3];	/* hourly network access, primary */
    unsigned char uaf$b_network_access_s[3];	/* hourly network access, secondary */
    unsigned char uaf$b_batch_access_p[3];	/* hourly batch access, primary */
    unsigned char uaf$b_batch_access_s[3];	/* hourly batch access, secondary */
    unsigned char uaf$b_local_access_p[3];	/* hourly local access, primary */
    unsigned char uaf$b_local_access_s[3];	/* hourly local access, secondary */
    unsigned char uaf$b_dialup_access_p[3];	/* hourly dialup access, primary */
    unsigned char uaf$b_dialup_access_s[3];	/* hourly dialup access, secondary */
    unsigned char uaf$b_remote_access_p[3];	/* hourly remote access, primary */
    unsigned char uaf$b_remote_access_s[3];	/* hourly remote access, secondary */
    char uafdef$$_fill_1[12];
    union {
	unsigned char uaf$b_primedays;	  /* bits representing primary days */
	struct {
	    unsigned uaf$v_monday    : 1; /* bit clear means this is a primary day */
	    unsigned uaf$v_tuesday   : 1; /* bit set means this is an off day */
	    unsigned uaf$v_wednesday : 1;
	    unsigned uaf$v_thursday  : 1;
	    unsigned uaf$v_friday    : 1;
	    unsigned uaf$v_saturday  : 1;
	    unsigned uaf$v_sunday    : 1;
	    unsigned		     : 1; /* padding */
	} uaf$r_primedays_bits;
    } uaf$r_primedays_overlay;
    unsigned	: 8;			/* char fill; */
    unsigned char uaf$b_pri;		/* base process priority */
    unsigned char uaf$b_quepri;		/* maximum job queuing priority */
    unsigned short uaf$w_maxjobs;	/* maximum jobs for UIC allowed; 0 means no limit */
    unsigned short uaf$w_maxacctjobs;	/* maximum jobs for account allowed; 0 means no limit */
    unsigned short uaf$w_maxdetach;	/* maximum detached processes for UIC; 0 means no limit */
    unsigned short uaf$w_prccnt;	/* subprocess creation limit */
    unsigned short uaf$w_biolm;		/* buffered I/O limit */
    unsigned short uaf$w_diolm;		/* direct I/O limit */
    unsigned short uaf$w_tqcnt;		/* timer queue entry limit */
    unsigned short uaf$w_astlm;		/* AST queue limit */
    unsigned short uaf$w_enqlm;		/* enqueue limit */
    unsigned short uaf$w_fillm;		/* open file limit */
    unsigned short uaf$w_shrfillm;	/* shared file limit */
    unsigned long uaf$l_wsquota;	/* working set size quota */
    unsigned long uaf$l_dfwscnt;	/* default working set size */
    unsigned long uaf$l_wsextent;	/* working set size limit */
    unsigned long uaf$l_pgflquota;	/* page file quota */
    unsigned long uaf$l_cputim;		/* CPU time quota */
    unsigned long uaf$l_bytlm;		/* buffered I/O byte count limit */
    unsigned long uaf$l_pbytlm;		/* paged buffer I/O byte count limit */
    unsigned long uaf$l_jtquota;	/* job-wide logical name table creation quota */
    unsigned short uaf$w_proxy_lim;	/* number of proxies user can grant */
    unsigned short uaf$w_proxies;	/* number of proxies granted */
    unsigned short uaf$w_account_lim;	/* number of sub-accounts allowed */
    unsigned short uaf$w_accounts;	/* number of sub-accounts in use */
#ifndef NO_VMS_V6
    unsigned char  uaf$r_def_class[20]; /* default security class */
    char uafdef$$_fill_2[44];
#else
    char uafdef$$_fill_2[64];
#endif
 /* end of fixed portion */
#ifdef UAFDEF_FULL_LENGTH
    char uafdef$$_fill_3[768];
#endif
};

#endif	/*_UAFDEF_H*/
