fsuti_h

/* FSHR_ERRORS
*	Defines parameters for the error codes returned by the File Sharing
*	UTI routines for internal (to the user process) errors.
*/

#define	FSHR__SUCCESS	0			/* Unconditional success */
#define	FSHR__PENDING	2			/* Operation pending */
#define	FSHR__NOBUF	((2*256) | 2)		/* No work area (warning) */
#define	FSHR__NOWKBUF	((-1*256) | 2)		/* No work area specified */
#define	FSHR__FSBUSY	((-2*256) | 2)		/* Operation already active */
#define	FSHR__WKLEN	((-3*256) | 2)		/* Work area too short */
#define FSHR__BUFALL	((-4*256) | 2)		/* Work area already allocated */
#define	FSHR__MXLIM	((-5*256) | 2)		/* Record size too large */
#define FSHR__TMO	((-6*256) | 2)		/* Network timeout */
#define FSHR__USRLCK	((-7*256) | 2)		/* user filesharing write lock */
#define FSHR__NOPRIV	((-8*256) | 2)		/* cns class no priv for write */
/* this errorcode matches one owned by fshare.exe */
#define	FSHR__NOFILE	((-109*256) | 2)	/* file not found */

#define yes 1
#define no 0

/* FSHR_DEFINE
*	Module $FSHR_DEFINE of text library VAX$AP_LIB:FORVAXAPL.
*	Defines parameters for the File Sharing UTI routines.
*	These include the offsets into the user-specified work area and ...
*/

#define	FSHR_K_BUFID	'FS'		/* Work area check word value */
#define FSHR_K_HDRLEN	12		/* Reply header length in words */
#define FSHR_K_MAXBYT	8140		/* Maximum record size (in bytes) */
#define FSHR_K_DEFTMO	10		/* Default timeout value */
#define	SECONDS		10*1000*1000	/* System tick units in 1 second */


#define	FSHR_M_NOLOCK	0x0001		/* NoLock flag from FSREAD */
#define	FSHR_M_NOMOD	0x0001		/* NoMod flag from FSWRIT */

#define	FSHR_K_TC_RD		1	/* Read record type code */
#define	FSHR_K_TC_WRT		2	/* Write record type code */
#define	FSHR_K_TC_OPN		3	/* Open file type code */
#define	FSHR_K_TC_CLS		4	/* Close file type code */
#define	FSHR_K_TC_CAT		5	/* Close all files for task type code */
#define FSHR_K_TC_CAN		6	/* Close all files for node type code */
#define FSHR_K_TC_WEF		7	/* Write EOF type code */
#define	FSHR_K_TC_REW		8	/* Rewind file type code */
#define FSHR_K_TC_ULK		9	/* Unlock record type code */
#define	FSHR_K_TC_RDM		10	/* Read multiple records type code */
#define	FSHR_K_TC_DEL		11	/* Delete record type code */
#define	FSHR_K_TC_INFO		17	/* Get file info */
#define	FSHR_K_TC_ACTIVE_USERS	96	/* return information about all active users */
#define	FSHR_K_TC_OPEN_FILES	97	/* return information about all open files */
#define	FSHR_K_TC_HEARTBEAT	98	/* heartbeat request */
#define	FSHR_K_TC_DUMP		99	/* request dump to file of user and file information */

#define	NIL 0				/* Empty pointer value */

/* FSHR___COMMON
C Module FSHR___COMMON of text library VAX$AP_LIB:FORVAXAPL.
C Defines the internal common used by the VAX File Sharing UTI routines.
*/

struct EXIT_BLOCK
    {
    int		flink;
    void	(*hand_ptr)();
    int		arg_count;
    int		*arg1_ptr;
    } __attribute__((packed)) /* Added by the PACKINATOR(tm) */;

struct FSHRCOMMON
    {
    int		ptr_pastend;		/* Pointer past end of work area */
    short	*ptr_iostat;		/* Pointer to return I/O status */
    int		*ptr_extstat;		/* Pointer to return extended status */
    short	*ptr_iobuf;		/* Pointer to record buffer */
    short	*ptr_bytcnt;		/* Pointer to return byte count */
    int		name_of_task;		/* Network task name */
    int		fshare_task;		/* Network task name of FSHARE */
    short	fshare_node;		/* Logical node number of FSHARE */
    unsigned short	current_reqid;	/* Current network request id */
    void	(*ptr_astfunc)();	/* pointer to user AST level function */
    } __attribute__((packed)) /* Added by the PACKINATOR(tm) */;

struct WORKBUFFER
    {
    short	fshr_w_fsid;			/* work area check word */
    short	fshr_w_size;			/* work area size word */
    short	fshr_w_efn;			/* work area event flag word */
/* === begin net packet === */
    short	fshr_w_tc;		/* 2 */	/* typecode word */
    short	fshr_w_acst;		/* 2 */	/* ACNET status return word */
    int		fshr_l_exst;		/* 4 */	/* exteneded status return */
    short	fshr_w_vun;		/* 2 */	/* virtual unit number */
    short	fshr_w_mxby;		/* 2 */	/* user's byte count */
    short	fshr_w_rtby;		/* 2 */	/* returned byte count */
    int		fshr_l_recn;		/* 4 */	/* record number */
    int 	fshr_l_tnam;		/* 4 */	/* network task name */
    short	fshr_w_flags;		/* 2 */	/* FSHARE flags */
			/* HEADER TOTAL = 24 */
#define FSHR_K_MAXDATA   (FSHR_K_MAXBYT - 24)
    short	fshr_w_data[FSHR_K_MAXDATA/2];	/* data area */
/* === end net packet === */
    } __attribute__((packed)) /* Added by the PACKINATOR(tm) */;

typedef struct FS_REQUEST_BUFFER
    {
    unsigned short	type_code;
    unsigned short	acnet_status;
    unsigned int	extended_status;
    unsigned short	vun;
    unsigned short	max_bytes;
    unsigned short	returned_bytes;
    unsigned int	record_number;
    unsigned int	task_name;
    unsigned short	flags;
    } FS_REQUEST_BUFFER;

#define	FS_FILE_INFO_NAME_LEN	64
#define	FS_INFO_MAX_FILES	85

typedef struct FS_FILE_INFO_ENTRY		/* returned information about a Filesharing file */
    {
    char	file_name[FS_FILE_INFO_NAME_LEN];
    unsigned int	rad50_task;
    unsigned short	node;
    unsigned short	type;
    unsigned short	last_status;
    unsigned short	num_opens;
    unsigned short	num_open_errors;
    unsigned short	num_close_errors;
    unsigned int	num_reads;
    unsigned int	num_read_errors;
    unsigned int	num_writes;
    unsigned int	num_write_errors;
    unsigned int	file_entry_id;
    } FS_FILE_INFO_ENTRY;

typedef struct FS_OPEN_FILES_REPLY		/* returned list of a all open Filesharing files */
    {
    unsigned short	type_code;
    unsigned short	acnet_status;
    int		num_files;
    int		num_remaining_files;
    int		start_index;
    FS_FILE_INFO_ENTRY	file_entries[1];
    } FS_OPEN_FILES_REPLY;

typedef struct FS_FILE_INFO_DATA		/* returned information about a Filesharing file */
    {
    char	file_name[FS_FILE_INFO_NAME_LEN+2];
    char	task_name[PROCESS_NAME_LEN];
    unsigned short	node;
    unsigned short	type;
    unsigned short	last_status;
    unsigned short	num_opens;
    unsigned short	num_open_errors;
    unsigned short	num_close_errors;
    unsigned int	num_reads;
    unsigned int	num_read_errors;
    unsigned int	num_writes;
    unsigned int	num_write_errors;
    unsigned int	file_entry_id;
    } FS_FILE_INFO_DATA;

#define	FS_INFO_MAX_USERS	300

typedef struct FS_ACTIVE_USER_ENTRY		/* returned information about an active Filesharing user */
    {
    unsigned int	rad50_task;
    unsigned short	node;
    unsigned short	console;
    unsigned short	vun;
    int		lun;
    unsigned short	activity;
    unsigned int	file_entry_id;
    } FS_ACTIVE_USER_ENTRY;

typedef struct FS_ACTIVE_USERS_REPLY		/* returned list of a all active Filesharing users */
    {
    unsigned short	type_code;
    unsigned short	acnet_status;
    int		num_users;
    int		num_remaining_users;
    int		start_index;
    FS_ACTIVE_USER_ENTRY	user_entries[1];
    } FS_ACTIVE_USERS_REPLY;

typedef struct FS_ACTIVE_USER_DATA		/* returned information about an active Filesharing user */
    {
    char	task_name[PROCESS_NAME_LEN];
    unsigned short	node;
    unsigned short	console;
    unsigned short	vun;
    int		lun;
    unsigned short	activity;
    unsigned int	file_entry_id;
    } FS_ACTIVE_USER_DATA;

#define	FS_ORDER_BY_NONE	0
#define	FS_ORDER_BY_NAME	1
#define	FS_ORDER_BY_TASK	2

int fs_get_active_user_info_c(int *num_users, FS_ACTIVE_USER_DATA **user_info,
			      int order_type=FS_ORDER_BY_NONE);
int fs_get_open_file_info_c(int *num_files, FS_FILE_INFO_DATA **file_info,
			    int order_type=FS_ORDER_BY_NONE);