cns_data_structs_h

/*
**	Copyright 1991-2017, Fermi Research Alliance, LLC.  All rights reserved.
*/
/******************************************************************************/
/* cns_data_structs.h
**
**	General console application data structures
**
*/
/******************************************************************************/

#ifndef	CNS_DATA_STRUCTS_DEFINED		/* do this only once */
#define	CNS_DATA_STRUCTS_DEFINED

#include <string>
#include <time.h>
#include <vector>
#include "cnsparam.h"
#include "vaxtypes.h"
//#include "dbmsql.h"

#ifdef __cplusplus
/*
 * These classes are intended to help C/C++ source deal as cleanly as possible
 * with the fact that persistent binary data, e.g., from file sharing,
 * must be maintained with DEC floating point format during the transistion
 * to Linux.  There is a version for float and a version for double.
 * For each precision there are also two versions - one for all cases
 * where the type is not in a union and one for where the type is in a union.
 * For the non-union case, the type is totally to the best of my knowledge
 * 99% compatible with plain old float and double.  The 1% is because a cast
 * is needed in printf() to explicitly convert the DecFloating... into a
 * float or double.  For the union case, there is an additional caveat about the
 * case where the float or double is the first member of the union and the union
 * is initialized at its defintion.  In such cases an explict conversion of the
 * initializing value is required.  For example ..
 * this ...
 *     union example
 *         {
 *         float                                as_float;
 *         int                                  as_integer;
 *         };
 *     example a_example = {                              20.0 };
 * becomes ...
 *     union example
 *         {
 *         DecFloatingPointFormatFloatUnionSafe as_float;
 *         int                                  as_integer;
 *         };
 *     example a_example = { DecFloatingPointFormatFloat( 20.0 ) };
 * The compiler will generate an error if the type is changed but the
 * explicit conversion is not added as well.   All this UnionSafe
 * stuff is needed because union members are not allowed to have
 * constructors, but yet we need constructors to convert IEEE to DEC
 * for the initialization case.
 * 
 */
class DecFloatingPointFormatFloatUnionSafe
    {
    public:
        /* IEEE to DEC conversion - assignment */
        DecFloatingPointFormatFloatUnionSafe& operator=( float ieee_float );
        
        /* DEC to IEEE conversion */
        operator float();

    protected:
        int dec_float;
    } __attribute__((packed));

class DecFloatingPointFormatFloat : public DecFloatingPointFormatFloatUnionSafe
    {
    public:
        /* IEEE to DEC conversion - initialization */
        DecFloatingPointFormatFloat( float ieee_float );
        DecFloatingPointFormatFloat();
        
    } __attribute__((packed));

class DecFloatingPointFormatDoubleUnionSafe
    {
    public:
        /* IEEE to DEC conversion - assignment */
        DecFloatingPointFormatDoubleUnionSafe& operator=( double ieee_double );
        
        /* DEC to IEEE conversion */
        operator double();

    protected:
        int dec_double;
    } __attribute__((packed));

class DecFloatingPointFormatDouble : public DecFloatingPointFormatDoubleUnionSafe
    {
    public:
        /* IEEE to DEC conversion - initialization */
        DecFloatingPointFormatDouble( double ieee_double );
        DecFloatingPointFormatDouble();
        
    } __attribute__((packed));
    
#endif

typedef void (*void_function)();		/* void function pointer */

typedef int (*int_function)();			/* int function pointer */

typedef int (*int_function_int)(int);		/* int function pointer with an int argument */

typedef int (*int_function_voidp)(void *);	/* int function pointer with a void pointer argument */

typedef int (*int_function_charp_charp)(char *, char *);	/* int function pointer with two char pointer arguments */

typedef int (*compare_function)(const void *value_1, const void *value_2);	/* compare function pointer */

typedef void (*signal_function)(int sig);	/* signal function pointer */

typedef void *(*pthread_function)(void *);	/* pthread function pointer */

#define	TOD_STRING_LEN		8		/* length of a standard Time Of Day string */
#define	TOD_STRING_LEN_NO_SECONDS	5	/* length of a standard Time Of Day string without seconds */

#define	DATESTRING_LEN		20		/* length of a standard date string */
#define	DATE_STRING_LEN		20		/* length of a standard date string */

typedef vmstime VMS_TIME;			/* VMS time structure */

typedef unsigned int clinks_t;

/* Note!!!!!!!!!!!!!!!!
	This same structure is also defined in the file ul_cnscom/ul_cnscom_all.h.  If this
	structure is changed, it should be changed in both files.
*/

#ifndef XCHAR_DEFINED

#define	XCHAR_DEFINED

typedef struct XCHAR				/* TVMX character/color format */
    {
    char	ch;				/* (ASCII) character */
    /* The values to be used for xcolor are #defines in cnsparam.h */
    char	xcolor;				/* color/blink codes */
    } __attribute__((packed)) XCHAR;

#endif

typedef struct TIMESTAMP_DATA			/* timestamp */
    {
    time_t	seconds;			/* seconds since epoch */
    unsigned int	nanoseconds;		/* nanoseconds since most recent second */
    } __attribute__((packed)) TIMESTAMP_DATA;

/*
 AST defines the network request AST structure.
*/
struct AST {
	unsigned short	ast_w_rqreplyid;	/* reply id */
	unsigned short	ast_w_rqreqlen;		/* request length (words) */
	unsigned int	ast_l_reqadr;		/* request address */
	unsigned char	ast_b_reqsts;		/* request status */
	unsigned char	ast_b_rqflgs;		/* request flags */
	unsigned short	ast_w_thistsk;		/* node and task id of me */
	unsigned short	ast_w_rqreqid;		/* request id */
	unsigned char	ast_b_rqnode;		/* logical node of requestor */
	unsigned char	ast_b_rqtskid;		/* task id of requestor */
	unsigned short	ast_w_unused1;		/* unused */
	unsigned short	ast_w_unused2;		/* unused */
	} __attribute__((packed));

/*
 NTW defines the network control structures.
*/
struct NTW {
	unsigned short	ntw_w_rqreplyid;	/* reply id */
	unsigned short	ntw_w_rqreqid;		/* request id */
	unsigned short	ntw_w_rqreqlen;		/* request length (words) */
	unsigned char	ntw_b_rqtskid;		/* taskid of requestor */
	unsigned char	ntw_b_rqnode;		/* logical node of requestor */
	unsigned char	ntw_b_rqflgs;		/* request flags */
	unsigned char	ntw_b_newreq;		/* new request flag when .TRUE. */
	unsigned char	ntw_b_canreq;		/* cancel flag when .TRUE. */
	unsigned char	ntw_b_mltreq;		/* mult reply request when .TRUE. */
	unsigned char	ntw_b_usmreq;		/* USM when .TRUE. */
	unsigned char	ntw_b_rtlreq;		/* request too int when .TRUE. */
	} __attribute__((packed));

/*
  Define network reply AST block.
*/
struct RAST {
	unsigned short	rast_w_reqid;		/* request id */
	unsigned short	rast_w_rpylen;		/* reply length (words) */
	char	*rast_l_rpyadr;		/* reply address */
	char	rast_b_rpysts;		/* reply status */
	char	rast_b_rpyflgs;		/* reply flags */
	short	rast_w_rpysts;		/* new ACNET word status */
	} __attribute__((packed));

/*
 SNR defines a simple network request or reply.
*/
struct SNR {
	short	snr_w_tc_or_status;	/* request typecode or status return */
	int 	snr_l_req_or_rpy1;	/* additional request or reply */
	int 	snr_l_req_or_rpy2;	/* additional request or reply */
	} __attribute__((packed));

typedef struct ACNET_ERR			/* ACNET error format */
    {
    char	facility;			/* facility number */
    char	error_num;			/* specific error number */
    } __attribute__((packed)) ACNET_ERR;

typedef struct ARRAY_DEVICE_DATA		/* array device */
    {
    int		device_index;			/* device index */
    short	property;			/* property index */
    unsigned int	array_index;		/* array index */
    } __attribute__((packed)) ARRAY_DEVICE_DATA;

typedef struct ARRAY_DEVICE_DATA_EXT		/* extended array device */
    {
    int		device_index;			/* device index */
    short	property;			/* property index */
    unsigned int	array_index;		/* array index */
    unsigned int	num_elements;		/* number of elements */
    } __attribute__((packed)) ARRAY_DEVICE_DATA_EXT;

typedef struct DRF_DEVICE_DATA			/* DRF device data */
    {
    int		device_index;			/* device index */
    short	property;			/* property index */
    unsigned int	array_index;		/* array index */
    unsigned int	num_elements;		/* number of elements */
    int		scaling_type;			/* scaling type */
    int		property_field;			/* property field (DIO_FIELD_xxx) */
    } __attribute__((packed)) DRF_DEVICE_DATA;

typedef struct DRF_DEVICE_DATA_RAW		/* DRF device data (raw) */
    {
    int		device_index;			/* device index */
    short	property;			/* property index */
    unsigned int	offset;			/* offset in bytes */
    unsigned int	length;			/* length in bytes */
    int		scaling_type;			/* scaling type */
    int		property_field;			/* property field (DIO_FIELD_xxx) */
    } __attribute__((packed)) DRF_DEVICE_DATA_RAW;

typedef struct ACNET_DEVICE_VALUE		/* device value */
    {
    int		device_index;			/* device index */
    short	property;			/* property index */
    float	value;				/* device value */
    } ACNET_DEVICE_VALUE;

typedef struct DBAREQ_INFO			/* DBAREQ info structure */
    {
    unsigned short	deflt_len;		/* data default length */
    unsigned short	max_len;		/* max data length */
    unsigned short	node;			/* source node */
    short	ssdn[4];			/* subsystem device # */
    short	ftd;				/* default frequency time descriptor */
    int		pro_mask;			/* console protection mask */
    } __attribute__((packed)) DBAREQ_INFO;

typedef struct DBAREQ32_INFO			/* DBAREQ32 info structure */
    {
    unsigned short	default_length;		/* data default length */
    unsigned int	atomic_length;		/* atomic length */
    unsigned int	maximum_length;		/* maximum data length */
    unsigned short	node;			/* source node */
    char	ssdn[LEN_SSDN];			/* subsystem device # */
    unsigned short	default_ftd;		/* default frequency time descriptor */
    unsigned int	setting_mask;		/* console protection mask */
    } __attribute__((packed)) DBAREQ32_INFO;

#define	FTP_NO_OPERATION	0		/* no arithmetic operation requested */
#define	FTP_ADD_OPERATION	1		/* arithmetic add operation requested */
#define	FTP_SUBTRACT_OPERATION	2		/* arithmetic subtract operation requested */
#define	FTP_MULTIPLY_OPERATION	3		/* arithmetic multiply operation requested */
#define	FTP_DIVIDE_OPERATION	4		/* arithmetic divide operation requested */

typedef struct FTP_DEVICE_DATA
    {
    int		device_index;			/* device index */
    short	property;			/* property index */
    unsigned int	array_index;		/* array index */
    int		operation;			/* arithmetic expression operation */
    float	minimum_value;
    float	maximum_value;
    } __attribute__((packed)) FTP_DEVICE_DATA;

//#define	FTP_DEVICE_NAME_LEN	(DEVICE_TERSE_NAME_LEN + 6)	/* length of an FTP device name */

typedef struct FTP_DEVICE_NAME_DATA
    {
    char	device_name[FTP_DEVICE_NAME_LEN];	/* device name */
    int		operation;			/* arithmetic expression operation */
    float	minimum_value;
    float	maximum_value;
    } __attribute__((packed)) FTP_DEVICE_NAME_DATA;

#define	FTP_MAX_Y_DEVICES	4		/* maximum number of Y axis devices */
#define	FTP_TIME_PLOT		0		/* indicator for having X axis represent time */
#define	FTP_MAX_RESET_EVENTS	8		/* maximum number of plot reset events */
#define	FTP_FREQ_AUTO		1		/* automatic plot frequency selection */
#define	FTP_FREQ_1HZ		2
#define	FTP_FREQ_15HZ		3
#define	FTP_FREQ_50HZ		4
#define	FTP_FREQ_100HZ		5
#define	FTP_FREQ_200HZ		6
#define	FTP_FREQ_360HZ		7
#define	FTP_FREQ_720HZ		8
#define	FTP_FREQ_1440HZ		9
#define	FTP_FREQ_EVENT		10
#define	FTP_PLOT_ONCE		1
#define	FTP_PLOT_SCROLLING	5
#define	FTP_REPEAT_SUPERCYCLE	2
#define	FTP_REPEAT_MI_CYCLE	3
#define	FTP_REPEAT_TEV_CYCLE	4
#define	FTP_REPEAT_RR_CYCLE	4
#define	FTP_REPEAT_SELECTED_MI	7
#define	FTP_REPEAT_SELECTED_TEV	8
#define	FTP_REPEAT_SELECTED_RR	8
#define	FTP_REPEAT_EVENT	6
#define	FTP_SCALING_COMMON	1
#define	FTP_SCALING_PRIMARY	2
#define	FTP_SCALING_LOG		3
#define	FTP_OPT_NONE		0
#define	FTP_OPT_BY_FILE_NAME	0
#define	FTP_OPT_BY_FILE_NUMBER	1
#define	FTP_OPT_CONNECT_POINTS	1
#define	FTP_OPT_PLOT_CHARACTERS	2
#define	FTP_OPT_BLINK_NEW_DATA	4
#define	FTP_OPT_NO_ERASE	0x1000
#define	FTP_OPT_X_SETTING	0x2000

typedef struct FTP_OPTION_DATA
    {
    unsigned int	options;
    int		time_base_2_start;
    float	time_base_2_minimum;
    float	time_base_2_maximum;
    } __attribute__((packed)) FTP_OPTION_DATA;

typedef struct FTP_PLOT_DATA
    {
    FTP_DEVICE_DATA	x_device;		/* X axis device */
    FTP_DEVICE_DATA	y_devices[FTP_MAX_Y_DEVICES];
    int		frequency_code;
    int		acquisition_event;		/* data acquisition clock event (FTP_FREQ_EVENT) */
    int		time_base;
    int		reset_events[FTP_MAX_RESET_EVENTS];	/* reset event or selected MI cycle events */
    int		plot_scaling;
    FTP_OPTION_DATA	option_data;
    } __attribute__((packed)) FTP_PLOT_DATA;

#define	FTP_ID_LEN		8		/* length of FTP structure identifier message */
#define	FTP_NUM_ROWS		3		/* number of rows in FTP plot structure */
#define	FTP_NUM_DISPLAY_ROWS	3		/* number of rows in FTP plot interface */
#define	FTP_TEXT_LEN		60		/* number of characters per line in FTP plot structure */
#define	FTP_DISPLAY_TEXT_LEN	60		/* number of characters per line in FTP plot interface */
#define	FTP_TIME_BASE_LEN	6		/* length of secondary time base text */

typedef struct FTP_INFO				/* fast time plot setup data - this structure's contents will change over time */
    {
    char	identifier[FTP_ID_LEN];		/* structure identifier string */
    XCHAR	text[FTP_NUM_ROWS][FTP_TEXT_LEN];	/* FTP window text */
    char	t2_initial[FTP_TIME_BASE_LEN];	/* secondary time base initial time */
    char	t2_final[FTP_TIME_BASE_LEN];	/* secondary time base final time */
    unsigned short	selected_event_masks[2];	/* Main Injector and Tevatron selected event masks */
    } __attribute__((packed)) FTP_INFO;

#define	FTP_NUM_ROWS_2		9		/* number of rows in FTP plot structure (version 2) */
#define	FTP_NUM_DISPLAY_ROWS_2	6		/* number of rows in FTP plot interface (version 2) */
#define	FTP_DISPLAY_TEXT_LEN_2	58		/* number of characters per line in FTP plot interface (version 2) */
#define	FTP_ENTRY_TEXT_LEN_2	44		/* number of characters per line in FTP plot save file (version 2) */

typedef struct FTP_INFO_2			/* fast time plot setup data (version 2) */
    {
    char	identifier[FTP_ID_LEN];		/* structure identifier string */
    XCHAR	text[FTP_NUM_ROWS_2][FTP_TEXT_LEN];	/* FTP window text */
    char	t2_initial[FTP_TIME_BASE_LEN];	/* secondary time base initial time */
    char	t2_final[FTP_TIME_BASE_LEN];	/* secondary time base final time */
    unsigned short	selected_event_masks[2];	/* Main Injector and Tevatron selected event masks */
    } __attribute__((packed)) FTP_INFO_2;

typedef struct FTP_POINT			/* Fast Time Plot point data */
    {
    float	x_value;
    float	y_value;
    } __attribute__((packed)) FTP_POINT;

#define	FTP_FILE_SYSTEM_NAME_LEN	80
#define	FTP_FILE_NAME_LEN		80
#define	FTP_FILE_DEVICE_TEXT_LEN	80

typedef struct FTP_FILE_INFO
    {
    char	system_name[FTP_FILE_SYSTEM_NAME_LEN+2];
    int		file_number;
    char	file_name[FTP_FILE_NAME_LEN+2];
    char	device_text[FTP_FILE_DEVICE_TEXT_LEN+2];
    unsigned int	modify_date;
    } __attribute__((packed)) FTP_FILE_INFO;

#define	SNP_NO_OPERATION	0		/* no arithmetic operation requested */

#define	SNP_TIME_PLOT		0		/* indicator for having X axis represent time */

typedef struct SNP_DEVICE_DATA
    {
    int		device_index;			/* device index */
    short	property;			/* property index */
    unsigned int	array_index;		/* array index (unused) */
    int		operation;			/* arithmetic expression operation (unused) */
    float	minimum_value;
    float	maximum_value;
    } __attribute__((packed)) SNP_DEVICE_DATA;

#define	SNP_MAX_Y_DEVICES	4		/* maximum number of Y axis devices */
#define	SNP_MAX_ARM_EVENTS	8		/* maximum number of plot arm events */
#define	SNP_AUTO_FREQUENCY	0.0		/* automatic plot frequency selection */
#define	SNP_FREQ_AUTO		1		/* automatic plot frequency selection */
#define	SNP_FREQ_EXPLICIT	2		/* user specified sample rate */
#define	SNP_ARM_SUPERCYCLE	1		/* Supercycle arm reference */
#define	SNP_ARM_MI_CYCLE	2		/* Main Injector arm reference */
#define	SNP_ARM_TEV_CYCLE	3		/* Tevatron arm reference */
#define	SNP_ARM_RR_CYCLE	3		/* Recycler arm reference */
#define	SNP_ARM_BOOSTER_CYCLE	4		/* Booster arm reference */
#define	SNP_ARM_EVENT		5		/* clock event arm reference */
#define	SNP_ARM_EXTERNAL	6		/* external arm reference */
#define	SNP_MODE_PLOT_ONCE	1		/* once mode */
#define	SNP_MODE_PLOT_MULT	2		/* multiple plot mode */
#define	SNP_MODE_VIEW		3		/* view mode */
#define	SNP_MODE_SNAPMGR	4		/* snapshot manager mode */
#define	SNP_MODE_SDA		5		/* SDA mode */
#define	SNP_MODE_MAIL_DATA	6		/* mail snap data mode */
#define	SNP_SCALING_COMMON	1
#define	SNP_SCALING_PRIMARY	2
#define	SNP_SCALING_LOG		3
#define	SNP_OPT_NONE		0
#define	SNP_OPT_BY_FILE_NAME	0
#define	SNP_OPT_BY_FILE_NUMBER	1
#define	SNP_OPT_CONNECT_POINTS	1
#define	SNP_OPT_PLOT_CHARACTERS	2
#define	SNP_OPT_BLINK_NEW_DATA	4
#define	SNP_OPT_NO_ERASE	0x80
#define	SNP_SETUP_NONE		0
#define	SNP_SETUP_EXT_TRIGGER	1
#define	SNP_SETUP_FRIG		2
#define	SNP_SETUP_SNAPMGR	3
#define	SNP_SETUP_SDA		4

typedef struct SNP_OPTION_DATA
    {
    unsigned int	options;
    } __attribute__((packed)) SNP_OPTION_DATA;

typedef struct SNP_EXT_TRIGGER_DATA
    {
    int		external_reference_number;	/* external reference spiggot number (1-4) */
    } __attribute__((packed)) SNP_EXT_TRIGGER_DATA;

typedef struct SNP_SDA_PLOT_DATA
    {
    int		sda_usage_number;		/* SDA usage number */
    int		sda_file_number;		/* SDA file number */
    int		sda_case_number;		/* SDA case number */
    int		sda_subcase_number;		/* SDA subcase number */
    int		sda_try_number;			/* SDA try number */
    } __attribute__((packed)) SNP_SDA_PLOT_DATA;

typedef struct SNP_SNAPMGR_PLOT_DATA
    {
    int		snpmgr_subsystem_number;	/* SNAP subsystem number */
    int		snpmgr_record_number;		/* SNAP record number */
    int		snpmgr_user_id;			/* SNAP user ID */
    int		snpmgr_user_key_1;		/* SNAP user key 1 */
    int		snpmgr_user_key_2;		/* SNAP user key 2 */
    } __attribute__((packed)) SNP_SNAPMGR_PLOT_DATA;

typedef struct SNP_FRIG_PLOT_DATA
    {
    int		external_reference_mask;	/* FRIG external reference mask */
    char	external_reference_name[DEVICE_NAME_LEN];	/* FRIG external reference device */
    } __attribute__((packed)) SNP_FRIG_PLOT_DATA;

typedef struct SNP_PLOT_DATA
    {
    int		mode;
    SNP_DEVICE_DATA	y_devices[SNP_MAX_Y_DEVICES];
    int		frequency_code;
    float	sample_rate_khz;		/* plot sample rate (KHz) */
    int		time_base;			/* arming code */
    int		arm_events[SNP_MAX_ARM_EVENTS];	/* arm events */
    int		plot_scaling;
    SNP_EXT_TRIGGER_DATA	ext_trigger_data;
    SNP_SDA_PLOT_DATA	sda_plot_data;		/* SDA snapshot plot data */
    SNP_SNAPMGR_PLOT_DATA	snapmgr_plot_data;	/* detached snapshot plot manager snapshot plot data */
    SNP_FRIG_PLOT_DATA	frig_plot_data;		/* frig snapshot plot data */
    SNP_OPTION_DATA	option_data;
    } __attribute__((packed)) SNP_PLOT_DATA;

#define	SNP_ID_LEN	8			/* length of snapshot plot structure identifier message */
#define	SNP_NUM_ROWS	3			/* number of rows in snapshot plot interface */
#define	SNP_TEXT_LEN	60			/* number of characters per line in snapshot plot interface */
#define	SNP_NUM_EVENTS	8			/* number of possible reference events */

typedef struct SNP_INFO				/* snapshot plot setup data - this structure's contents will change over time */
    {
    char	identifier[SNP_ID_LEN];		/* structure identifier string */
    XCHAR	text[SNP_NUM_ROWS][SNP_TEXT_LEN];	/* snapshot plot window text */
    char	events[SNP_NUM_EVENTS];
    } __attribute__((packed)) SNP_INFO;

#define	SNP_FILE_SYSTEM_NAME_LEN	80
#define	SNP_FILE_NAME_LEN		80
#define	SNP_FILE_DEVICE_TEXT_LEN	80

typedef struct SNP_FILE_INFO
    {
    char	system_name[SNP_FILE_SYSTEM_NAME_LEN+2];
    int		file_number;
    char	file_name[SNP_FILE_NAME_LEN+2];
    char	device_text[SNP_FILE_DEVICE_TEXT_LEN+2];
    unsigned int	modify_date;
    } __attribute__((packed)) SNP_FILE_INFO;

/*
** wnlib wn_quick_grid...
*/
typedef struct PLOT_DATA		/* plot grid data structure */
    {
    int		id;			/* window ID */
    float	view_xmin;		/* viewport coordinates */
    float	view_ymin;
    float	view_xmax;
    float	view_ymax;
    float	real_xmin;		/* real coordinates */
    float	real_ymin;
    float	real_xmax;
    float	real_ymax;
    int		x_major_ticks;		/* # of major ticks on the x axis */
    int		x_minor_ticks;		/* # of minor ticks on the x axis */
    int		y_major_ticks;		/* # of major ticks on the y axis */
    int		y_minor_ticks;		/* # of minor ticks on the y axis */
    int		grid_x;			/* draw x grid if TRUE */
    int		grid_y;			/* draw y grid if TRUE */
    int		x_nchar;		/* # of characters for labelling x axis */
    int		x_label_type;		/* type of x labels (CNV_FLOAT - normal, CNV_EXP - scientific notation */
    int		y_nchar;		/* # of characters for labelling y axis */
    int		y_label_type;		/* type of y labels (CNV_FLOAT - normal, CNV_EXP - scientific notation */
    char	*x_title;		/* x axis title */
    int		x_text_size;		/* text size of x title */
    int		x_text_color;		/* color of x title */
    char	*y_title;		/* y axis title */
    int		y_text_size;		/* text size of y title */
    int		y_text_color;		/* color of y title */
    int		plot_type;		/* type of plotting (WN_SCALE_LINEAR_BOTH - linear, otherwise use WN_X(Y)_SCALE_xxx) */
    int		plot_flags;		/* miscellaneous plot information flags (same as wn_grid(_c)) */
    float	*yloc_major;		/* array of coordinates for major tick marks on the Y axis (number of ticks + 1) */
    float	*yloc_minor;		/* array of coordinates for minor tick marks on the Y axis (number of ticks + 1) */
    float	*xloc_major;		/* array of coordinates for major tick marks on the X axis (number of ticks + 1) */
    float	*xloc_minor;		/* array of coordinates for minor tick marks on the X axis (number of ticks + 1) */
    } __attribute__((packed)) PLOT_DATA;

typedef struct WN_VECTOR_GRAIN_DATA
    {
    int		separation;		/* number of pixels between displayed pixels */
    int		multiplier;		/* pattern multiplier */
    } __attribute__((packed)) WN_VECTOR_GRAIN_DATA;

typedef struct WN_SYMBOL_ATTRIBUTE_DATA
    {
    char	symbol_name[LEN_LEXOBJECT];	/* current symbol name */
    short 	symbol_rotation;	/* symbol rotation */
    short 	symbol_attr1;		/* symbol attribute values... */
    short 	symbol_attr2;
    short 	symbol_attr3;
    short 	symbol_attr4;
    short 	symbol_attr5;
    short 	symbol_attr6;
    } __attribute__((packed)) WN_SYMBOL_ATTRIBUTE_DATA;

typedef struct WN_FIELD_CONSTRAINT	/* field constraint structure */
    {
    int		constrain_to_window;
    int		window_id;
    int		constrain_to_field;
    float	y;
    float	height;
    float	x;
    float	width;
    } __attribute__((packed)) WN_FIELD_CONSTRAINT;

typedef struct WN_EXPOSE_DATA		/* window expose callback data structure */
    {
    int		previous_depth;		/* previous stack depth */
    } __attribute__((packed)) WN_EXPOSE_DATA;

typedef struct WN_OCCLUDE_DATA		/* window occlude callback data structure */
    {
    int		occluding_window_id;	/* occluding window ID */
    } __attribute__((packed)) WN_OCCLUDE_DATA;

/*
** window manager callback function passed data structures
*/
typedef struct WINDOW_INTYPE_DATA	/* window intype callback data structure */
    {
    short	type;			/* interrupt type from intype (INTxxx) plus INT_ENTER_FIELD and INT_LEAVE_FIELD for enter and leave field callbacks */
    int		row;			/* window row of interrupt */
    int		col;			/* window column of interrupt */
    int		info;			/* interrupt information */
    } __attribute__((packed)) WINDOW_INTYPE_DATA;

typedef struct WINDOW_MOVE_DATA		/* window move callback data structure */
    {
    int		row;			/* new top row of window */
    int		col;			/* new left column of window */
    int		delta_row;		/* new top row minus old */
    int		delta_col;		/* new left column minus old */
    } __attribute__((packed)) WINDOW_MOVE_DATA;

typedef struct WINDOW_RESIZE_DATA	/* window resize callback data structure */
    {
    int		height;			/* new window height */
    int		width;			/* new window width */
    int		delta_height;		/* new height minus old */
    int		delta_width;		/* new width minus old */
    } __attribute__((packed)) WINDOW_RESIZE_DATA;

typedef struct WINDOW_SCROLL_DATA	/* window scroll callback data structure */
    {
    int		direction;		/* scroll direction */
    int		num_lines;		/* number of lines (vertical scroll) */
    int		num_characters;		/* number of characters (horizontal scroll) */
    } __attribute__((packed)) WINDOW_SCROLL_DATA;

typedef struct WINDOW_EXPOSE_DATA	/* window expose callback data structure */
    {
    int		previous_depth;		/* previous stack depth */
    } __attribute__((packed)) WINDOW_EXPOSE_DATA;

typedef struct WINDOW_OCCLUDE_DATA	/* window occlude callback data structure */
    {
    short	occluding_window_id;	/* occluding window ID */
    } __attribute__((packed)) WINDOW_OCCLUDE_DATA;

#define	WMNGR_NO_DATA		0	/* no data in this structure */
#define	WMNGR_GRAPHWIN_DATA	1	/* data is graphical window information */

typedef struct WINDOW_INTYPE_EXTRA_INFO	/* window intype extra information data structure */
    {
    int		type;			/* information type */
    int		id;			/* graphic window ID */
    float	x;			/* x coordinate of interrupt */
    float	y;			/* y coordinate of interrupt */
    int		in_window;		/* flag indicating whether or not cursor was in graphic window */
    int		unused[3];
    } __attribute__((packed)) WINDOW_INTYPE_EXTRA_INFO;

typedef struct WINDOW_CREATE_CALLBACK_DATA
    {
    short	window_id;		/* window ID */
    int		top_row;		/* top row */
    int		left_column;		/* left column */
    int		bottom_row;		/* bottom row */
    int		right_column;		/* right column */
    int		bkgd_color;		/* window background color */
    int		title_color;		/* window title color */
    int		border_color;		/* window border color */
    int		border_style;		/* style of border */
    int		clip_it;		/* right and bottom clipping flag */
    int		move_it;		/* move enable flag */
    int		resize_it;		/* resize enable flag */
    int		is_popup;		/* flag to indicate if this is a popup window */
    int		restore_mode;		/* text repaint mode */
    int		vertical_scrollbar;	/* vertical scroll bar present flag */
    int		horizontal_scrollbar;	/* horizontal scroll bar present flag */
    short	parent;			/* parent window ID */
    int		intype_operation;	/* flag indicating a window_intype generated action */
    } __attribute__((packed)) WINDOW_CREATE_CALLBACK_DATA;

typedef struct WINDOW_DELETE_CALLBACK_DATA
    {
    short	window_id;		/* window ID */
    int		top_row;		/* top row */
    int		left_column;		/* left column */
    int		right_column;		/* right column */
    int		bottom_row;		/* bottom row */
    int		bkgd_color;		/* window background color */
    int		title_color;		/* window title color */
    int		border_color;		/* window border color */
    int		border_style;		/* style of border */
    int		clip_it;		/* right and bottom clipping flag */
    int		move_it;		/* move enable flag */
    int		resize_it;		/* resize enable flag */
    int		is_popup;		/* window push/pop enable flag */
    int		restore_mode;		/* text repaint mode */
    int		vertical_scrollbar;	/* vertical scroll bar present flag */
    int		horizontal_scrollbar;	/* horizontal scroll bar present flag */
    short	parent;			/* parent window ID */
    int		intype_operation;	/* flag indicating a window_intype generated action */
    } __attribute__((packed)) WINDOW_DELETE_CALLBACK_DATA;

typedef void (*window_delete_notify_func)(short window_id, int will_delete, void *notify_data);

typedef struct WINDOW_DELETE_REQUEST_CB_DATA
    {
    int		request_type;		/* ID, handle, or title */
    short	window_id;		/* requested window ID */
    char	*handle_or_title;	/* requested window handle or title */
    window_delete_notify_func	notify_func;	/* notification function */
    void	*notify_data;		/* notification data */
    } __attribute__((packed)) WINDOW_DELETE_REQUEST_CB_DATA;

typedef struct WINDOW_CHANGE_CALLBACK_DATA
    {
    int		change_type;		/* type of change */
    void	*change_data;		/* pointer to changed data */
    } __attribute__((packed)) WINDOW_CHANGE_CALLBACK_DATA;

typedef struct WINDOW_CHANGE_TITLE_DATA
    {
    int		change_type;		/* type of change */
    char	*title;			/* new window title */
    } __attribute__((packed)) WINDOW_CHANGE_TITLE_DATA;

typedef struct WINDOW_CHANGE_CLIPPING_DATA
    {
    int		change_type;		/* type of change */
    int		*clip_it;		/* new clipping state */
    } __attribute__((packed)) WINDOW_CHANGE_CLIPPING_DATA;

typedef struct WINDOW_CHANGE_HANDLE_DATA
    {
    int		change_type;		/* type of change */
    char	*handle;		/* new window handle */
    } __attribute__((packed)) WINDOW_CHANGE_HANDLE_DATA;

typedef struct WINDOW_CHANGE_LINE_LENGTH_DATA
    {
    int		change_type;		/* type of change */
    int		*line_length;		/* new line length */
    } __attribute__((packed)) WINDOW_CHANGE_LINE_LENGTH_DATA;

typedef struct WINDOW_CHANGE_KEY_DATA
    {
    int		change_type;		/* type of change */
    int		*new_value;		/* new value */
    } __attribute__((packed)) WINDOW_CHANGE_KEY_DATA;

typedef void (*window_interrupt_function)(short window_id, void *callback_data,
					  WINDOW_INTYPE_DATA *intype_data);	/* window loop function */

typedef struct WINDOW_INTERRUPT_FUNC_DATA
    {
    short	interrupt_type;
    window_interrupt_function	function;
    void	*func_data;
    } __attribute__((packed)) WINDOW_INTERRUPT_FUNC_DATA;

typedef struct WINDOW_MAIL_INFO		/* information for mailing the contents of a window */
    {
    char	*subject;		/* subject string */
    char	*body_text;		/* body text string */
    } __attribute__((packed)) WINDOW_MAIL_INFO;

typedef struct TEXT_CURSOR_DATA		/* text_cursor_init callback data structure */
    {
    int		row;			/* row of key event */
    int		col;			/* column of key event */
    int		key_info;		/* key pressed */
    int		color;			/* echo color */
    int		key_state;		/* key modifier information */
    } __attribute__((packed)) TEXT_CURSOR_DATA;

typedef struct CNS_EDIT_DATA		/* cns_edit callback data structure */
    {
    int		is_post_process;	/* post processing flag */
    int		insert_mode;		/* insert mode */
    int		wrap_mode;		/* wrap mode */
    } __attribute__((packed)) CNS_EDIT_DATA;

typedef struct MENU_BAR_INTERRUPT_DATA	/* menu bar callback data structure */
    {
    int		field;			/* field number */
    } __attribute__((packed)) MENU_BAR_INTERRUPT_DATA;

typedef struct MENU_INTERRUPT_DATA	/* menu callback data structure */
    {
    int		item;			/* item number */
    } __attribute__((packed)) MENU_INTERRUPT_DATA;

typedef struct SWITCH_ACTION_DATA	/* switch callback data structure */
    {
    int		id;			/* switch ID */
    int		new_switch;		/* newly activated switch (radio switches only) */
    int		last_switch;		/* previously activate switch (radio switches only) */
    int		switch_state;		/* present state of switch */
    char	*handle;		/* identifier handle */
    } __attribute__((packed)) SWITCH_ACTION_DATA;

typedef struct SLIDER_ACTION_DATA	/* slider callback data structure */
    {
    int		id;			/* slider ID */
    int		action;			/* type of slider action */
    float	old_value;		/* previous slider value */
    float	new_value;		/* new slider value */
    } __attribute__((packed)) SLIDER_ACTION_DATA;

typedef struct HELP_FUNCTION_DATA	/* help callback data structure */
    {
    int		help_id;		/* help ID */
    int		row;			/* window row when help key was pressed (physical row) */
    int		column;			/* window column when help key was pressed (physical column) */
    int		relative_row;		/* interrupt row relative to top row of help field */
    int		relative_column;	/* interrupt column relative to left column of help field */
    char	*handle;		/* identifier handle */
    } __attribute__((packed)) HELP_FUNCTION_DATA;

typedef struct HELP_CALLBACK_DATA	/* help callback setup data structure */
    {
    int		help_type;		/* help type */
					/* these values are for WMNGR_BY_FILE_NAME */
    char	*help_file;		/* null terminated help file name */
    int		help_record;		/* help record */
					/* these values are for WMNGR_BY_FUNCTION */
    void_function	help_func;	/* help callback function */
    void	*help_func_data;	/* data to pass to 'help_func' */
					/* these values are for WMNGR_BY_CONSOLE_HELP */
    int		help_level;		/* console help level */
    int		help_entry;		/* console help entry */
    char	*help_text;		/* simple help text string */
    int		help_text_length;	/* length of help text string */
    } __attribute__((packed)) HELP_CALLBACK_DATA;

typedef struct WINDOW_FIELD_INTERRUPT_DATA	/* window field callback data structure */
    {
    short	type;			/* interrupt type from intype (INTxxx) plus INT_ENTER_FIELD and INT_LEAVE_FIELD for enter and leave field callbacks */
    int		row;			/* window row of interrupt */
    int		column;			/* window column of interrupt */
    int		info;			/* interrupt information */
    int		top_row;		/* top row of field */
    int		left_column;		/* left column of field */
    int		height;			/* height of field */
    int		width;			/* width of field */
    int		relative_row;		/* interrupt row relative to top row of field */
    int		relative_column;	/* interrupt column relative to left column of field */
    int		is_scrollable;		/* flag indicating if the field is scrollable */
    char	*handle;		/* identifier handle */
    short	field_window_id;	/* window ID of window that the field is in */
    } __attribute__((packed)) WINDOW_FIELD_INTERRUPT_DATA;

typedef struct LIST_FIELD_DATA		/* list field callback data structure */
    {
    int		field_id;		/* list field ID */
    char	*handle;		/* identifier handle */
    int		item;			/* item selected */
    char	*item_text;		/* selected item text */
    int		text_length;		/* length of item text string */
    int		row;			/* row of list field */
    int		left_column;		/* left column of list field */
    int		logical_item;		/* selected item number minus separators */
    } __attribute__((packed)) LIST_FIELD_DATA;

typedef struct INPUT_FIELD_DATA		/* input field callback data structure */
    {
    int		field_id;		/* input field ID */
    char	*handle;		/* identifier handle */
    void	*new_value;		/* new value entered */
    int		data_type;		/* data type */
    int		data_length;		/* data length in bytes */
    int		row;			/* row of input field */
    int		left_column;		/* left column of input field */
    int		array_index;		/* array index */
    } __attribute__((packed)) INPUT_FIELD_DATA;

typedef struct TOGGLE_SWITCH_DATA	/* toggle switch callback data structure */
    {
    int		switch_id;		/* toggle switch ID */
    char	*handle;		/* identifier handle */
    int		switch_value;		/* new switch value */
    int		row;			/* row of toggle switch */
    int		left_column;		/* left column of toggle switch */
    } __attribute__((packed)) TOGGLE_SWITCH_DATA;

#define	SELECT_FIELD_NOOP	0	/* no operation has taken place on this select field */
#define	SELECT_FIELD_DECREMENT	1	/* select field was decremented */
#define	SELECT_FIELD_SELECT	2	/* a new value was selected in the select field */
#define	SELECT_FIELD_INCREMENT	3	/* select field was incremented */

typedef struct SELECT_FIELD_DATA	/* select field callback data structure */
    {
    int		select_id;		/* select field type ID */
    char	*handle;		/* identifier handle */
    int		operation;		/* operation on the select field */
    char	*entry_text;		/* current entry text */
    int		entry_index;		/* current entry index */
    } __attribute__((packed)) SELECT_FIELD_DATA;

typedef struct HILITE_UPDATE_DATA	/* highlight region callback data structure */
    {
    int		row;			/* highlight row */
    int		column;			/* highlight start column */
    int		num_chars;		/* # of characters per entry */
    int		top_row;		/* top row of highlight region */
    int		left_column;		/* leftmost column of highlight region */
    int		num_items;		/* # of highlighted items */
    int		num_columns;		/* # of columns */
    int		items_per_column;	/* items per column */
    int		width;			/* width of region in characters */
    int		field_orient;		/* cursor check field orientation */
    int		field_length;		/* cursor check field length */
    int		field_offset;		/* cursor check field offset */
    int		separation;		/* # of characters separating adjacent columns */
    int		color;			/* highlight color */
    } __attribute__((packed)) HILITE_UPDATE_DATA;

typedef struct WINDOW_TEXT_FORMAT	/* row/column text format */
    {
    int		num_rows;		/* number of rows */
    int		num_columns;		/* number of columns */
    } __attribute__((packed)) WINDOW_TEXT_FORMAT;

typedef struct WINDOW_FIELD_CONSTRAINT	/* field constraint structure */
    {
    int		constrain_to_window;
    int		window_id;
    int		constrain_to_field;
    int		top_row;
    int		num_rows;
    int		left_column;
    int		num_columns;
    } __attribute__((packed)) WINDOW_FIELD_CONSTRAINT;

typedef struct KEY_CALLBACK_DATA	/* key press callback data structure */
    {
    unsigned int	key_symbol;	/* key symbol */
    int		modifier;		/* key modifier */
    short	window_id;		/* window ID */
    int		row;			/* window row of key press */
    int		column;			/* window column of interrupt */
    } __attribute__((packed)) KEY_CALLBACK_DATA;

typedef struct KNOB_EVENT_DATA		/* knob change data structure */
    {
    int		scaled_count;		/* scaled knob count */
    int		raw_count;		/* raw knob count */
    float	float_scaled_count;	/* floating point scaled knob count */
    int		integrated_count;	/* unscaled integrated count */
    short	window_id;		/* window ID */
    int		row;			/* window row */
    int		column;			/* window column */
    } __attribute__((packed)) KNOB_EVENT_DATA;

#define	SCRIPT_FILL_LEN	(80 - (SCRIPT_NAMLEN + 20 + PROCESS_NAME_LEN))

typedef struct				/* script_select info */
    {
    char	script_name[SCRIPT_NAMLEN];	/* name of script */
    int		script_doterm;			/* TRUE-> program terminates */
    float	script_speed;			/* replay multiplier */
    int		script_noset;			/* TRUE-> inhibit device settings */
    int		script_nofswrite;		/* TRUE-> inhibit file writes */
    int		script_notify_node;		/* if nonzero, notify this node upon termination */
    char	script_notify_process[PROCESS_NAME_LEN];	/* process to notify upon termination */
    char	script_filler[SCRIPT_FILL_LEN];	/* fill out to 80 bytes */
    } __attribute__((packed)) do_script_t;

typedef struct SCRIPT_REPLAY_STATUS		/* returned script replay status */
    {
    char	id_string[sizeof("script_replay")];	/* ID string ("script_replay") */
    char	script_name[SCRIPT_NAMLEN];	/* name of script replayed */
    int		status;				/* script replay status */
    } __attribute__((packed)) SCRIPT_REPLAY_STATUS;

#define	CNS_USER_NAME_LEN	12		/* length of console user name text */
#define	CNS_LOCATION_LEN	12		/* length of console location text */
#define	CNS_SERVER_NAME_LEN	30		/* length of console server name text */

typedef struct CONSOLE_INFO_DATA		/* data structure for use with console_info */
    {
    int		console;			/* console number */
    char	user_name[CNS_USER_NAME_LEN+1];	/* null terminated user name */
    char	location[CNS_LOCATION_LEN+1];	/* null terminated console location text */
    int		phone_num;			/* nearest phone number */
    unsigned int	flags;			/* console information flags */
    unsigned short	trunk;			/* console trunk */
    unsigned short	node;			/* console node number */
    unsigned int	console_class;		/* console class */
    char	server[CNS_SERVER_NAME_LEN+1];	/* null terminated server node name */
    } __attribute__((packed)) CONSOLE_INFO_DATA;

#define	CNS_PGM_NAME_LEN	18		/* length of a console program name */

typedef struct CONSOLE_LIVE_INFO_DATA
    {
    int		console;			/* console number */
    unsigned int	program_loads;		/* number of program loads */
    unsigned int	program_stages;		/* number of program stages */
    unsigned int	user_aborts;		/* number of user aborts */
    unsigned int	program_aborts;		/* number of program aborts */
    int		chgpgm_time;			/* last time a CHGPGM was executed */
    int		cnsrunstop_time;		/* last time console was started or stopped */
    char	pa_page[PAGNAM_LEN+2];		/* null terminated PA page */
    char	pa_name[CNS_PGM_NAME_LEN+2];	/* null terminated PA program name */
    char	pb_page[PAGNAM_LEN+2];		/* null terminated PB page */
    char	pb_name[CNS_PGM_NAME_LEN+2];	/* null terminated PB program name */
    char	pc_page[PAGNAM_LEN+2];		/* null terminated PC page */
    char	pc_name[CNS_PGM_NAME_LEN+2];	/* null terminated PC program name */
    char	pd_page[PAGNAM_LEN+2];		/* null terminated PD page */
    char	pd_name[CNS_PGM_NAME_LEN+2];	/* null terminated PD program name */
    char	pe_page[PAGNAM_LEN+2];		/* null terminated PE page */
    char	pe_name[CNS_PGM_NAME_LEN+2];	/* null terminated PE program name */
    short	slot1_task;			/* slot 1 task number */
    short	slot2_task;			/* slot 2 task number */
    short	slot3_task;			/* slot 3 task number */
    short	slot4_task;			/* slot 4 task number */
    short	slot5_task;			/* slot 5 task number */
    short	slot6_task;			/* slot 6 task number */
    short	slot7_task;			/* slot 7 task number */
    short	slot8_task;			/* slot 8 task number */
    short	slot9_task;			/* slot 9 task number */
    short	slot10_task;			/* slot 10 task number */
    short	slot11_task;			/* slot 11 task number */
    short	slot12_task;			/* slot 12 task number */
    short	slot13_task;			/* slot 13 task number */
    } __attribute__((packed)) CONSOLE_LIVE_INFO_DATA;

typedef struct CONSOLE_SLOT_INFO
    {
    int		slot;
    char	task_name[PROCESS_NAME_LEN+2];
    char	page_name[PAGE_NAME_LEN+2];		/* null terminated page name */
    char	program_name[CNS_PGM_NAME_LEN+2];	/* null terminated program name */
    } __attribute__((packed)) CONSOLE_SLOT_INFO;

#define	NUM_CONSOLE_INFO_SLOTS		13

typedef struct CONSOLE_LIVE_INFO_FULL_DATA
    {
    int		console;			/* console number */
    unsigned int	program_loads;		/* number of program loads */
    unsigned int	program_stages;		/* number of program stages */
    unsigned int	user_aborts;		/* number of user aborts */
    unsigned int	program_aborts;		/* number of program aborts */
    int		chgpgm_time;			/* last time a CHGPGM was executed */
    int		cnsrunstop_time;		/* last time console was started or stopped */
    int		num_slots_present;		/* number of slots returned */
    CONSOLE_SLOT_INFO	slot_info[NUM_CONSOLE_INFO_SLOTS];	/* slot program information */
    } __attribute__((packed)) CONSOLE_LIVE_INFO_FULL_DATA;

#define	DIO_PDB_MAX_CONSTANTS	6	/* maximum number of scaling constants */

typedef struct PDB_RS			/* contents of a reading/setting PDB */
    {
    ubyte	pdb_len;		/* byte length of PDB */
    ubyte	pdb_att;		/* device attributes */
    char	pdb_ptxt[4];		/* primary units text */
    char	pdb_ctxt[4];		/* common units text */
    ubyte	pdb_pinx;		/* primary transform index */
    ubyte	pdb_cinx;		/* common transform index */
    float	pdb_cnst[DIO_PDB_MAX_CONSTANTS];	/* common transform constants */
    } __attribute__((packed)) PDB_RS;

#define	DIO_PDB_MAX_PRIMARY_CONSTANTS	2	/* maximum number of primary scaling constants */
#define	DIO_PDB_EXT_MAX_CONSTANTS	10	/* maximum number of scaling constants */

typedef struct PDB_RS_EXT		/* contents of an extended reading/setting PDB */
    {
    int		primary_transform;	/* primary transform index */
    int		common_transform;	/* common transform index */
    char	primary_text[4];	/* primary units text */
    char	common_text[4];		/* common units text */
    double	primary_minimum;	/* minimum primary value */
    double	primary_maximum;	/* maximum primary value */
    double	minimum;		/* minimum scaled value */
    double	maximum;		/* maximum scaled value */
    int		display_format;		/* display format */
    int		display_length;		/* number of characters to display */
    int		scaling_length;		/* number of bytes to scale */
    int		scaling_offset;		/* raw data scaling starting offset */
    double	primary_constants[DIO_PDB_MAX_PRIMARY_CONSTANTS];	/* primary transform constants */
    int		num_constants;		/* number of constants defined */
    double	constants[DIO_PDB_EXT_MAX_CONSTANTS];	/* common transform constants */
    } __attribute__((packed)) PDB_RS_EXT;

typedef struct PDB_STS			/* contents of basic status PDB */
    {
    ubyte		pdb_slen;	/* byte length of PDB */
    ubyte		pdb_sattr;	/* low nibble is attribute definition flags, high nibble is alternate character flags */
    ubyte		pdb_sinvert;	/* status data invert flags */
    ubyte		pdb_sdatalen;	/* unprocessed data length */
    unsigned int	pdb_son;	/* on attribute*/
    unsigned int	pdb_sred;	/* ready attribute*/
    unsigned int	pdb_srem;	/* remote attribute*/
    unsigned int	pdb_spol;	/* polarity attribute*/
    XCHAR		pdb_sonchar;	/* alternate character for 'on' status */
    XCHAR		pdb_soffchar;	/* alternate character for 'off' status */
    XCHAR		pdb_srdychar;	/* alternate character for 'ready' status */
    XCHAR		pdb_strpchar;	/* alternate character for 'tripped' status */
    XCHAR		pdb_sremchar;	/* alternate character for 'remote' status */
    XCHAR		pdb_slclchar;	/* alternate character for 'local' status */
    XCHAR		pdb_sposchar;	/* alternate character for 'positive' status */
    XCHAR		pdb_snegchar;	/* alternate character for 'negative' status */
    } __attribute__((packed)) PDB_STS;

typedef struct PDB_CON			/* contents of a digital control PDB */
    {
    ubyte		pdb_clen;	/* byte length of PDB */
    ubyte		pdb_cflgs;	/* misc flags */
    unsigned int	pdb_crst;	/* reset attribute */
    unsigned int	pdb_con;	/* on attribute */
    unsigned int	pdb_coff;	/* off attribute */
    unsigned int	pdb_cpos;	/* positive attribute */
    unsigned int	pdb_cneg;	/* negative attribute */
    ubyte		pdb_cfill[2];	/* filler--not used */
    } __attribute__((packed)) PDB_CON;

typedef struct DB_DATETIME_DATA		/* Sybase date structure */
    {
    int			days_since_1900;	/* number of days since 1/1/1900 */
    int			since_midnight_300ths;	/* number of 1/300th's of a second since midnight */
    } __attribute__((packed)) DB_DATETIME_DATA;

typedef struct DB_INSERT_DATA
    {
    unsigned char *data;
    int		length;
    } __attribute__((packed)) db_insert_data_t;

typedef char db_handle_t;

#define	DB_COLUMN_NAME_LEN	30		/* maximum length of a column name */
#define	DB_TYPE_NAME_LEN	16		/* maximum length of a data type name */

typedef struct DB_COLUMN_INFO
    {
    char	column_name[DB_COLUMN_NAME_LEN+1];	/* column name */
    char	type_name[DB_TYPE_NAME_LEN+1];	/* data type string */
    int		data_type;			/* data type */
    int		data_length;			/* column length in bytes */
    } __attribute__((packed)) DB_COLUMN_INFO;

typedef struct DB_RESULT_SET_INFO
    {
    int		num_columns;			/* number of columns for this result set */
    DB_COLUMN_INFO	*column_info;		/* array of column information structures */
    int		num_rows;			/* number of rows in this result set */
    } __attribute__((packed)) DB_RESULT_SET_INFO;

#define	SR_ITEM_DI	1			/* device index */
#define	SR_ITEM_DEVICE_NAME	2		/* device name */
#define	SR_ITEM_LIST_NUMBER	3		/* save list number */
#define	SR_ITEM_LIST_NAME	4		/* save list name */
#define	SR_ITEM_USER_LIST_NUMBER	5	/* user (display) save list number */
#define	SR_ITEM_USER_LIST_NAME	6		/* save list name */
#define	SR_ITEM_FAMILY_DI	7		/* family device index */
#define	SR_ITEM_FAMILY_NAME	8		/* family device name */
#define	SR_ITEM_FILE_PATH	9		/* file path */
#define	SR_ITEM_FILE	10			/* file name */
#define	SR_ITEM_DB_QUERY	11		/* database query string */
#define	SR_ITEM_NODE	12			/* ACNET node number */
#define	SR_ITEM_NODE_NAME	13		/* ACNET node name */
#define	SR_ITEM_CRATE	14			/* ACNET node number */
#define	SR_ITEM_CRATE_NAME	15		/* ACNET node name */

#define	SR_SAVE_DESCRIPTOR_LEN	32		/* length of a save/restore save item descriptor */

typedef struct SR_USER_LIST_NUMBER
    {
    int		system_index;
    int		level_1_list_index;
    int		level_2_list_index;
    } __attribute__((packed)) SR_USER_LIST_NUMBER;

typedef struct SR_CRATE_SPEC
    {
    int		node;
    int		crate;
    } __attribute__((packed)) SR_CRATE_SPEC;

typedef struct SR_SAVE_ITEM
    {
    int		type;				/* type of item */
    union
	{
	int	save_list;
	int	device_index;
	int	node;
	char	descriptor[SR_SAVE_DESCRIPTOR_LEN];
	SR_USER_LIST_NUMBER	user_list_number;
	SR_CRATE_SPEC	crate_spec;
	} data;
    } __attribute__((packed)) SR_SAVE_ITEM;

#define	SR_TITLE_LEN	40			/* length of save/restore file title */

typedef struct SR_DIR_INFO			/* file directory entry */
    {
    unsigned short	file_num;		/* file number */
    char		title[SR_TITLE_LEN];	/* file title */
    int			info;			/* file status information */
    unsigned int	timestamp;		/* save start time */
    } __attribute__((packed)) SR_DIR_INFO;

typedef struct SR_DIR_INFO_FULL			/* file directory entry */
    {
    unsigned short	file_num;		/* file number */
    char		title[SR_TITLE_LEN];	/* file title */
    int			info;			/* file status information */
    unsigned int	start_time;		/* save start time */
    unsigned int	end_time;		/* save end time */
    int			modify_enable;		/* modify enable flag */
    unsigned char	subsystem_map[32];	/* map indicating which subsystems were saved */
    unsigned short	version;		/* version of SRSAVE which made the save */
    unsigned int	first_error_di;		/* DI of the first device in error */
    short		store_number;		/* associated store number (SDA only) */
    short		file_size;		/* file size in blocks */
    int			num_dis;		/* number of DIs in file */
    int			num_dipis;		/* number of DI/PIs in file */
    int			num_di_errors;		/* number of DIs in error in file */
    int			num_dipi_errors;	/* number of DI/PIs in error in file */
    short		num_displays;		/* number of times this file has been displayed */
    int			num_display_dis;	/* number of DIs in this file that have been displayed */
    int			num_display_dipis;	/* number of DI/PIs in this file that have been displayed */
    unsigned int	display_time;		/* time this file was last displayed */
    short		num_restores;		/* number of times this file has been restored */
    int			num_restore_dis;	/* number of DIs in this file that have been restored */
    int			num_restore_dipis;	/* number of DI/PIs in this file that have been restored */
    unsigned int	restore_time;		/* time this file was last restored */
    short		num_modifies;		/* number of times this file has been modified */
    int			num_modify_dis;		/* number of DIs in this file that have been modified */
    int			num_modify_dipis;	/* number of DI/PIs in this file that have been modified */
    unsigned int	modify_time;		/* time this file was last modified */
    } __attribute__((packed)) SR_DIR_INFO_FULL;

#define	SR_STATUS_NO_SAVE	0		/* no save in progress */
#define	SR_STATUS_SAVING	1		/* save in progress */
#define	SR_STATUS_GLOBAL_SAVE	2		/* global save in progress */
#define	SR_STATUS_NORMAL_EXIT	3		/* normal save exit */
#define	SR_STATUS_ABNORMAL_EXIT	4		/* abnormal save exit */
#define	SR_STATUS_FORCED_EXIT	5		/* forced exit */

typedef struct SR_SAVE_STATUS_DATA		/* save status information */
    {
    int		file_number;			/* save file number */
    int		file_size;			/* save file size in blocks */
    int		console_number;			/* attached console */
    unsigned int	start_time;		/* save start time */
    unsigned int	end_time;		/* save end time */
    unsigned int	single_shot_done_time;	/* time single shot done */
    unsigned int	dis_to_save;		/* total number of DIs to save */
    unsigned int	num_saved_dis;		/* total number of DIs saved */
    unsigned int	num_saved_dipis;	/* total number of DIPIs saved */
    unsigned int	num_error_dis;		/* total number of DIs saved in error */
    unsigned int	num_error_dipis;	/* total number of DIPIs saved in error */
    } __attribute__((packed)) SR_SAVE_STATUS_DATA;

typedef struct SR_SNAPSHOT_HEADER		/* saved snapshot header information */
    {
    int			snapshot_mode;		/* DIO_STANDARD_SNAPSHOT_MODE or DIO_TRANSIENT_RECORDER_MODE */
    unsigned int	num_points;		/* number of points available */
    unsigned int	start_time;		/* date and time of arm event */
    unsigned char	arm_events[8];		/* arm clock events */
    int			arm_delay;		/* arm delay (msec or sample periods) */
    double		delta_time;		/* time between points in microseconds */
    unsigned char	trigger_events[8];	/* trigger clock events */
    int			system;			/* for plot: system or userkey 1 */
    int			record;			/* for plot: record # or userkey 2 */
    int			user_id;		/* for plot: user ID */
    unsigned short	trigger_data;		/* arm and trigger selection */
    } __attribute__((packed)) SR_SNAPSHOT_HEADER;

typedef struct ACNET_NODE			/* ACNET node descriptor */
    {
    unsigned char	node;
    unsigned char	trunk;
    } __attribute__((packed)) ACNET_NODE;

typedef struct STR_SEARCH_INFO			/* string search information structure */
    {
    char	*match_string;			/* pointer to null terminated match string */
    int		case_sensitive;			/* case sensitivity flag */
    char	wildcard_char;			/* wildcard character */
    char	filler;
    int		ignore_spaces;			/* ignore white space flag */
    } __attribute__((packed)) STR_SEARCH_INFO;

#define	STRUCT_CLASS_NAME_LEN	64		/* maximum length of a structure class name */
#define	STRUCT_NAME_LEN		64		/* maximum length of a structure name */
#define	STRUCT_FIELD_NAME_LEN	80		/* maximum structure field name length */

typedef struct STRUCT_FIELD_DATA		/* structure field data */
    {
    int		field_number;
    char	field_name[STRUCT_FIELD_NAME_LEN+2];
    int		data_type;			/* data type */
    int		atomic_length;
    int		num_elements;
    int		is_bit_mask;
    int		specific_data_type;
    int		edit_this_field;
    int		field_offset;
    void	*default_value;
    void	*minimum_value;
    void	*maximum_value;
    } __attribute__((packed)) STRUCT_FIELD_DATA;

#define	DIO_DIGITAL_CONTROL_TEXT_LEN	64	/* length of a digital control text string */
#define	DIO_DIGITAL_CONTROL_SHORT_TEXT_LEN	16	/* length of a short digital control text string */

typedef struct DIO_DIGITAL_CONTROL_ENTRY
    {
    int		order_number;			/* menu order number (starts at 0) */
    int		value;				/* raw command value */
    char	short_text[DIO_DIGITAL_CONTROL_SHORT_TEXT_LEN];	/* short command text */
    char	text[DIO_DIGITAL_CONTROL_TEXT_LEN];	/* command text */
    } __attribute__((packed)) DIO_DIGITAL_CONTROL_ENTRY;

#define	DIO_ENUM_VALUE_TEXT_LEN		64	/* length of an enumerated value text string */
#define	DIO_ENUM_VALUE_SHORT_TEXT_LEN	10	/* length of a short enumerated value text string */

typedef struct DIO_ENUM_VALUE_ENTRY
    {
    int		value;				/* enumerated value */
    char	short_text[DIO_ENUM_VALUE_SHORT_TEXT_LEN];	/* short enumerated value text */
    char	text[DIO_ENUM_VALUE_TEXT_LEN];	/* enumerated value text */
    } __attribute__((packed)) DIO_ENUM_VALUE_ENTRY;

typedef struct DIO_SLOT_TO_DI_REQ
    {
    unsigned short	node;			/* front end node */
    unsigned char	crate;			/* crate */
    unsigned char	slot;			/* slot */
    } DIO_SLOT_TO_DI_REQ;

typedef struct DIO_SLOT_TO_DI_REPLY
    {
    int		device_index;			/* device index */
    } __attribute__((packed)) DIO_SLOT_TO_DI_REPLY;

typedef struct DIO_DEV_TEXT_TO_NAME_REQ
    {
    char	device_text[LEN_DEV_DESCR_TEXT];	/* device text to match */
    } DIO_DEV_TEXT_TO_NAME_REQ;

typedef struct DIO_DEV_TEXT_TO_NAME_REPLY
    {
    char	name_and_text[DEVICE_TERSE_NAME_LEN+1+LEN_DEV_DESCR_TEXT];	/* matching device name and text */
    } __attribute__((packed)) DIO_DEV_TEXT_TO_NAME_REPLY;

#define	DIO_FULL_TEXT_SEARCH_STRING_LEN	(2 * DEVICE_FULL_DESCRIPTION_LEN)

typedef struct DIO_FULL_TEXT_TO_NAME_REQ
    {
    char	full_text[DIO_FULL_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    } DIO_FULL_TEXT_TO_NAME_REQ;

typedef struct DIO_FULL_TEXT_TO_NAME_REPLY
    {
    char	full_name[DEVICE_FULL_NAME_LEN];	/* matching device full name */
    char	full_text[DEVICE_FULL_DESCRIPTION_LEN];	/* matching device full text */
    int		device_index;				/* matching device index */
    unsigned char	device_state;			/* present device state (normal, obsolete, deleted) */
    unsigned char	unused;
    } __attribute__((packed)) DIO_FULL_TEXT_TO_NAME_REPLY;

typedef struct DIO_AUDIT_INFO_REQ
    {
    int		device_index;			/* device index to audit */
    } DIO_AUDIT_INFO_REQ;

#define	DIO_PROPERTY_LEN	6		/* length of property text */
#define	DIO_AUDIT_USER_NAME_LEN	30		/* length of audit record user name */
#define	DIO_OPERATION_LEN	10		/* length of database operation text */

typedef struct DIO_AUDIT_INFO_REPLY
    {
    char	date[20];			/* ASCII time of audit */
    char	device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    char	property_text[DIO_PROPERTY_LEN];	/* property text */
    char	operation[DIO_OPERATION_LEN];
    char	user_name[DIO_AUDIT_USER_NAME_LEN];	/* user name */
    } __attribute__((packed)) DIO_AUDIT_INFO_REPLY;

typedef struct DIO_SSDN_TO_DI_REQ
    {
    unsigned short	node;			/* front end node */
    char		compare_byte[LEN_SSDN];	/* compare flags */
    unsigned char	ssdn[LEN_SSDN];		/* SSDN to match */
    } DIO_SSDN_TO_DI_REQ;

typedef struct DIO_SSDN_TO_DI_REPLY
    {
    int		device_index;			/* device index */
    } __attribute__((packed)) DIO_SSDN_TO_DI_REPLY;

typedef struct DIO_DEVICE_INDEX_COUNT_REQ
    {
    int		allow_obsolete;			/* allow obsolete device flag */
    int		allow_deleted;			/* allow deleted device flag */
    } DIO_DEVICE_INDEX_COUNT_REQ;

typedef struct DIO_DEVICE_INDEX_COUNT_REPLY
    {
    int		num_device_indices;		/* number of active device indices */
    int		min_device_index;		/* minimum device index */
    int		max_device_index;		/* maximum device index */
    } __attribute__((packed)) DIO_DEVICE_INDEX_COUNT_REPLY;

typedef struct DIO_DEVICE_RANGE_REQ
    {
    int		min_device_index;		/* minimum device index */
    int		max_device_index;		/* maximum device index */
    int		allow_obsolete;			/* allow obsolete device flag */
    int		allow_deleted;			/* allow deleted device flag */
    } DIO_DEVICE_RANGE_REQ;

typedef struct DIO_DEVICE_RANGE_REPLY
    {
    char		device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int			device_index;		/* device index */
    } __attribute__((packed)) DIO_DEVICE_RANGE_REPLY;

typedef struct DIO_MADC_TO_DI_REQ
    {
    unsigned short	node;			/* front end node */
    unsigned short	madc_number;		/* MADC number */
    } DIO_MADC_TO_DI_REQ;

typedef struct DIO_MADC_TO_DI_REPLY
    {
    int			device_index;		/* device index */
    unsigned char	channel;		/* MADC channel number */
    unsigned char	unused;
    } __attribute__((packed)) DIO_MADC_TO_DI_REPLY;

typedef struct DIO_TRANSFORM_TO_DIPI_REQ
    {
    int			transform_type;		/* type of transform */
    unsigned short	transform_number;	/* transform number */
    } DIO_TRANSFORM_TO_DIPI_REQ;

typedef struct DIO_TRANSFORM_TO_DIPI_REPLY
    {
    char		device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int			device_index;		/* device index */
    unsigned char	property_index;		/* property index */
    } __attribute__((packed)) DIO_TRANSFORM_TO_DIPI_REPLY;

typedef struct DIO_SAVELIST_TO_DI_REQ
    {
    unsigned short	list_number;		/* save list ID number */
    } DIO_SAVELIST_TO_DI_REQ;

typedef struct DIO_SAVELIST_TO_DI_REPLY
    {
    char		device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int			device_index;		/* device index */
    } __attribute__((packed)) DIO_SAVELIST_TO_DI_REPLY;

typedef struct DIO_SAVECODE_TO_DI_REQ
    {
    short		restore_code;		/* restore handler code */
    short		restore_subcode;	/* restore handler subcode */
    short		display_code;		/* display handler code */
    } DIO_SAVECODE_TO_DI_REQ;

typedef struct DIO_SAVECODE_TO_DI_REPLY
    {
    char		device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int			device_index;		/* device index */
    } __attribute__((packed)) DIO_SAVECODE_TO_DI_REPLY;

typedef struct DIO_NODE_TO_DI_REQ
    {
    unsigned short	node;			/* front end node */
    } DIO_NODE_TO_DI_REQ;

typedef struct DIO_NODE_TO_DI_REPLY
    {
    char		device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int			device_index;		/* device index */
    } __attribute__((packed)) DIO_NODE_TO_DI_REPLY;

typedef struct DIO_DRIVER_TO_DI_REQ
    {
    unsigned char	driver_number;		/* front end driver number */
    } DIO_DRIVER_TO_DI_REQ;

typedef struct DIO_DRIVER_TO_DI_REPLY
    {
    char		device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int			device_index;		/* device index */
    unsigned short	node;			/* front end node */
    } __attribute__((packed)) DIO_DRIVER_TO_DI_REPLY;

typedef struct DIO_DRIVER_NODE_TO_DI_REQ
    {
    unsigned short	node;			/* front end node */
    unsigned char	driver_number;		/* front end driver number */
    } DIO_DRIVER_NODE_TO_DI_REQ;

typedef struct DIO_DRIVER_NODE_TO_DI_REPLY
    {
    char		device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int			device_index;		/* device index */
    } __attribute__((packed)) DIO_DRIVER_NODE_TO_DI_REPLY;

typedef struct DIO_CRATE_TO_DI_REQ
    {
    unsigned short	node;			/* front end node */
    unsigned char	crate;			/* crate */
    } DIO_CRATE_TO_DI_REQ;

typedef struct DIO_CRATE_TO_DI_REPLY
    {
    char		device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int			device_index;		/* device index */
    } __attribute__((packed)) DIO_CRATE_TO_DI_REPLY;

typedef struct DIO_VM_TO_DI_REQ
    {
    int			vm_device_index;	/* virtual machine device index */
    } DIO_VM_TO_DI_REQ;

typedef struct DIO_VM_TO_DI_REPLY
    {
    char		device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int			device_index;		/* device index */
    unsigned short	node;			/* front end node */
    unsigned int	property_mask;		/* virtual machine property mask */
    } __attribute__((packed)) DIO_VM_TO_DI_REPLY;

typedef struct DIO_UNITS_TO_DI_REQ
    {
    char		units_text[LEN_DEV_UNITS];	/* units text */
    unsigned short	units_type;		/* type of units (unused) */
    } DIO_UNITS_TO_DI_REQ;

typedef struct DIO_UNITS_TO_DI_REPLY
    {
    char		device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int			device_index;		/* device index */
    } __attribute__((packed)) DIO_UNITS_TO_DI_REPLY;

#define	DIO_NODE_PIS_MAX_PROPERTIES	8	/* maximum number of properties to check */

typedef struct DIO_NODE_PIS_TO_DIPI_REQ
    {
    unsigned short	node;			/* front end node */
    unsigned short	num_properties;		/* number of properties */
    unsigned char	property_indices[DIO_NODE_PIS_MAX_PROPERTIES];	/* requested properties */
    } DIO_NODE_PIS_TO_DIPI_REQ;

typedef struct DIO_NODE_PIS_TO_DIPI_REPLY
    {
    char		device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int			device_index;		/* device index */
    unsigned char	property_index;		/* property index */
    unsigned char	unused;
    } __attribute__((packed)) DIO_NODE_PIS_TO_DIPI_REPLY;

#define	DIO_DEVICE_SEARCH_STRING_LEN	32
#define	DIO_TEXT_SEARCH_STRING_LEN	64

typedef struct DIO_STR_TO_NAME_REQ
    {
    char		string[DIO_DEVICE_SEARCH_STRING_LEN+2];	/* device name text to match */
    int			num_characters;		/* number of characters to match */
    } DIO_STR_TO_NAME_REQ;

typedef struct DIO_STR_TO_NAME_REPLY
    {
    char		device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int			device_index;		/* device index */
    } __attribute__((packed)) DIO_STR_TO_NAME_REPLY;

#define	DIO_FULL_NAME_SEARCH_STRING_LEN	(2 * DEVICE_FULL_NAME_LEN)

typedef struct DIO_STR_TO_FULL_NAME_REQ
    {
    char		full_name[DIO_FULL_NAME_SEARCH_STRING_LEN+2];	/* device name text to match */
    int			num_characters;		/* number of characters to match */
    } DIO_STR_TO_FULL_NAME_REQ;

typedef struct DIO_STR_TO_FULL_NAME_REPLY
    {
    char		full_name[DEVICE_FULL_NAME_LEN];	/* device full name */
    int			device_index;		/* device index */
    unsigned char	device_state;		/* present device state (normal, obsolete, deleted) */
    unsigned char	unused;
    } __attribute__((packed)) DIO_STR_TO_FULL_NAME_REPLY;

typedef struct DIO_AUDIT_BY_TIME_INFO_REQ
    {
    char		start_time[30];		/* null terminated start date/time string */
    char		end_time[30];		/* null terminated end date/time string */
    } DIO_AUDIT_BY_TIME_INFO_REQ;

typedef struct DIO_AUDIT_BY_TIME_INFO_REPLY
    {
    char		date[20];		/* ASCII time of audit */
    char		device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    char		property_text[DIO_PROPERTY_LEN];	/* property text */
    char		operation[DIO_OPERATION_LEN];
    char		user_name[DIO_AUDIT_USER_NAME_LEN];	/* user name */
    } __attribute__((packed)) DIO_AUDIT_BY_TIME_INFO_REPLY;

#define	DIO_DI_TO_NAME_MAX_DIS	250		/* maximum number of device indices */

typedef struct DIO_DI_TO_NAME_REQ
    {
    unsigned short	num_device_indices;	/* number of device indices */
    int			device_indices[DIO_DI_TO_NAME_MAX_DIS];	/* requested device indices */
    } DIO_DI_TO_NAME_REQ;

typedef struct DIO_DI_TO_NAME_REPLY
    {
    char		device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int			device_index;		/* device index */
    unsigned char	device_state;		/* present device state (normal, obsolete, deleted) */
    unsigned char	unused;
    } __attribute__((packed)) DIO_DI_TO_NAME_REPLY;

#define	DIO_NAME_TO_DI_MAX_NAMES	250		/* maximum number of device names */

typedef struct DIO_NAME_TO_DI_REQ
    {
    unsigned short	num_device_names;		/* number of device names */
    char		device_names[DIO_NAME_TO_DI_MAX_NAMES][DEVICE_TERSE_NAME_LEN];	/* requested device names */
    } DIO_NAME_TO_DI_REQ;

typedef struct DIO_NAME_TO_DI_REPLY
    {
    char		device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int			device_index;		/* device index */
    unsigned char	device_state;		/* present device state (normal, obsolete, deleted) */
    unsigned char	unused;
    } __attribute__((packed)) DIO_NAME_TO_DI_REPLY;

typedef struct DIO_ALL_FE_NODES_REQ
    {
    int		unused;
    } DIO_ALL_FE_NODES_REQ;

typedef struct DIO_ALL_FE_NODES_REPLY
    {
    unsigned short	node;			/* front end node */
    } __attribute__((packed)) DIO_ALL_FE_NODES_REPLY;

typedef struct DIO_TYPE_NODE_TO_DIPI_REQ
    {
    int			device_class;		/* device class */
    int			device_type;		/* device type */
    unsigned short	node;			/* front end node */
    } DIO_TYPE_NODE_TO_DIPI_REQ;

typedef struct DIO_TYPE_NODE_TO_DIPI_REPLY
    {
    char		device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int			device_index;		/* device index */
    unsigned char	property_index;		/* property index */
    unsigned char	unused;
    } __attribute__((packed)) DIO_TYPE_NODE_TO_DIPI_REPLY;

#define	DIO_TYPE_NAME_STRING_LEN	16

typedef struct DIO_TYPE_NAME_TO_DIPI_REQ
    {
    int		device_class;					/* device class */
    int		device_type;					/* device type */
    char	name_string[DIO_DEVICE_SEARCH_STRING_LEN+2];	/* matching name string */
    char	text_string[DIO_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    char	full_name[DIO_FULL_NAME_SEARCH_STRING_LEN+2];	/* device name text to match */
    char	full_text[DIO_FULL_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    } DIO_TYPE_NAME_TO_DIPI_REQ;

typedef struct DIO_TYPE_NAME_TO_DIPI_REPLY
    {
    char		device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int			device_index;		/* device index */
    unsigned char	property_index;		/* property index */
    unsigned char	unused;
    } __attribute__((packed)) DIO_TYPE_NAME_TO_DIPI_REPLY;

typedef struct DIO_CONSOLE_CLASS_TO_DI_REQ
    {
    unsigned int	console_class;				/* console class mask */
    char	name_string[DIO_DEVICE_SEARCH_STRING_LEN+2];	/* matching name string */
    unsigned short	node;			/* front end node */
    char	text_string[DIO_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    char	full_name[DIO_FULL_NAME_SEARCH_STRING_LEN+2];	/* device name text to match */
    char	full_text[DIO_FULL_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    } DIO_CONSOLE_CLASS_TO_DI_REQ;

typedef struct DIO_CONSOLE_CLASS_TO_DI_REPLY
    {
    char		device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int			device_index;		/* device index */
    unsigned char	device_state;		/* present device state (normal, obsolete, deleted) */
    unsigned char	unused;
    } __attribute__((packed)) DIO_CONSOLE_CLASS_TO_DI_REPLY;

typedef struct DIO_CAMAC_MODULE_INFO_REQ
    {
    unsigned short	node;			/* front end node */
    int			module_number;		/* CAMAC module number */
    } DIO_CAMAC_MODULE_INFO_REQ;

typedef struct DIO_CAMAC_MODULE_INFO_REPLY
    {
    unsigned char	crate;			/* crate */
    unsigned char	slot;			/* slot */
    } __attribute__((packed)) DIO_CAMAC_MODULE_INFO_REPLY;

typedef struct DIO_EMC_TO_DI_REQ
    {
    unsigned short	node;			/* front end node */
    char		compare_byte[LEN_EMC];	/* compare flags */
    unsigned char	emc[LEN_EMC];		/* EMC to match */
    } DIO_EMC_TO_DI_REQ;

typedef struct DIO_EMC_TO_DI_REPLY
    {
    int		device_index;			/* device index */
    } __attribute__((packed)) DIO_EMC_TO_DI_REPLY;

typedef struct DIO_PRIORITY_TO_DIPI_REQ
    {
    int		priority;			/* priority number */
    int		comparator;			/* comparator */
    int		alarm_type;			/* type of alarm */
    unsigned short	node;			/* front end node */
    } DIO_PRIORITY_TO_DIPI_REQ;

typedef struct DIO_PRIORITY_TO_DIPI_REPLY
    {
    char		device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int			device_index;		/* device index */
    unsigned char	property_index;		/* property index */
    } __attribute__((packed)) DIO_PRIORITY_TO_DIPI_REPLY;

typedef struct DIO_CLASS_NODE_TO_DIPI_REQ
    {
    int			device_class;		/* device class */
    unsigned short	node;			/* front end node */
    } DIO_CLASS_NODE_TO_DIPI_REQ;

typedef struct DIO_CLASS_NODE_TO_DIPI_REPLY
    {
    char		device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int			device_index;		/* device index */
    unsigned char	property_index;		/* property index */
    unsigned char	unused;
    } __attribute__((packed)) DIO_CLASS_NODE_TO_DIPI_REPLY;

typedef struct DIO_GAS_MODULE_TO_DI_REQ
    {
    unsigned short	node;			/* front end node */
    int		house;				/* house number (1-42) */
    int		gas_slot;			/* GAS slot (0-6) */
    } __attribute__((packed)) DIO_GAS_MODULE_TO_DI_REQ;

typedef struct DIO_GAS_MODULE_TO_DI_REPLY
    {
    char	device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int		device_index;			/* device index */
    } __attribute__((packed)) DIO_GAS_MODULE_TO_DI_REPLY;

typedef struct DIO_ALARM_LIST_TO_DI_REQ
    {
    int		list_number;			/* alarm list ID number */
    } DIO_ALARM_LIST_TO_DI_REQ;

typedef struct DIO_ALARM_LIST_TO_DI_REPLY
    {
    char	device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int		device_index;			/* device index */
    unsigned char	device_state;		/* present device state (normal, obsolete, deleted) */
    unsigned char	unused;
    } __attribute__((packed)) DIO_ALARM_LIST_TO_DI_REPLY;

typedef struct DIO_DI_TO_FAMILY_REQ
    {
    int		device_index;			/* requested device index */
    } DIO_DI_TO_FAMILY_REQ;

typedef struct DIO_DI_TO_FAMILY_REPLY
    {
    char	device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int		device_index;			/* device index */
    unsigned char	device_state;		/* present device state (normal, obsolete, deleted) */
    unsigned char	unused;
    } __attribute__((packed)) DIO_DI_TO_FAMILY_REPLY;

typedef struct DIO_DI_TO_COMPOSITE_REQ
    {
    int		device_index;			/* requested device index */
    } DIO_DI_TO_COMPOSITE_REQ;

typedef struct DIO_DI_TO_COMPOSITE_REPLY
    {
    char	device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int		device_index;			/* device index */
    unsigned char	device_state;		/* present device state (normal, obsolete, deleted) */
    unsigned char	unused;
    } __attribute__((packed)) DIO_DI_TO_COMPOSITE_REPLY;

typedef struct DIO_ALL_DEVICES_REQ
    {
    int		unused;
    } DIO_ALL_DEVICES_REQ;

typedef struct DIO_ALL_DEVICES_REPLY
    {
    char	device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int		device_index;			/* device index */
    } __attribute__((packed)) DIO_ALL_DEVICES_REPLY;

#define	DIO_ALL_DIPIS_MAX_PROPERTIES	8	/* maximum number of properties to check */

typedef struct DIO_ALL_DIPIS_REQ
    {
    unsigned short	num_properties;		/* number of properties */
    unsigned char	property_indices[DIO_ALL_DIPIS_MAX_PROPERTIES];	/* requested properties */
    } DIO_ALL_DIPIS_REQ;

typedef struct DIO_ALL_DIPIS_REPLY
    {
    char		device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int			device_index;		/* device index */
    unsigned char	property_index;		/* property index */
    unsigned char	unused;
    } __attribute__((packed)) DIO_ALL_DIPIS_REPLY;

typedef struct DIO_WILDCARD_NODE_TO_DI_REQ
    {
    char	node_string[NODE_NAME_LEN+2];
    } DIO_WILDCARD_NODE_TO_DI_REQ;

typedef struct DIO_WILDCARD_NODE_TO_DI_REPLY
    {
    char		device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int			device_index;		/* device index */
    } __attribute__((packed)) DIO_WILDCARD_NODE_TO_DI_REPLY;

#define	DIO_WILDCARD_NODE_PIS_MAX_PROPERTIES	8	/* maximum number of properties to check */

typedef struct DIO_WILDCARD_NODE_PIS_TO_DIPI_REQ
    {
    char	node_string[NODE_NAME_LEN+2];
    unsigned short	num_properties;		/* number of properties */
    unsigned char	property_indices[DIO_WILDCARD_NODE_PIS_MAX_PROPERTIES];	/* requested properties */
    } DIO_WILDCARD_NODE_PIS_TO_DIPI_REQ;

typedef struct DIO_WILDCARD_NODE_PIS_TO_DIPI_REPLY
    {
    char		device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int			device_index;		/* device index */
    unsigned char	property_index;		/* property index */
    unsigned char	unused;
    } __attribute__((packed)) DIO_WILDCARD_NODE_PIS_TO_DIPI_REPLY;

typedef struct DIO_ALARM_HANDLER_TO_DIPI_REQ
    {
    short	property_index;
    int		handler_code;			/* alarm handler code */
    int		use_sound_id;
    int		sound_id;
    int		use_speech_id;
    int		speech_id;
    } DIO_ALARM_HANDLER_TO_DIPI_REQ;

typedef struct DIO_ALARM_HANDLER_TO_DIPI_REPLY
    {
    char	device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int		device_index;			/* device index */
    unsigned char	property_index;		/* property index */
    unsigned char	unused;
    int		condition;
    int		mask;
    } __attribute__((packed)) DIO_ALARM_HANDLER_TO_DIPI_REPLY;

typedef struct DIO_BYPASSED_ALARM_TO_DIPI_REQ
    {
    int		invert;				/* invert the sense of the query */
    short	property;			/* property or alarm type */
    char	name_string[DIO_DEVICE_SEARCH_STRING_LEN+2];	/* matching name string */
    char	text_string[DIO_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    unsigned short	node;			/* front end node */
    int		alarm_list;			/* alarm list ID */
    int		alarm_group;			/* alarm group */
    int		device_class;			/* device class */
    int		device_type;			/* device type */
    char	full_name[DIO_FULL_NAME_SEARCH_STRING_LEN+2];	/* device name text to match */
    char	full_text[DIO_FULL_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    } DIO_BYPASSED_ALARM_TO_DIPI_REQ;

typedef struct DIO_BYPASSED_ALARM_TO_DIPI_REPLY
    {
    char	device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int		device_index;			/* device index */
    unsigned char	property_index;		/* property index */
    unsigned char	unused;
    } __attribute__((packed)) DIO_BYPASSED_ALARM_TO_DIPI_REPLY;

typedef struct DIO_ALARM_SUPPRESSED_TO_DIPI_REQ
    {
    int		invert;				/* invert the sense of the query */
    short	property;			/* property or alarm type */
    char	name_string[DIO_DEVICE_SEARCH_STRING_LEN+2];	/* matching name string */
    char	text_string[DIO_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    unsigned short	node;			/* front end node */
    int		alarm_list;			/* alarm list ID */
    int		alarm_group;			/* alarm group */
    int		device_class;			/* device class */
    int		device_type;			/* device type */
    char	full_name[DIO_FULL_NAME_SEARCH_STRING_LEN+2];	/* device name text to match */
    char	full_text[DIO_FULL_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    } DIO_ALARM_SUPPRESSED_TO_DIPI_REQ;

typedef struct DIO_ALARM_SUPPRESSED_TO_DIPI_REPLY
    {
    char	device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int		device_index;			/* device index */
    unsigned char	property_index;		/* property index */
    unsigned char	unused;
    } __attribute__((packed)) DIO_ALARM_SUPPRESSED_TO_DIPI_REPLY;

typedef struct DIO_ALARM_NEVER_USED_TO_DIPI_REQ
    {
    int		invert;				/* invert the sense of the query */
    short	property;			/* property or alarm type */
    char	name_string[DIO_DEVICE_SEARCH_STRING_LEN+2];	/* matching name string */
    char	text_string[DIO_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    unsigned short	node;			/* front end node */
    int		alarm_list;			/* alarm list ID */
    int		alarm_group;			/* alarm group */
    int		device_class;			/* device class */
    int		device_type;			/* device type */
    char	full_name[DIO_FULL_NAME_SEARCH_STRING_LEN+2];	/* device name text to match */
    char	full_text[DIO_FULL_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    } DIO_ALARM_NEVER_USED_TO_DIPI_REQ;

typedef struct DIO_ALARM_NEVER_USED_TO_DIPI_REPLY
    {
    char	device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int		device_index;			/* device index */
    unsigned char	property_index;		/* property index */
    unsigned char	unused;
    } __attribute__((packed)) DIO_ALARM_NEVER_USED_TO_DIPI_REPLY;

typedef struct DIO_CURRENTLY_ALARMING_TO_DIPI_REQ
    {
    int		invert;				/* invert the sense of the query */
    short	property;			/* property or alarm type */
    char	name_string[DIO_DEVICE_SEARCH_STRING_LEN+2];	/* matching name string */
    char	text_string[DIO_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    unsigned short	node;			/* front end node */
    int		alarm_list;			/* alarm list ID */
    int		alarm_group;			/* alarm group */
    int		device_class;			/* device class */
    int		device_type;			/* device type */
    char	full_name[DIO_FULL_NAME_SEARCH_STRING_LEN+2];	/* device name text to match */
    char	full_text[DIO_FULL_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    } DIO_CURRENTLY_ALARMING_TO_DIPI_REQ;

typedef struct DIO_CURRENTLY_ALARMING_TO_DIPI_REPLY
    {
    char	device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int		device_index;			/* device index */
    unsigned char	property_index;		/* property index */
    unsigned char	unused;
    } __attribute__((packed)) DIO_CURRENTLY_ALARMING_TO_DIPI_REPLY;

typedef struct DIO_ABORT_ALARM_TO_DIPI_REQ
    {
    int		invert;				/* invert the sense of the query */
    short	property;			/* property or alarm type */
    char	name_string[DIO_DEVICE_SEARCH_STRING_LEN+2];	/* matching name string */
    char	text_string[DIO_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    unsigned short	node;			/* front end node */
    int		alarm_list;			/* alarm list ID */
    int		alarm_group;			/* alarm group */
    int		device_class;			/* device class */
    int		device_type;			/* device type */
    char	full_name[DIO_FULL_NAME_SEARCH_STRING_LEN+2];	/* device name text to match */
    char	full_text[DIO_FULL_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    } DIO_ABORT_ALARM_TO_DIPI_REQ;

typedef struct DIO_ABORT_ALARM_TO_DIPI_REPLY
    {
    char	device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int		device_index;			/* device index */
    unsigned char	property_index;		/* property index */
    unsigned char	unused;
    } __attribute__((packed)) DIO_ABORT_ALARM_TO_DIPI_REPLY;

#define	DIO_ALARM_TEXT_SEARCH_STRING_LEN	(2 * 80)

typedef struct DIO_ANALOG_ALARM_TEXT_TO_DI_REQ
    {
    char	alarm_text[DIO_ALARM_TEXT_SEARCH_STRING_LEN+2];	/* alarm text to match */
    int		invert;				/* invert the sense of the query */
    char	name_string[DIO_DEVICE_SEARCH_STRING_LEN+2];	/* matching name string */
    char	text_string[DIO_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    unsigned short	node;			/* front end node */
    int		alarm_list;			/* alarm list ID */
    int		alarm_group;			/* alarm group */
    int		device_class;			/* device class */
    int		device_type;			/* device type */
    char	full_name[DIO_FULL_NAME_SEARCH_STRING_LEN+2];	/* device name text to match */
    char	full_text[DIO_FULL_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    } DIO_ANALOG_ALARM_TEXT_TO_DI_REQ;

typedef struct DIO_ANALOG_ALARM_TEXT_TO_DI_REPLY
    {
    char	device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int		device_index;			/* device index */
    } __attribute__((packed)) DIO_ANALOG_ALARM_TEXT_TO_DI_REPLY;

typedef struct DIO_DIGITAL_ALARM_TEXT_TO_DI_REQ
    {
    char	alarm_text[DIO_ALARM_TEXT_SEARCH_STRING_LEN+2];	/* alarm text to match */
    int		invert;				/* invert the sense of the query */
    char	name_string[DIO_DEVICE_SEARCH_STRING_LEN+2];	/* matching name string */
    char	text_string[DIO_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    unsigned short	node;			/* front end node */
    int		alarm_list;			/* alarm list ID */
    int		alarm_group;			/* alarm group */
    int		device_class;			/* device class */
    int		device_type;			/* device type */
    char	full_name[DIO_FULL_NAME_SEARCH_STRING_LEN+2];	/* device name text to match */
    char	full_text[DIO_FULL_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    } DIO_DIGITAL_ALARM_TEXT_TO_DI_REQ;

typedef struct DIO_DIGITAL_ALARM_TEXT_TO_DI_REPLY
    {
    char	device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int		device_index;			/* device index */
    } __attribute__((packed)) DIO_DIGITAL_ALARM_TEXT_TO_DI_REPLY;

typedef struct DIO_CONTROLLING_DEVICE_TO_DI_REQ
    {
    int		controlling_device;		/* controlling device index */
    } DIO_CONTROLLING_DEVICE_TO_DI_REQ;

typedef struct DIO_CONTROLLING_DEVICE_TO_DI_REPLY
    {
    char	device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int		device_index;			/* device index */
    unsigned char	device_state;		/* present device state (normal, obsolete, deleted) */
    unsigned char	unused;
    } __attribute__((packed)) DIO_CONTROLLING_DEVICE_TO_DI_REPLY;

#define	DIO_EXPR_STR_TO_DI_STRING_LEN	255

typedef struct DIO_EXPR_STR_TO_DI_REQ
    {
    char	string[DIO_EXPR_STR_TO_DI_STRING_LEN+1];	/* device expression text to match */
    int		num_characters;					/* number of characters to match */
    char	name_string[DIO_DEVICE_SEARCH_STRING_LEN+2];	/* matching name string */
    int		device_class;					/* device class */
    int		device_type;					/* device type */
    char	text_string[DIO_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    char	full_name[DIO_FULL_NAME_SEARCH_STRING_LEN+2];	/* device name text to match */
    char	full_text[DIO_FULL_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    } DIO_EXPR_STR_TO_DI_REQ;

typedef struct DIO_EXPR_STR_TO_DI_REPLY
    {
    char		device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int			device_index;		/* device index */
    } __attribute__((packed)) DIO_EXPR_STR_TO_DI_REPLY;

typedef struct DIO_EXPR_DI_TO_DI_REQ
    {
    int			device_index;		/* device index */
    char		name_string[DIO_DEVICE_SEARCH_STRING_LEN+2];	/* matching name string */
    int			device_class;		/* device class */
    int			device_type;		/* device type */
    } DIO_EXPR_DI_TO_DI_REQ;

typedef struct DIO_EXPR_DI_TO_DI_REPLY
    {
    char		device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int			device_index;		/* device index */
    } __attribute__((packed)) DIO_EXPR_DI_TO_DI_REPLY;

typedef struct DIO_TEXT_NODE_TO_DI_REQ
    {
    char	text_string[DIO_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    char	name_string[DIO_DEVICE_SEARCH_STRING_LEN+2];	/* matching name string */
    unsigned short	node;			/* front end node */
    char	full_text[DIO_FULL_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    char	full_name[DIO_FULL_NAME_SEARCH_STRING_LEN+2];	/* device name text to match */
    } DIO_TEXT_NODE_TO_DI_REQ;

typedef struct DIO_TEXT_NODE_TO_DI_REPLY
    {
    char		device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int			device_index;		/* device index */
    } __attribute__((packed)) DIO_TEXT_NODE_TO_DI_REPLY;

typedef struct DIO_TYPE_TEXT_TO_DIPI_REQ
    {
    int		device_class;					/* device class */
    int		device_type;					/* device type */
    char	text_string[DIO_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    char	name_string[DIO_DEVICE_SEARCH_STRING_LEN+2];	/* matching name string */
    unsigned short	node;			/* front end node */
    char	full_name[DIO_FULL_NAME_SEARCH_STRING_LEN+2];	/* device name text to match */
    char	full_text[DIO_FULL_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    } DIO_TYPE_TEXT_TO_DIPI_REQ;

typedef struct DIO_TYPE_TEXT_TO_DIPI_REPLY
    {
    char		device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int			device_index;		/* device index */
    unsigned char	property_index;		/* property index */
    unsigned char	unused;
    } __attribute__((packed)) DIO_TYPE_TEXT_TO_DIPI_REPLY;

typedef struct DIO_USER_AUDIT_TO_DI_REQ
    {
    char	user_name[USER_NAME_LEN+2];			/* user name */
    unsigned int	timestamp;				/* modification date (in clinks) */
    int		created_only;					/* want only created devices */
    int		active_only;					/* want only active devices */
    short	property;					/* modification property */
    unsigned short	node;					/* front end node */
    char	name_string[DIO_DEVICE_SEARCH_STRING_LEN+2];	/* matching name string */
    char	text_string[DIO_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    char	full_name[DIO_FULL_NAME_SEARCH_STRING_LEN+2];	/* device name text to match */
    char	full_text[DIO_FULL_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    } DIO_USER_AUDIT_TO_DI_REQ;

typedef struct DIO_USER_AUDIT_TO_DI_REPLY
    {
    char		device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int			device_index;		/* device index */
    unsigned char	device_state;		/* present device state (normal, obsolete, deleted) */
    unsigned char	unused;
    } __attribute__((packed)) DIO_USER_AUDIT_TO_DI_REPLY;

typedef struct DIO_TRUNK_TO_DIPI_REQ
    {
    int		trunk;						/* trunk number */
    char	name_string[DIO_DEVICE_SEARCH_STRING_LEN+2];	/* matching name string */
    char	text_string[DIO_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    char	full_name[DIO_FULL_NAME_SEARCH_STRING_LEN+2];	/* device name text to match */
    char	full_text[DIO_FULL_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    } DIO_TRUNK_TO_DIPI_REQ;

typedef struct DIO_TRUNK_TO_DIPI_REPLY
    {
    char		device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int			device_index;		/* device index */
    unsigned char	property_index;		/* property index */
    unsigned char	unused;
    } __attribute__((packed)) DIO_TRUNK_TO_DIPI_REPLY;

#define	FOREIGN_DEVICE_PV_NAME_LEN	80	/* foreign device maximum PV name length */

typedef struct DIO_FOREIGN_DEVICE_TO_DIPI_REQ
    {
    char	foreign_name_string[FOREIGN_DEVICE_PV_NAME_LEN*2+2];	/* matching foreign name string */
    int		system_type;					/* control system type */
    int		device_class;					/* device class */
    int		device_type;					/* device type */
    char	text_string[DIO_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    char	name_string[DIO_DEVICE_SEARCH_STRING_LEN+2];	/* matching name string */
    unsigned short	node;					/* front end node */
    char	full_name[DIO_FULL_NAME_SEARCH_STRING_LEN+2];	/* device name text to match */
    char	full_text[DIO_FULL_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    } DIO_FOREIGN_DEVICE_TO_DIPI_REQ;

typedef struct DIO_FOREIGN_DEVICE_TO_DIPI_REPLY
    {
    char		device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int			device_index;		/* device index */
    unsigned char	property_index;		/* property index */
    unsigned char	unused;
    } __attribute__((packed)) DIO_FOREIGN_DEVICE_TO_DIPI_REPLY;

typedef struct DIO_STRUCT_NAME_TO_DIPI_REQ
    {
    char	struct_class_string[STRUCT_CLASS_NAME_LEN*2+2];	/* matching class name string */
    char	struct_name_string[STRUCT_NAME_LEN*2+2];	/* matching structure name string */
    int		device_class;					/* device class */
    int		device_type;					/* device type */
    char	text_string[DIO_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    char	name_string[DIO_DEVICE_SEARCH_STRING_LEN+2];	/* matching name string */
    unsigned short	node;					/* front end node */
    char	full_name[DIO_FULL_NAME_SEARCH_STRING_LEN+2];	/* device name text to match */
    char	full_text[DIO_FULL_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    } DIO_STRUCT_NAME_TO_DIPI_REQ;

typedef struct DIO_STRUCT_NAME_TO_DIPI_REPLY
    {
    char		device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int			device_index;		/* device index */
    unsigned char	property_index;		/* property index */
    unsigned char	unused;
    } __attribute__((packed)) DIO_STRUCT_NAME_TO_DIPI_REPLY;

typedef struct DIO_DEPARTMENT_TO_DI_REQ
    {
    char	department_string[64*2+2];			/* matching department name string */
    int		device_class;					/* device class */
    int		device_type;					/* device type */
    char	text_string[DIO_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    char	name_string[DIO_DEVICE_SEARCH_STRING_LEN+2];	/* matching name string */
    unsigned short	node;					/* front end node */
    char	full_name[DIO_FULL_NAME_SEARCH_STRING_LEN+2];	/* device name text to match */
    char	full_text[DIO_FULL_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    } DIO_DEPARTMENT_TO_DI_REQ;

typedef struct DIO_DEPARTMENT_TO_DI_REPLY
    {
    char		device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int			device_index;			/* device index */
    } __attribute__((packed)) DIO_DEPARTMENT_TO_DI_REPLY;

typedef struct DIO_MAINTAINER_TO_DI_REQ
    {
    char	maintainer_string[USER_NAME_LEN*4+2];		/* matching maintainer user name string */
    int		device_class;					/* device class */
    int		device_type;					/* device type */
    char	text_string[DIO_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    char	name_string[DIO_DEVICE_SEARCH_STRING_LEN+2];	/* matching name string */
    unsigned short	node;					/* front end node */
    char	full_name[DIO_FULL_NAME_SEARCH_STRING_LEN+2];	/* device name text to match */
    char	full_text[DIO_FULL_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    } __attribute__((packed)) DIO_MAINTAINER_TO_DI_REQ;

typedef struct DIO_MAINTAINER_TO_DI_REPLY
    {
    char		device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int			device_index;		/* device index */
    } __attribute__((packed)) DIO_MAINTAINER_TO_DI_REPLY;

typedef struct DIO_MACHINE_TO_DI_REQ
    {
    int		machine_id;					/* matching machine ID */
    int		device_class;					/* device class */
    int		device_type;					/* device type */
    char	text_string[DIO_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    char	name_string[DIO_DEVICE_SEARCH_STRING_LEN+2];	/* matching name string */
    unsigned short	node;					/* front end node */
    char	full_name[DIO_FULL_NAME_SEARCH_STRING_LEN+2];	/* device name text to match */
    char	full_text[DIO_FULL_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    } DIO_MACHINE_TO_DI_REQ;

typedef struct DIO_MACHINE_TO_DI_REPLY
    {
    char		device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int			device_index;			/* device index */
    } __attribute__((packed)) DIO_MACHINE_TO_DI_REPLY;

typedef struct DIO_AREA_TO_DI_REQ
    {
    int		area_id;					/* matching area ID */
    int		device_class;					/* device class */
    int		device_type;					/* device type */
    char	text_string[DIO_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    char	name_string[DIO_DEVICE_SEARCH_STRING_LEN+2];	/* matching name string */
    char	full_name[DIO_FULL_NAME_SEARCH_STRING_LEN+2];	/* device name text to match */
    char	full_text[DIO_FULL_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    } DIO_AREA_TO_DI_REQ;

typedef struct DIO_AREA_TO_DI_REPLY
    {
    char		device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int			device_index;			/* device index */
    } __attribute__((packed)) DIO_AREA_TO_DI_REPLY;

typedef struct DIO_LOGGER_DEVICE_TO_DIPI_REQ
    {
    int		invert;						/* invert the sense of the query */
    char	name_string[DIO_DEVICE_SEARCH_STRING_LEN+2];	/* matching name string */
    char	text_string[DIO_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    short	property;					/* property */
    unsigned short	node;					/* data logger node */
    char	list_data_event[DATA_EVENT_MAX_LEN];		/* collection data event */
    int		list_id;					/* list ID (-1 means any) */
    int		device_class;					/* device class */
    int		device_type;					/* device type */
    char	full_name[DIO_FULL_NAME_SEARCH_STRING_LEN+2];	/* device name text to match */
    char	full_text[DIO_FULL_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    } __attribute__((packed)) DIO_LOGGER_DEVICE_TO_DIPI_REQ;

typedef struct DIO_LOGGER_DEVICE_TO_DIPI_REPLY
    {
    int			device_index;		/* device index */
    unsigned char	property_index;		/* property index */
    unsigned char	unused;
    } __attribute__((packed)) DIO_LOGGER_DEVICE_TO_DIPI_REPLY;


#define	DIO_NOVA_SCHEMA_NAME_LEN	32

typedef struct DIO_NOVA_ARCHIVER_TO_NAME_REQ
    {
    char	schema_name[DIO_NOVA_SCHEMA_NAME_LEN+2];	/* matching schema name */
    char	name_string[DIO_DEVICE_SEARCH_STRING_LEN+2];	/* matching name string */
    } DIO_NOVA_ARCHIVER_TO_DIPI_REQ;

#define	NOVA_ARCHIVER_DEVICE_NAME_LEN	80

typedef struct DIO_NOVA_ARCHIVER_TO_NAME_REPLY
    {
    char	device_name[NOVA_ARCHIVER_DEVICE_NAME_LEN];	/* device name */
    } __attribute__((packed)) DIO_NOVA_ARCHIVER_TO_NAME_REPLY;

typedef struct DIO_ADDRESSING_MODE_TO_DIPI_REQ
    {
    int		addressing_mode;				/* matching addressing mode */
    int		device_class;					/* device class */
    int		device_type;					/* device type */
    char	text_string[DIO_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    char	name_string[DIO_DEVICE_SEARCH_STRING_LEN+2];	/* matching name string */
    unsigned short	node;					/* front end node */
    char	full_name[DIO_FULL_NAME_SEARCH_STRING_LEN+2];	/* full device name text to match */
    char	full_text[DIO_FULL_TEXT_SEARCH_STRING_LEN+2];	/* full device text to match */
    } DIO_ADDRESSING_MODE_TO_DIPI_REQ;

typedef struct DIO_ADDRESSING_MODE_TO_DIPI_REPLY
    {
    char		device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int			device_index;		/* device index */
    unsigned char	property_index;		/* property index */
    unsigned char	unused;
    } __attribute__((packed)) DIO_ADDRESSING_MODE_TO_DIPI_REPLY;

typedef struct DIO_GENERIC_SEARCH_TO_DIPI_REQ
    {
    char	name_string[DIO_DEVICE_SEARCH_STRING_LEN+2];	/* matching name string */
    char	full_name[DIO_FULL_NAME_SEARCH_STRING_LEN+2];	/* device name text to match */
    char	text_string[DIO_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    char	full_text[DIO_FULL_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    char	node_string[NODE_NAME_LEN+2];
    unsigned short	node;					/* front end node */
    int		node_system_type;				/* node system type */
    int		node_software_type;				/* node software type */
    int		node_area_type;					/* node area type */
    int		node_status_type;				/* node status type */
    int		device_class;					/* device class */
    int		device_type;					/* device type */
    unsigned short	num_properties;				/* number of properties */
    unsigned char	property_indices[DIO_WILDCARD_NODE_PIS_MAX_PROPERTIES];	/* requested properties */
    int		search_for_simple_alarm_list;
    int		alarm_list_number;				/* alarm list ID number */
    int		search_for_analog_alarm_handler;
    int		search_for_digital_alarm_handler;
    int		alarm_handler;
    int		save_list_number;				/* save list ID number */
    int		search_for_restore_code;
    int		restore_code;					/* restore handler code */
    int		search_for_restore_subcode;
    int		restore_subcode;				/* restore handler subcode */
    int		search_for_display_code;
    int		display_code;					/* display handler code */
    unsigned int	console_class_mask;			/* mask of console class mask bits to check for */
    unsigned int	console_class;				/* console class mask */
    unsigned short	default_ftd;				/* default FTD */
    char	ssdn_compare_byte[LEN_SSDN];			/* compare flags */
    unsigned char	ssdn[LEN_SSDN];				/* SSDN to match */
    int		vm_device_index;				/* virtual machine device index */
    int		search_for_data_type;
    int		data_type;					/* property data type */
    int		search_for_primary_transform;
    int		primary_transform_index;			/* primary transform index */
    int		search_for_common_transform;
    int		common_transform_index;				/* common transform index */
    char	units_text[2*LEN_DEV_UNITS+2];			/* units text */
    int		units_type;					/* type of units */
    char	department_string[64*2+2];			/* matching department name string */
    char	maintainer_string[USER_NAME_LEN*4+2];		/* matching maintainer user name string */
    char	struct_class_string[STRUCT_CLASS_NAME_LEN*2+2];	/* matching class name string */
    char	struct_name_string[STRUCT_NAME_LEN*2+2];	/* matching structure name string */
    int		foreign_system_type;				/* foreign device system type */
    char	foreign_device_name[DIO_FULL_NAME_SEARCH_STRING_LEN+2];	/* foreign device name text to match */
    int		crate;						/* crate */
    int		slot;						/* slot */
    int		madc;						/* MADC */
    } DIO_GENERIC_SEARCH_TO_DIPI_REQ;

typedef struct DIO_GENERIC_SEARCH_TO_DIPI_REPLY
    {
    char		device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int			device_index;		/* device index */
    unsigned char	property_index;		/* property index */
    unsigned char	unused;
    } __attribute__((packed)) DIO_GENERIC_SEARCH_TO_DIPI_REPLY;

typedef struct DIO_ACTUAL_ALARM_LIST_TO_DI_REQ
    {
    int		list_number;					/* alarm list ID number */
    short	property;					/* property or alarm type */
    char	name_string[DIO_DEVICE_SEARCH_STRING_LEN+2];	/* matching name string */
    char	text_string[DIO_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    unsigned short	node;					/* front end node */
    int		device_class;					/* device class */
    int		device_type;					/* device type */
    char	full_name[DIO_FULL_NAME_SEARCH_STRING_LEN+2];	/* device name text to match */
    char	full_text[DIO_FULL_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    } DIO_ACTUAL_ALARM_LIST_TO_DI_REQ;

typedef struct DIO_ACTUAL_ALARM_LIST_TO_DI_REPLY
    {
    int		device_index;			/* device index */
    } __attribute__((packed)) DIO_ACTUAL_ALARM_LIST_TO_DI_REPLY;

typedef struct DIO_ALARM_GROUP_TO_DI_REQ
    {
    int		alarm_group;					/* alarm group number */
    short	property;					/* property or alarm type */
    char	name_string[DIO_DEVICE_SEARCH_STRING_LEN+2];	/* matching name string */
    char	text_string[DIO_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    unsigned short	node;					/* front end node */
    int		device_class;					/* device class */
    int		device_type;					/* device type */
    char	full_name[DIO_FULL_NAME_SEARCH_STRING_LEN+2];	/* device name text to match */
    char	full_text[DIO_FULL_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    } DIO_ALARM_GROUP_TO_DI_REQ;

typedef struct DIO_ALARM_GROUP_TO_DI_REPLY
    {
    char	device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int		device_index;			/* device index */
    } __attribute__((packed)) DIO_ALARM_GROUP_TO_DI_REPLY;

typedef struct DIO_ALARM_CONSOLIDATOR_TO_DI_REQ
    {
    char	name_string[DIO_DEVICE_SEARCH_STRING_LEN+2];	/* matching name string */
    char	text_string[DIO_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    char	full_name[DIO_FULL_NAME_SEARCH_STRING_LEN+2];	/* device name text to match */
    char	full_text[DIO_FULL_TEXT_SEARCH_STRING_LEN+2];	/* device text to match */
    } DIO_ALARM_CONSOLIDATOR_TO_DI_REQ;

typedef struct DIO_ALARM_CONSOLIDATOR_TO_DI_REPLY
    {
    char	device_name[DEVICE_TERSE_NAME_LEN];	/* device name */
    int		device_index;			/* device index */
    } __attribute__((packed)) DIO_ALARM_CONSOLIDATOR_TO_DI_REPLY;

typedef struct DIO_PROPERTY_FLAGS_DATA		/* property flags information structure */
    {
    int		is_step_motor;			/* is step motor flag */
    int		is_destructive_read;		/* is destructive reading flag */
    int		is_fe_scaling;			/* let front end do the scaling flag */
    int		is_controlled_setting;		/* is controlled setting flag */
    int		is_not_knobable;		/* is not knobable flag */
    int		spare3;				/* spare flag */
    int		spare2;				/* spare flag */
    int		spare;				/* spare flag */
    } __attribute__((packed)) DIO_PROPERTY_FLAGS_DATA;

typedef struct DIO_SR_SPEC
    {
    int		file_number;			/* save/restore file source to populate from */
    } __attribute__((packed)) DIO_SR_SPEC;

typedef struct DIO_SDA_SPEC
    {
    int		file_number;			/* SDA file source to populate from */
    int		case_number;			/* SDA case number */
    int		subcase_number;			/* SDA subcase number */
    int		usage_number;			/* SDA usage number */
    int		try_number;			/* SDA try number */
    } __attribute__((packed)) DIO_SDA_SPEC;

typedef struct DIO_DL_SPEC
    {
    int		node;				/* Lumberjack source node */
    clib_time_t	start_time;			/* requested starting data time stamp in seconds since January 1, 1970 */
    unsigned int	accuracy;		/* allowable variance from start time in seconds */
    } __attribute__((packed)) DIO_DL_SPEC;

typedef struct DIO_MEMORY_SPEC
    {
    int		pool_id;			/* memory pool ID */
    int		auto_populate;			/* flag indicating whether or not to autopopulate on reads */
    } __attribute__((packed)) DIO_MEMORY_SPEC;

typedef struct DIO_SNAPMANAGER_SPEC
    {
    int		system_number;			/* snapshot manager system number */
    unsigned int	record_or_date;		/* record number or date */
    } __attribute__((packed)) DIO_SNAPMANAGER_SPEC;

#define	DIO_REDIRECT_MODEL_NAME_LEN	16

typedef struct DIO_MODEL_SPEC
    {
    char	model_name[DIO_REDIRECT_MODEL_NAME_LEN];
    int		model_node;			/* model node value */
    int		model_class;			/* model class value */
    } __attribute__((packed)) DIO_MODEL_SPEC;

typedef struct DIO_TEST_OAC_SPEC
    {
    int		normal_node;			/* normal node value */
    int		test_node;			/* test node value */
    } __attribute__((packed)) DIO_TEST_OAC_SPEC;

typedef struct DIO_SNAPSHOT_CLASS_DATA		/* snapshot class data */
    {
    unsigned int	max_points;		/* maximum number of points returned */
    unsigned int	max_frequency;		/* maximum frequency supported */
    int		supports_tc_7;			/* supports type codes 7 and 8 for access */
    int		has_timestamps;			/* returns timestamps */
    int		is_trigger;			/* is a snapshot trigger class */
    int		random;				/* random access read supported */
    int		supports_delay;			/* supports delay specification */
    int		fixed_frequency;		/* only available for a single frequency */
    unsigned int	auto_frequency;		/* auto frequency */
    } __attribute__((packed)) DIO_SNAPSHOT_CLASS_DATA;

typedef struct DIO_SNAPSHOT_POINT		/* one point of snapshot data */
    {
    float	timestamp;			/* timestamp value in 100 usec units */
    float	value;				/* value in engineering units */
    } __attribute__((packed)) DIO_SNAPSHOT_POINT;

typedef struct DIO_RAW_SNAPSHOT_POINT		/* one point of raw snapshot data */
    {
    float	timestamp;			/* timestamp value in 100 usec units */
    unsigned int	value;			/* value in raw units */
    } __attribute__((packed)) DIO_RAW_SNAPSHOT_POINT;

typedef struct DIO_FTP_CLASS_DATA		/* fast time plot class data */
    {
    unsigned int	max_frequency;		/* maximum frequency supported */
    int		supports_tc_6;			/* supports type code 6 for access */
    } __attribute__((packed)) DIO_FTP_CLASS_DATA;

typedef struct DIO_FTP_POINT			/* one point of fast time plot data */
    {
    float	timestamp;			/* timestamp value in seconds */
    unsigned int	timestamp_100usec;	/* timestamp value in 100 usec units */
    unsigned short	raw_timestamp;		/* raw timestamp in 100 usec units */
    float	value;				/* value in engineering units */
    } __attribute__((packed)) DIO_FTP_POINT;

typedef struct DIO_RAW_FTP_POINT		/* one point of raw fast time plot data */
    {
    float	timestamp;			/* timestamp value in seconds */
    unsigned int	timestamp_100usec;	/* timestamp value in 100 usec units */
    unsigned short	raw_timestamp;		/* raw timestamp in 100 usec units */
    unsigned int	value;			/* value in raw units */
    } __attribute__((packed)) DIO_RAW_FTP_POINT;

#define	DIO_FTP_ON_OFF_MASK		1
#define	DIO_FTP_READY_TRIPPED_MASK	2
#define	DIO_FTP_REMOTE_LOCAL_MASK	4
#define	DIO_FTP_POSITIVE_NEGATIVE_MASK	8
#define	DIO_FTP_RAMP_DC_MASK		0x10

typedef struct DIO_STATUS_FTP_POINT		/* one point of basic status fast time plot data */
    {
    float	timestamp;			/* timestamp value in seconds */
    unsigned int	timestamp_100usec;	/* timestamp value in 100 usec units */
    unsigned short	raw_timestamp;		/* raw timestamp in 100 usec units */
    int		status_value;			/* status value (bit mask) */
    int		on_off_value;			/* on/off status value */
    int		ready_tripped_value;		/* ready/tripped status value */
    int		remote_local_value;		/* remote/local status value */
    int		positive_negative_value;	/* positive/negative status value */
    int		ramp_dc_value;			/* ramp/DC status value */
    } __attribute__((packed)) DIO_STATUS_FTP_POINT;

typedef struct DIO_OLD_FTP_DEVICE_REQUEST
    {
    int		dipi;				/* packed device index / property */
    char	ssdn[LEN_SSDN];			/* device SSDN */
    short	sample_period;			/* device sample period (10 usec units) */
    } __attribute__((packed)) DIO_OLD_FTP_DEVICE_REQUEST;

typedef struct DIO_OLD_FTP_REQUEST		/* Fast Time Plot request (old style) */
    {
    short	type_code_and_priority;		/* request type code (2) (priority in upper 2 bits) */
    int		rad50_task_name;		/* RAD50 task name */
    char	num_devices;			/* number of devices */
    char	current_time_15hz;		/* time since event 02 in 15 Hz ticks */
    short	return_period_15hz;		/* reply return period in 15 Hz ticks */
    short	max_return_words;		/* maximum reply size in words */
    short	data_return_reference;		/* event or group of events to trigger return of data (not used) */
    short	start_return_time_15hz;		/* time (in 15 Hz ticks) to start returning data after the reference event (not used) */
    short	stop_return_time_15hz;		/* time (in 15 Hz ticks) to stop returning data (not used) */
    DIO_OLD_FTP_DEVICE_REQUEST	devices[1];	/* devices to plot */
    } __attribute__((packed)) DIO_OLD_FTP_REQUEST;

typedef struct DIO_FTP_DEVICE_REQUEST
    {
    int		dipi;				/* packed device index / property */
    int		offset;				/* device offset in bytes */
    char	ssdn[LEN_SSDN];			/* device SSDN */
    short	sample_period;			/* device sample period (10 usec units) */
    short	spare[2];
    } __attribute__((packed)) DIO_FTP_DEVICE_REQUEST;

typedef struct DIO_FTP_REQUEST			/* Fast Time Plot request */
    {
    short	type_code;			/* request type code (6) */
    int		rad50_task_name;		/* RAD50 task name */
    short	num_devices;			/* number of devices */
    short	return_period_15hz;		/* reply return period in 15 Hz ticks */
    short	max_return_words;		/* maximum reply size in words */
    short	data_return_reference;		/* event or group of events to trigger return of data (not used) */
    short	start_return_time_15hz;		/* time (in 15 Hz ticks) to start returning data after the reference event (not used) */
    short	stop_return_time_15hz;		/* time (in 15 Hz ticks) to stop returning data (not used) */
    short	priority;			/* plot priority (default is 0) */
    short	current_time_15hz;		/* time since event 02 in 15 Hz ticks */
    short	spare[5];
    DIO_FTP_DEVICE_REQUEST	devices[1];	/* devices to plot */
    } __attribute__((packed)) DIO_FTP_REQUEST;

typedef struct DIO_FTP_FIRST_REPLY		/* Fast Time Plot first reply */
    {
    short	overall_status;			/* overall status of request */
    short	type_code;			/* type code (1) */
    short	status[1];			/* status for each requested device */
    } __attribute__((packed)) DIO_FTP_FIRST_REPLY;

typedef struct DIO_FTP_DEVICE_REPLY
    {
    short	status;				/* status for this device */
    short	data_pointer;			/* offset in bytes from the start of the reply buffer to the data for this device */
    short	num_points;			/* number of points returned */
    } __attribute__((packed)) DIO_FTP_DEVICE_REPLY;

typedef struct DIO_FTP_DATA_REPLY		/* Fast Time Plot data reply */
    {
    short	overall_status;			/* overall status of request */
    short	type_code;			/* type code (2) */
    short	unused[2];
    DIO_FTP_DEVICE_REPLY	devices[1];	/* reply information for each requested device */
    } __attribute__((packed)) DIO_FTP_DATA_REPLY;

typedef struct DIO_STATUS_DATA			/* basic status data */
    {
    char	on;				/* on/off status */
    char	ready;				/* ready/tripped status */
    char	remote;				/* remote/local status */
    char	polarity;			/* polarity status */
    char	ramping;			/* ramp/DC status */
    } __attribute__((packed)) DIO_STATUS_DATA;

/* Structures used by dio_find_devices to return results */
struct dio_find_devices_match_t {
	int         di;
	std::string name;
	std::string full_name;
	std::string description;
	std::string full_description;
	bool        name_matched;
	bool        full_name_matched;
	bool        description_matched;
	bool        full_description_matched;
};
typedef std::vector<dio_find_devices_match_t> dio_find_devices_matches_t;

#define	LOGGER_SHORT_DEVICE_NAME_LEN	12	/* "old" logger network message device name length */

typedef struct LOGGER_DATA
    {
    short 	tc_or_status;			/* request typecode or status return */
    short 	num_devices;			/* number of devices */
    short 	num_points;			/* number of points to return or returned */
    short 	min_delta_time;			/* min seconds between points */
    unsigned int	start_time;		/* start time data sample */
    unsigned int	stop_time;		/* stop time data sample */
    unsigned int	first_time;		/* time of first data sample */
    char	device_names[5][LOGGER_SHORT_DEVICE_NAME_LEN];	/* up to 5 device names */
    unsigned int	data[1];		/* start of data return */
    } __attribute__((packed)) LOGGER_DATA;

#define	LOGGER_DEVICE_NAME_LEN	32
#define	LOGGER_DATA_EVENT_LEN	252

typedef struct LOGGER_REQUEST_DEVICE_DATA
    {
    short 	request_type_code;		/* request typecode */
    int 	num_points;			/* number of points to return */
    int 	min_delta_time;			/* minimum number of seconds between points */
    int		num_points_to_skip;		/* number of points to skip */
    int		skip_offset;			/* index of first point to return */
    char	data_event[LOGGER_DATA_EVENT_LEN];	/* data acquisition data event to return */
						/* (blank or null string means any) */
    int		list_id;			/* list ID (-1 means any) */
    unsigned int	start_time;		/* start time data sample */
    unsigned int	start_nanoseconds;	/* start time fraction of a second */
    unsigned int	stop_time;		/* stop time data sample */
    unsigned int	stop_nanoseconds;	/* stop time fraction of a second */
    unsigned int	seed_time;		/* seed time for data sample (starts at 0) */
    unsigned int	seed_nanoseconds;	/* seed time fraction of a second */
    char	device_name[LOGGER_DEVICE_NAME_LEN];	/* device name */
    } __attribute__((packed)) LOGGER_REQUEST_DEVICE_DATA;

typedef struct LOGGER_STATUS_VALUE
    {
    unsigned int	raw_status;
    char	on_off;				/* -1 -> no on/off attribute */
    char	ready_tripped;			/* -1 -> no ready/tripped attribute */
    char	local_remote;			/* -1 -> no local/remote attribute */
    char	polarity;			/* -1 -> no polarity attribute */
    } __attribute__((packed)) LOGGER_STATUS_VALUE;

typedef struct LOGGER_POINT
    {
    unsigned long long	timestamp;		/* timestamp in milliseconds */
    union					/* data value */
	{
	double	scaled_value;
	LOGGER_STATUS_VALUE	status_value;
	} value;
    } __attribute__((packed)) LOGGER_POINT;

typedef struct LOGGER_REPLY_DEVICE_DATA
    {
    short	status;				/* returned status */
    int		num_points;			/* number of points returned */
    char	device_name[LOGGER_DEVICE_NAME_LEN];	/* device name */
    unsigned int	seed_time;		/* seed time for data sample (starts at 0) */
    unsigned int	seed_nanoseconds;	/* seed time fraction of a second */
    LOGGER_POINT	points[1];		/* returned points */
    } __attribute__((packed)) LOGGER_REPLY_DEVICE_DATA;

typedef struct LOGGER_UPDATE_DATA
    {
    int		device_index;			/* device index */
    int		property;			/* property index */
    unsigned int	total_points;		/* total number of points read */
    unsigned int	last_timestamp;		/* timestamp of last point read */
    } __attribute__((packed)) LOGGER_UPDATE_DATA;

typedef struct LOGGER_UPDATE_DATA_BY_NAME
    {
    char	device_name[LONG_DEVICE_NAME_LEN+2];	/* device name */
    unsigned int	total_points;		/* total number of points read */
    unsigned int	last_timestamp;		/* timestamp of last point read */
    } __attribute__((packed)) LOGGER_UPDATE_DATA_BY_NAME;

#define	LOGGER_LIST_NAME_LEN	8		/* length of a Lumberjack list name */
#define	LOGGER_NODE_NAME_LEN	6		/* length of a Lumberjack node name */

typedef struct LOGGER_SEARCH_DATA
    {
    unsigned int	node;			/* node */
    unsigned int	historic_id;		/* historic Lumberjack index */
    char	list_name[LOGGER_LIST_NAME_LEN];	/* list name */
    int		rate;				/* milliseconds between collections */
    char	list_data_event[DATA_EVENT_MAX_LEN];	/* collection data event */
    char	node_name[LOGGER_NODE_NAME_LEN];	/* Lumberjack node name */
    char	device_name[C_STYLE_LONG_DEVICE_NAME_LEN];	/* device name */
    int		list_id;			/* list ID */
    int		display_index;			/* display index of device in database */
    } __attribute__((packed)) LOGGER_SEARCH_DATA;

typedef struct LOGGER_SEARCH_LIST_DATA
    {
    unsigned int	node;			/* node */
    char	node_name[LOGGER_NODE_NAME_LEN];	/* Lumberjack node name */
    int		list_id;			/* list ID (0-17) */
    char	list_name[LOGGER_LIST_NAME_LEN];	/* list name */
    int		column;				/* list column (0-4) */
    char	list_data_event[DATA_EVENT_MAX_LEN];	/* collection data event */
    } __attribute__((packed)) LOGGER_SEARCH_LIST_DATA;

typedef struct LOGGER_SEARCH_DELETED_DATA
    {
    unsigned int	node;			/* node */
    char	node_name[LOGGER_NODE_NAME_LEN+2];	/* Lumberjack node name */
    int		list_id;			/* list ID */
    char	list_data_event[DATA_EVENT_MAX_LEN+2];	/* collection data event */
    char	device_name[C_STYLE_LONG_DEVICE_NAME_LEN+2];	/* device name */
    int		device_index;
    int		property;
    int		array_index;
    int		num_elements;
    int		whole_property;
    char	user_name[USER_NAME_LEN+2];	/* user name of user who deleted the device */
    unsigned int	delete_date;		/* date device was deleted */
    } __attribute__((packed)) LOGGER_SEARCH_DELETED_DATA;

#define	LOGGER_NUM_SUB_DATA_EVENTS	5	/* number of sub data events per list */
#define	LOGGER_NUM_SUPPORTED_PROPERTIES	3	/* number of loggable properties */

typedef struct LOGGER_LIST_DATA
    {
    char	node_name[LOGGER_NODE_NAME_LEN+2];	/* Lumberjack node name */
    unsigned int	node;			/* node */
    unsigned int	historic_id;		/* historic Lumberjack index */
    int		list_id;			/* list ID */
    char	list_name[LOGGER_LIST_NAME_LEN+2];	/* list name */
    int		logger_rate;			/* logger rate (0->fast, 1->normal, 2->slow) */
    char	list_data_event[DATA_EVENT_MAX_LEN+2];	/* collection data event */
    int		use_sub_data_events;		/* flag indicating whether or not sub data events are used */
    char	sub_data_events[LOGGER_NUM_SUB_DATA_EVENTS][DATA_EVENT_MAX_LEN+2];	/* collection data event */
    unsigned int	max_values;		/* maximum number of values list can hold */
    unsigned int	num_devices;		/* number of devices in list */
    unsigned int	num_values;		/* number of values in list */
    unsigned int	max_values_per_device;	/* maximum number of values for a device */
    unsigned int	min_array_index;	/* minimum array index for a device */
    unsigned int	max_array_index;	/* maximum array index for a device */
    int		has_reading_property;
    int		has_setting_property;
    int		has_status_property;
    } __attribute__((packed)) LOGGER_LIST_DATA;

typedef struct LOGGER_LIST_DEVICE_STATS_DATA
    {
    unsigned int	num_devices;		/* number of devices in list */
    unsigned int	num_values;		/* number of values in list */
    unsigned int	max_values_per_device;	/* maximum number of values for a device */
    unsigned int	min_array_index;	/* minimum array index for a device */
    unsigned int	max_array_index;	/* maximum array index for a device */
    int		has_reading_property;
    int		has_setting_property;
    int		has_status_property;
    } __attribute__((packed)) LOGGER_LIST_DEVICE_STATS_DATA;

typedef struct LOGGER_LIST_DAQ_STATS_DATA
    {
    char	device_name[DEVICE_TERSE_NAME_LEN+2];	/* device name */
    int		device_index;
    short	property;
    int		array_index;
    unsigned int	num_successful_readings;	/* number of successful readings */
    double	last_reading;			/* last successful reading value */
    unsigned int	num_errors;		/* number of errors */
    int		last_error;			/* last error */
    unsigned int	last_update_time;	/* last update time (seconds since midnight) */
    } __attribute__((packed)) LOGGER_LIST_DAQ_STATS_DATA;

typedef struct LOGGER_DEVICE_LOG_DATA
    {
    unsigned int	node;			/* node */
    unsigned int	historic_id;		/* historic Lumberjack index */
    char	list_name[LOGGER_LIST_NAME_LEN];	/* list name */
    int		rate;				/* milliseconds between collections */
    char	list_data_event[DATA_EVENT_MAX_LEN];	/* collection data event */
    char	node_name[LOGGER_NODE_NAME_LEN];	/* Lumberjack node name */
    char	device_name[C_STYLE_LONG_DEVICE_NAME_LEN];	/* device name */
    int		list_id;			/* list ID */
    int		display_index;			/* display index of device in database */
    int		start_index;			/* starting array index */
    int		end_index;			/* ending array index */
    int		array_retrieval;		/* True if is QRay or BigRay, otherwise False */
    } __attribute__((packed))  LOGGER_DEVICE_LOG_DATA;

typedef struct LOGGER_LIST_DATA_EVENT_INFO
    {
    int		list_id;				/* list ID */
    char	list_data_event[DATA_EVENT_MAX_LEN+2];	/* collection data event */
    int		start_index;				/* starting index in the list */
    int		num_devices;				/* number of devices with this data event */
    } __attribute__((packed)) LOGGER_LIST_DATA_EVENT_INFO;

typedef struct LOGGER_DEVICE_ENTRY_DATA		/* logged device entry data */
    {
    char	device_name[LOGGER_DEVICE_NAME_LEN+2];	/* device name */
    char	data_event[LOGGER_DATA_EVENT_LEN+2];	/* data acquisition data event */
    int		list_id;			/* list ID */
    } __attribute__((packed)) LOGGER_DEVICE_ENTRY_DATA;

#define	TEXT_TYPE_NONE			0	/* no text */
#define	TEXT_TYPE_ASCII			1	/* ASCII text */
#define	TEXT_TYPE_COLOR_CODED		2	/* color coded (XCHAR format) text */

typedef struct TEXT_BLOCK_DATA			/* text block description structure */
    {
    int		text_type;			/* type of text */
    int		num_rows;			/* number of rows of text */
    int		num_columns;			/* number of columns of text */
    int		num_characters;			/* total number of characters */
    void	*text;				/* text block */
    int		free_text;			/* flag indicating if caller can free text */
    } __attribute__((packed)) TEXT_BLOCK_DATA;

#define	SYSTEM_PROCESS_NAME_LEN		128	/* length of a process name */

typedef struct PROCESS_INFO_DATA
    {
    char		process_name[SYSTEM_PROCESS_NAME_LEN+1];	/* process name */
    char		user_name[USER_NAME_LEN+2];	/* process user name */
    unsigned int	process_startup_time;	/* time that process was started in clinks */
    unsigned int	remaining_memory;	/* memory remaining in bytes */
    unsigned int	memory_quota;		/* memory quota for this process */
    unsigned int	peak_memory_size; 	/* peak virtual memory size for this process */
    unsigned int	current_physical_memory;	/* current physical memory for this process */
    unsigned int	default_physical_memory;	/* default physical memory for this process */
    unsigned int	physical_memory_quota;	/* physical memory quota for this process */
    unsigned int	physical_memory_limit;	/* maximum physical memory for this process */
    unsigned int	peak_physical_memory;	/* peak physical memory for this process */
    unsigned int	shared_memory;		/* shared memory used by this process */
    unsigned int	num_page_faults;	/* number of page faults */
    unsigned int	current_priority;	/* current process priority */
    unsigned int	base_priority;		/* base process priority */
    unsigned int	cpu_time;		/* CPU time used by process in 10 millisecond ticks */
    unsigned int	cpu_time_limit;		/* CPU time limit for this process */
    unsigned int	remaining_open_file_quota;	/* remaining open file quota for this process */
    unsigned int	open_file_quota;	/* open file quota for this process */
    unsigned int	remaining_buffered_io_byte_count;	/* remaining buffered I/O byte count quota for this process */
    unsigned int	buffered_io_byte_count_quota;	/* buffered I/O byte count quota for this process */
    unsigned int	remaining_buffered_io;	/* remaining buffered I/O quota for this process */
    unsigned int	buffered_io_quota;	/* buffered I/O quota for this process */
    unsigned int	remaining_direct_io;	/* remaining direct I/O quota for this process */
    unsigned int	direct_io_quota;	/* direct I/O quota for this process */
    unsigned int	remaining_lock_quota;	/* remaining lock request quota for this process */
    unsigned int	lock_quota;		/* lock request quota for this process */
    unsigned int	remaining_timer_quota;	/* remaining timer queue entry quota for this process */
    unsigned int	timer_quota;		/* timer queue entry quota for this process */
    unsigned int	process_id;		/* process ID */
    } __attribute__((packed)) PROCESS_INFO_DATA;

typedef struct ANALOG_ALARM_BLOCK
    {
    unsigned short	flags;			/* flag word */
    int			minimum;		/* minimum or nominal */
    int			maximum;		/* maximum or tolerance */
    unsigned char	tries_now;		/* times out of tolerance */
    unsigned char	tries_needed;		/* times needed for alarm */
    unsigned char	global_event_2;
    unsigned char	global_event_1;
    unsigned char	specific_info[6];	/* front end specific data */
    } __attribute__((packed)) ANALOG_ALARM_BLOCK;

typedef struct DIGITAL_ALARM_BLOCK
    {
    unsigned short	flags;			/* flag word */
    int			nominal;		/* nominal value */
    int			mask;			/* bitwise mask */
    unsigned char	tries_now;		/* times out of tolerance */
    unsigned char	tries_needed;		/* times needed for alarm */
    unsigned char	global_event_2;
    unsigned char	global_event_1;
    unsigned char	specific_info[6];	/* front end specific data */
    } __attribute__((packed)) DIGITAL_ALARM_BLOCK;

typedef struct FIND_CHANGE_DATA			/* find/change information structure */
    {
    short	key1;		/* for find_routine, it indicates:
				   current number of the found item;
				   key1 = 0: first call or initialize; 
				   key1 = -1: can't find. */ 

    short	key2;		/* for change_routine, it indicates:
				   how many items are changed; key2 =0:
				   first call or initialize; */ 

    char    search_string[80];	/* the string user wants to find, 
				   which is read from window. */
    char    found_string[80];	/* return the found string(the length 
				   is maxlen). */
    char    change_string[80];	/* the string user wants to change to
				   which is read from window. */
    } __attribute__((packed)) FIND_CHANGE_DATA;

#define	LOCK_MAX_NAME_LEN	64		/* maximum lock name length */
#define	LOCK_OWNER_NAME_LEN	16		/* maximum lock owner name length */

typedef struct LOCK_ENTRY_DATA			/* lock entry information */
    {
    unsigned int	time_locked;
    int		ip_node;
    int		process_id;
    char	owner[LOCK_OWNER_NAME_LEN+2];
    short	acnet_node;
    int		slot;
    } __attribute__((packed)) LOCK_ENTRY_DATA;

typedef struct PROGRAM_LOCK_ENTRY_DATA		/* program lock entry information */
    {
    char	lock_name[LOCK_MAX_NAME_LEN+2];
    unsigned int	time_locked;
    int		ip_node;
    int		process_id;
    short	acnet_node;
    int		console;
    int		slot;
    } __attribute__((packed)) PROGRAM_LOCK_ENTRY_DATA;

typedef struct STATE_VALUE
    {
    int		vm_device_index;
    int		state_number;
    } __attribute__((packed)) STATE_VALUE;

#define	SDA_USAGE_NAME_LEN		30	/* length of an SDA usage string */

typedef struct SDA_CASE_VALUE
    {
    int		usage_number;
    int		case_number;
    int		subcase_number;
    int		try_number;
    } __attribute__((packed)) SDA_CASE_VALUE;

typedef struct SDA_FILE_VALUE
    {
    int		usage_number;
    int		file_number;
    int		case_number;
    int		subcase_number;
    int		try_number;
    } __attribute__((packed)) SDA_FILE_VALUE;

#define	SDA_CONFIG_DEVICE_DATA_EVENT_LEN	20
#define	SDA_CONFIG_USER_NAME_LEN	20

typedef struct SDA_CONFIG_DEVICE_DATA
    {
    int		device_index;
    int		property;
    int		length;
    int		offset;
    char	data_event[SDA_CONFIG_DEVICE_DATA_EVENT_LEN];
    int		usage_no;
    int		case_no;
    char	added_by[SDA_CONFIG_USER_NAME_LEN];
    unsigned int	added_date;
    char	modified_by[SDA_CONFIG_USER_NAME_LEN];
    unsigned int	modified_date;
    } __attribute__((packed)) SDA_CONFIG_DEVICE_DATA;

#define	SDA_CONFIG_PLOT_DATA_EVENT_LEN	254

typedef struct SDA_CONFIG_PLOT_DATA
    {
    int		device_index;
    int		property;
    int		array_index;
    int		is_ftp;
    int		pretriggered;
    char	data_event[SDA_CONFIG_PLOT_DATA_EVENT_LEN];
    int		usage_no;
    int		case_no;
    char	added_by[SDA_CONFIG_USER_NAME_LEN];
    unsigned int	added_date;
    char	modified_by[SDA_CONFIG_USER_NAME_LEN];
    unsigned int	modified_date;
    } __attribute__((packed)) SDA_CONFIG_PLOT_DATA;

#define	SDA_CONFIG_CASE_NAME_LEN	64
#define	SDA_CONFIG_CASE_DESCRIPTION_LEN	127
#define	SDA_CONFIG_CASE_DATA_EVENT_LEN	127

typedef struct SDA_CONFIG_CASE_DATA
    {
    int		case_number;
    char	case_name[SDA_CONFIG_CASE_NAME_LEN];
    char	case_description[SDA_CONFIG_CASE_DESCRIPTION_LEN];
    int		num_subcases;
    int		multiple_collections;
    int		multiple_sets;
    int		concurrent_allowed;
    char	arm_events[2][SDA_CONFIG_CASE_DATA_EVENT_LEN];
    char	set_events[2][SDA_CONFIG_CASE_DATA_EVENT_LEN];
    char	disarm_events[2][SDA_CONFIG_CASE_DATA_EVENT_LEN];
    char	end_events[2][SDA_CONFIG_CASE_DATA_EVENT_LEN];
    } __attribute__((packed)) SDA_CONFIG_CASE_DATA;

typedef struct SDA_FTP_POINT			/* one point of fast time plot data from SDA */
    {
    float	timestamp;			/* timestamp value in seconds */
    unsigned int	timestamp_100usec;	/* timestamp value in 100 usec units */
    long long	raw_timestamp;			/* raw timestamp in microseconds */
    double	value;				/* value in engineering units */
    } __attribute__((packed)) SDA_FTP_POINT;

typedef struct SDA_RAW_FTP_POINT		/* one point of fast time plot data from SDA */
    {
    float	timestamp;			/* timestamp value in seconds */
    unsigned int	timestamp_100usec;	/* timestamp value in 100 usec units */
    long long	raw_timestamp;			/* raw timestamp in microseconds */
    unsigned int	value;			/* value in raw units */
    } __attribute__((packed)) SDA_RAW_FTP_POINT;

typedef struct SDA_SNAPSHOT_POINT		/* one point of snapshot data form SDA */
    {
    float	timestamp;			/* timestamp value in 100 usec units */
    unsigned int	timestamp_100usec;	/* timestamp value in 100 usec units */
    long long	raw_timestamp;			/* raw timestamp in microseconds */
    unsigned short	nanoseconds;		/* nanoseconds past the most recent microsecond */
    double	value;				/* value in engineering units */
    } __attribute__((packed)) SDA_SNAPSHOT_POINT;

typedef struct SDA_RAW_SNAPSHOT_POINT		/* one point of snapshot data form SDA */
    {
    float	timestamp;			/* timestamp value in 100 usec units */
    unsigned int	timestamp_100usec;	/* timestamp value in 100 usec units */
    long long	raw_timestamp;			/* raw timestamp in microseconds */
    unsigned short	nanoseconds;		/* nanoseconds past the most recent microsecond */
    unsigned int	value;			/* value in raw units */
    } __attribute__((packed)) SDA_RAW_SNAPSHOT_POINT;

#define	GENMESS_TC_REMOTE_PROGRAM	1	/* generic message type code for remote program messages */

#define	GENMESS_TYPE_REQRPLY		0	/* normal REQuest/RePLY message */
#define	GENMESS_TYPE_USM		1	/* UnSolicited Message */
#define	GENMESS_TYPE_MCAST		2	/* MultiCAST message */

#define	REMPGM_TC_SCRIPT		1	/* remote program script request */
#define	REMPGM_TC_METHOD		2	/* remote program method request */
#define	REMPGM_TC_SCRIPT_LIST		3	/* remote program script list request */

#define	REMPGM_OPT_COPY_IMAGE		1	/* remote program copy image option */
#define	REMPGM_OPT_TERMINATE		2	/* remote program terminate option */

#define	REMPGM_NO_REPLY			0	/* remote program request with no reply */
#define	REMPGM_REPLY			1	/* remote program request with reply */

#define	GENMESS_ID_STRING_LEN		8	/* length of generic message ID string */
#define	GENMESS_DATA_TYPE_LEN		3	/* length of data type ID string */
#define	GENMESS_MESS_ID_NAME_LEN	16	/* length of message ID string */

typedef struct GENERIC_MESSAGE_HEADER		/* generic interprocess message header */
    {
    char	id_string[GENMESS_ID_STRING_LEN+2];	/* ASCII string identifying this as a generic message ("fermi1") */
    char	data_type[GENMESS_DATA_TYPE_LEN+1];	/* ASCII string identifying data type ("DEC") */
    int		message_type;			/* type of message - request/reply, USM, multicast */
    int		generic_type_code;		/* facility level type code */
    int		type_code;			/* type code */
    int		subtype_code;			/* subtype code */
    unsigned int	options_mask;		/* request options */
    int		request_node;			/* requesting node */
    char	request_task[PROCESS_NAME_LEN+2];	/* requesting task */
    int		reply_type;			/* type of reply requested */
    unsigned int	timestamp;		/* time of request in clinks */
    unsigned int	delta_timestamp;	/* fraction of second after timestamp */
    char	message_id[GENMESS_MESS_ID_NAME_LEN+2];	/* message ID string */
    unsigned int	message_length;		/* message length */
    } __attribute__((packed)) GENERIC_MESSAGE_HEADER;

#define	REMOTE_COPY_MAIN_SCREEN	0		/* copy program's main screen */
#define	REMOTE_COPY_GRAPHICS_1	1		/* copy program's first graphics screen GxP1 */
#define	REMOTE_COPY_GRAPHICS_2	2		/* copy program's second graphics screen GxP2 */
#define	REMOTE_COPY_SA		3		/* copy secondary application SA */
#define	REMOTE_COPY_SB		4		/* copy secondary application SB */
#define	REMOTE_COPY_SC		5		/* copy secondary application SC */
#define	REMOTE_COPY_SD		6		/* copy secondary application SD */
#define	REMOTE_COPY_SE		7		/* copy secondary application SE */

#define	REMOTE_COPY_PATH_LEN	64		/* copy image path name length */
#define	REMOTE_COPY_NAME_LEN	32		/* copy image name length */

typedef struct REMOTE_COPY_DATA			/* remote program copy data */
    {
    int		type_code;			/* presently unused */
    int		subtype_code;			/* presently unused */
    int		screen_id;			/* screen to copy */
    int		output_type;			/* presently unused */
    int		clock_event;			/* clock event to wait for before making copy */
    unsigned int	delay;			/* delay from event (or request time) in milliseconds before making copy */
    char	path[REMOTE_COPY_PATH_LEN+2];	/* path to copy image file to */
    char	name[REMOTE_COPY_NAME_LEN+2];	/* copy image name */
    int		append_date;			/* logical flag to determine whether or not to append the date to the name */
    } __attribute__((packed)) REMOTE_COPY_DATA;

typedef struct REMOTE_PROGRAM_SCRIPT_DATA	/* remote program script request info */
    {
    char	script_name[SCRIPT_NAMLEN+2];	/* name of script */
    int		script_doterm;			/* TRUE-> program terminates */
    float	script_speed;			/* replay multiplier */
    int		script_noset;			/* TRUE-> inhibit DP settings */
    int		script_nofswrite;		/* TRUE-> inhibit FS writes */
    } __attribute__((packed)) REMOTE_PROGRAM_SCRIPT_DATA;

typedef struct AUX_REMOTE_PROGRAM_SCRIPT_DATA	/* remote program script request info */
    {
    float	script_speed;			/* replay multiplier */
    int		script_noset;			/* TRUE-> inhibit DP settings */
    int		script_nofswrite;		/* TRUE-> inhibit FS writes */
    } __attribute__((packed)) AUX_REMOTE_PROGRAM_SCRIPT_DATA;

#define	REMOTE_METHOD_NAME_LEN		64	/* length of a program method name */
#define	REMOTE_METHOD_OBJECT_LEN	252	/* length of a program method object */
#define	REMOTE_METHOD_QUALIFIER_LEN	252	/* length of a program method qualifier */

typedef struct REMOTE_PROGRAM_METHOD_DATA	/* remote program method request info */
    {
    char	method[REMOTE_METHOD_NAME_LEN+2];	/* method to invoke */
    char	method_object[REMOTE_METHOD_OBJECT_LEN+2];	/* object of method */
    char	method_qualifier[REMOTE_METHOD_QUALIFIER_LEN+2];	/* method qualifier */
    } __attribute__((packed)) REMOTE_PROGRAM_METHOD_DATA;

#define	SCRIPT_LIST_FILE_LEN	132

typedef struct REMOTE_PROGRAM_SCRIPT_LIST_DATA	/* remote program script list request info */
    {
    char	script_file[SCRIPT_LIST_FILE_LEN+2];	/* name of file containing scripts to execute */
    int		script_doterm;			/* TRUE-> program terminates */
    float	script_speed;			/* replay multiplier */
    int		script_noset;			/* TRUE-> inhibit DP settings */
    int		script_nofswrite;		/* TRUE-> inhibit FS writes */
    } __attribute__((packed)) REMOTE_PROGRAM_SCRIPT_LIST_DATA;

typedef struct REMOTE_PROGRAM_DATA		/* remote program data */
    {
    GENERIC_MESSAGE_HEADER	header;		/* message header information */
    int			request_console;	/* requesting console */
    int			request_slot;		/* requesting slot */
    int			clock_event;		/* clock event to wait for before executing request */
    unsigned int	delay;			/* delay from event (or request time) in milliseconds before executing request */
    unsigned int	command_data_length;	/* length of additional command information in bytes */
    } __attribute__((packed)) REMOTE_PROGRAM_DATA;

#define	REMOTE_METHOD_DESCRIPTION_LEN	252	/* length of a program method description */
#define	REMOTE_METHOD_OBJECT_DESCR_LEN	252	/* length of a program method object description */
#define	REMOTE_METHOD_QUALIFIER_DESCR_LEN	252	/* length of a program method qualifier description */

typedef struct REMOTE_METHOD_INFO		/* remote program method information */
    {
    char	process_name[PROCESS_NAME_LEN];
    char	method[REMOTE_METHOD_NAME_LEN];	/* method name */
    int		method_id;
    char	method_description[REMOTE_METHOD_DESCRIPTION_LEN];	/* method description */
    char	object_description[REMOTE_METHOD_OBJECT_DESCR_LEN];	/* object description */
    char	qualifier_description[REMOTE_METHOD_QUALIFIER_DESCR_LEN];	/* qualifier description */
    int		protection;
    } __attribute__((packed)) REMOTE_METHOD_INFO;

typedef struct PROGRAM_LOCATION			/* console program location information */
    {
    int		console_number;			/* console number */
    int		console_slot;			/* console slot */
    } __attribute__((packed)) PROGRAM_LOCATION;

typedef struct DEVLST_SR_SOURCE_DATA
    {
    int		file_number;			/* save/restore file number */
    } __attribute__((packed)) DEVLST_SR_SOURCE_DATA;

typedef struct DEVLST_SDA_SOURCE_DATA
    {
    int		file_number;			/* SDA file number */
    int		case_number;			/* SDA case number */
    int		subcase_number;			/* SDA subcase number */
    int		usage_number;			/* SDA usage number */
    int		try_number;			/* SDA try number */
    } __attribute__((packed)) DEVLST_SDA_SOURCE_DATA;

typedef struct DEVLST_LOGGER_SOURCE_DATA
    {
    int		node;				/* Lumberjack node */
    unsigned int	start_time;		/* requested start time in seconds since January 1, 1970 */
    unsigned int	accuracy;		/* allowable variance from start time in seconds */
    } __attribute__((packed)) DEVLST_LOGGER_SOURCE_DATA;

typedef struct DEVLST_MEMORY_SOURCE_DATA
    {
    int		pool_id;			/* memory pool ID */
    int		auto_populate;			/* flag indicating whether or not to autopopulate on reads */
    } __attribute__((packed)) DEVLST_MEMORY_SOURCE_DATA;

typedef struct DEVLST_SNAPMANAGER_SOURCE_DATA
    {
    int		system_number;			/* snapshot manager system number */
    unsigned int	record_or_date;		/* record number or date */
    } __attribute__((packed)) DEVLST_SNAPMANAGER_SOURCE_DATA;

typedef struct DEVLST_OPTION_DATA
    {
    int		option_type;
    int		option_value;
    void	*option_data;
    } __attribute__((packed)) DEVLST_OPTION_DATA;

typedef struct DEVLST_OUTPUT_MEMORY_DATA
    {
    char	*formatted_text;
    int		line_length;
    int		num_lines;
    } __attribute__((packed)) DEVLST_OUTPUT_MEMORY_DATA;

typedef struct DATA_EVENT_PERIODIC_DATA
    {
    unsigned int	interval_in_msec;	/* interval in milliseconds */
    int		want_immediate;
    } __attribute__((packed)) DATA_EVENT_PERIODIC_DATA;

#define	DATA_EVENT_NO_CLOCK_EVENT	-1	/* no clock event detection */
#define	DATA_EVENT_HARD_CLOCK_EVENT	0	/* hard clock event detection */
#define	DATA_EVENT_SOFT_CLOCK_EVENT	1	/* soft clock event detection */
#define	DATA_EVENT_EITHER_CLOCK_EVENT	2	/* either hard or soft clock event detection */

typedef struct DATA_EVENT_CLOCK_DATA
    {
    int		clock_type;			/* type of clock event */
    int		event_number;			/* clock event number */
    int		detection_type;			/* type of event detection */
    unsigned int	delay;			/* delay in milliseconds */
    } __attribute__((packed)) DATA_EVENT_CLOCK_DATA;

#define	DATA_EVENT_STATE_NOOP		-1	/* don't monitor any transitions */
#define	DATA_EVENT_STATE_EQUALS		0	/* want transition to requested state */
#define	DATA_EVENT_STATE_NOT_EQUALS	1	/* want transition except for requested state */
#define	DATA_EVENT_STATE_ALL		2	/* want transition for all state values */
#define	DATA_EVENT_STATE_LESS_THAN	3	/* want transition if state value is less than requested state */
#define	DATA_EVENT_STATE_LESS_EQUAL	4	/* want transition if state value is less than or equal to requested state */
#define	DATA_EVENT_STATE_GREATER_THAN	5	/* want transition if state value is greater than requested state */
#define	DATA_EVENT_STATE_GREATER_EQUAL	6	/* want transition if state value is greater than or equal to requested state */

typedef struct DATA_EVENT_STATE_DATA
    {
    int		device_index;			/* device index of state device */
    int		state_number;			/* state number */
    int		condition;			/* state transition condition */
    unsigned int	delay;			/* delay in milliseconds */
    } __attribute__((packed)) DATA_EVENT_STATE_DATA;

#define	SNAPSHOT_NONE_PREFERRED		0	/* neither rate nor duration requested */
#define	SNAPSHOT_RATE_PREFERRED		1	/* rate is the most important parameter */
#define	SNAPSHOT_DURATION_PREFERRED	2	/* duration is the most important parameter */
#define	SNAPSHOT_BOTH_PREFERRED		4	/* honor both rate and duration requested */

#define	SNAPSHOT_SAMPLE_PERIODIC	1	/* sample data periodically */
#define	SNAPSHOT_SAMPLE_EVENT		2	/* sample data on event */
#define	SNAPSHOT_SAMPLE_EXTERNAL	3	/* sample on an external trigger */

#define	SNAPSHOT_MAX_SAMPLE_EVENTS	4

typedef struct SNAPSHOT_EVENT_SAMPLE_DATA
    {
    int		num_events;			/* number of sample events */
    int		sample_events[SNAPSHOT_MAX_SAMPLE_EVENTS];	/* sample events */
    unsigned int	delay;			/* delay in milliseconds */
    } __attribute__((packed)) SNAPSHOT_EVENT_SAMPLE_DATA;

typedef struct SNAPSHOT_EXTERNAL_SAMPLE_DATA
    {
    int		source;				/* external source number */
    } __attribute__((packed)) SNAPSHOT_EXTERNAL_SAMPLE_DATA;

#define	SNAPSHOT_TRIGGER_EVENT		1	/* trigger on a clock event */
#define	SNAPSHOT_TRIGGER_STATE		2	/* trigger on a state event */
#define	SNAPSHOT_TRIGGER_DEVICE		3	/* trigger on a device reading */

#define	SNAPSHOT_MAX_TRIGGER_EVENTS	8

typedef struct SNAPSHOT_EVENT_TRIGGER_DATA
    {
    int		num_events;			/* number of trigger events */
    int		trigger_events[SNAPSHOT_MAX_TRIGGER_EVENTS];	/* trigger events */
    int		delay;				/* delay in milliseconds */
    } __attribute__((packed)) SNAPSHOT_EVENT_TRIGGER_DATA;

typedef struct SNAPSHOT_DEVICE_TRIGGER_DATA
    {
    ARRAY_DEVICE_DATA	device;			/* triggering device */
    unsigned int	mask;			/* value mask */
    unsigned int	value;			/* trigger value */
    int		delay;				/* delay in milliseconds */
    } __attribute__((packed)) SNAPSHOT_DEVICE_TRIGGER_DATA;

#define	SNAPSHOT_REARM_NONE		0	/* don't rearm snapshot */
#define	SNAPSHOT_REARM_EVENT		1	/* rearm on a clock event */
#define	SNAPSHOT_REARM_STATE		2	/* rearm on a state event */
#define	SNAPSHOT_REARM_PERIODIC		3	/* rearm after a fixed time */

typedef struct DATA_EVENT_SNAPSHOT_DATA
    {
    int		rate;				/* plotting rate */
    double	duration;			/* plot duration */
    int		num_points;			/* number of points */
    int		plot_preference;		/* plot rate/duration preference */
    int		sample_type;			/* plot sample type */
    union
	{
	SNAPSHOT_EVENT_SAMPLE_DATA	event;	/* event sample data */
	SNAPSHOT_EXTERNAL_SAMPLE_DATA	external;	/* external sample data */
	} sample;				/* sampling information */
    int		trigger_type;			/* type of trigger */
    union
	{
	SNAPSHOT_EVENT_TRIGGER_DATA	event;	/* event trigger data */
	DATA_EVENT_STATE_DATA	state;		/* state trigger data */
	SNAPSHOT_DEVICE_TRIGGER_DATA	device;	/* device trigger data */
	} trigger;
    int		rearm;				/* logical rearm flag */
    int		rearm_delay_type;		/* type of rearm delay */
    union
	{
	DATA_EVENT_PERIODIC_DATA	periodic;	/* periodic delay data */
	DATA_EVENT_CLOCK_DATA		event;	/* clock event delay data */
	DATA_EVENT_STATE_DATA		state;	/* state event delay data */
	} rearm_delay;
    int		max_per_hour;			/* maximum number of snapshots per hour */
    } __attribute__((packed)) DATA_EVENT_SNAPSHOT_DATA;

#define	FTP_SAMPLE_PERIODIC	1	/* sample data periodically */
#define	FTP_SAMPLE_EVENT	2	/* sample data on event */
#define	FTP_SAMPLE_EXTERNAL	3	/* sample on an external trigger */

#define	FTP_MAX_SAMPLE_EVENTS	4

typedef struct FTP_EVENT_SAMPLE_DATA
    {
    int		num_events;			/* number of sample events */
    int		sample_events[FTP_MAX_SAMPLE_EVENTS];	/* sample events */
    unsigned int	delay;			/* delay in milliseconds */
    } __attribute__((packed)) FTP_EVENT_SAMPLE_DATA;

typedef struct FTP_EXTERNAL_SAMPLE_DATA
    {
    int		source;				/* external source number */
    } __attribute__((packed)) FTP_EXTERNAL_SAMPLE_DATA;

#define	FTP_TRIGGER_EVENT		1	/* trigger on a clock event */
#define	FTP_TRIGGER_STATE		2	/* trigger on a state event */
#define	FTP_TRIGGER_DEVICE		3	/* trigger on a device reading */

#define	FTP_MAX_TRIGGER_EVENTS		8

typedef struct FTP_EVENT_TRIGGER_DATA
    {
    int		num_events;			/* number of trigger events */
    int		trigger_events[FTP_MAX_TRIGGER_EVENTS];	/* trigger events */
    unsigned int	delay;			/* delay in milliseconds */
    } __attribute__((packed)) FTP_EVENT_TRIGGER_DATA;

typedef struct FTP_DEVICE_TRIGGER_DATA
    {
    ARRAY_DEVICE_DATA	device;			/* triggering device */
    unsigned int	mask;			/* value mask */
    unsigned int	value;			/* trigger value */
    unsigned int	delay;			/* delay in milliseconds */
    } __attribute__((packed)) FTP_DEVICE_TRIGGER_DATA;

#define	FTP_REARM_NONE		0		/* don't rearm fast time plot */
#define	FTP_REARM_EVENT		1		/* rearm on a clock event */
#define	FTP_REARM_STATE		2		/* rearm on a state event */
#define	FTP_REARM_PERIODIC	3		/* rearm after a fixed time */

typedef struct DATA_EVENT_FTP_DATA
    {
    double	rate;				/* plotting rate */
    double	duration;			/* plot duration */
    int		unused;				/* unused */
    int		sample_type;			/* plot sample type */
    union
	{
	FTP_EVENT_SAMPLE_DATA	event;		/* event sample data */
	FTP_EXTERNAL_SAMPLE_DATA	external;	/* external sample data */
	} sample;				/* sampling information */
    int		trigger_type;			/* type of trigger */
    union
	{
	FTP_EVENT_TRIGGER_DATA	event;		/* event trigger data */
	DATA_EVENT_STATE_DATA	state;		/* state trigger data */
	FTP_DEVICE_TRIGGER_DATA	device;		/* device trigger data */
	} trigger;
    int		rearm;				/* logical rearm flag */
    int		rearm_delay_type;		/* type of rearm delay */
    union
	{
	DATA_EVENT_PERIODIC_DATA	periodic;	/* periodic delay data */
	DATA_EVENT_CLOCK_DATA		event;	/* clock event delay data */
	DATA_EVENT_STATE_DATA		state;	/* state event delay data */
	} rearm_delay;
    int		max_per_hour;			/* maximum number of fast time plots per hour */
    } __attribute__((packed)) DATA_EVENT_FTP_DATA;

#define	DATA_EVENT_CLIENT_NAME_LEN	15	/* maximum client name length */

typedef struct DATA_EVENT_CLIENT_DATA
    {
    char	client_name[DATA_EVENT_CLIENT_NAME_LEN+1];	/* client name */
    } __attribute__((packed)) DATA_EVENT_CLIENT_DATA;

typedef struct DATA_EVENT_DEFAULT_DATA
    {
    int		unused;				/* unused */
    } __attribute__((packed)) DATA_EVENT_DEFAULT_DATA;

#define	DATA_EVENT_ALARM_ANALOG		1	/* want analog alarm */
#define	DATA_EVENT_ALARM_DIGITAL	2	/* want digital alarm */
#define	DATA_EVENT_ALARM_ANY_TYPE	3	/* want any type of alarm */

#define	DATA_EVENT_ALARM_BAD		1	/* want going bad alarm */
#define	DATA_EVENT_ALARM_GOOD		2	/* want going good alarm */
#define	DATA_EVENT_ALARM_ANY_CONDITION	3	/* want any alarm condition */

typedef struct DATA_EVENT_ALARM_DATA
    {
    int		device_index;			/* device index of alarm device */
    int		alarm_type;			/* alarm type */
    int		alarm_condition;		/* alarm condition */
    unsigned int	delay;			/* delay in milliseconds */
    } __attribute__((packed)) DATA_EVENT_ALARM_DATA;

#define	DATA_EVENT_ALARM_BYPASSED	1	/* want alarm bypass */
#define	DATA_EVENT_ALARM_ENABLED	2	/* want alarm enable */
#define	DATA_EVENT_ALARM_ANY_STATE	3	/* want any alarm state change */

typedef struct DATA_EVENT_ALARM_BYPASS_DATA
    {
    int		device_index;			/* device index of alarm device */
    int		alarm_type;			/* alarm type */
    int		alarm_state;			/* alarm state */
    unsigned int	delay;			/* delay in milliseconds */
    } __attribute__((packed)) DATA_EVENT_ALARM_BYPASS_DATA;

typedef struct DATA_EVENT_TOD_DATA
    {
    int		time_of_day;			/* time of day in seconds */
    int		do_once;			/* do once flag */
    } __attribute__((packed)) DATA_EVENT_TOD_DATA;

#define	DATA_EVENT_SETTING_ANY_PROPERTY	0	/* want any setting property */

typedef struct DATA_EVENT_SETTING_DATA
    {
    int		device_index;			/* device index of setting device */
    short	property;			/* device property */
    unsigned int	delay;			/* delay in milliseconds */
    } __attribute__((packed)) DATA_EVENT_SETTING_DATA;

#define	DATA_EVENT_DBNEWS_ALL_DEVICES		(-1)	/* want any DBNEWS device */
#define	DATA_EVENT_DBNEWS_ANY_PROPERTY		0	/* want any DBNEWS property */
#define	DATA_EVENT_DBNEWS_ANY_MOD_TYPE		0xFFFFFFFFFFFFFFFFULL	/* want any DBNEWS modification type */
#define	DATA_EVENT_DBNEWS_NEW_DEVICE		1	/* new device created */
#define	DATA_EVENT_DBNEWS_NEW_PROPERTY		2	/* new property added */
#define	DATA_EVENT_DBNEWS_READ_SCALING_MOD	4	/* reading scaling modified */
#define	DATA_EVENT_DBNEWS_SET_SCALING_MOD	8	/* setting scaling modified */
#define	DATA_EVENT_DBNEWS_READ_SET_SCALING_MOD	0xC	/* reading or setting scaling modified */
#define	DATA_EVENT_DBNEWS_READ_ENUMVAL_MOD	0x10	/* reading enumerated value information modified */
#define	DATA_EVENT_DBNEWS_SET_ENUMVAL_MOD	0x20	/* setting enumerated value information modified */
#define	DATA_EVENT_DBNEWS_ENUMVAL_MOD		0x30	/* enumerated value information modified */
#define	DATA_EVENT_DBNEWS_STATUS_SCALING_MOD	0x40	/* status scaling modified */
#define	DATA_EVENT_DBNEWS_SCALING_MOD		0x4C	/* scaling modified */
#define	DATA_EVENT_DBNEWS_FOREIGN_DEVICE_MOD	0x80	/* foreign device mapping information modified */
#define DATA_EVENT_DBNEWS_READ_STRUC_MOD	0x100	/* reading structure name modified */
#define DATA_EVENT_DBNEWS_SET_STRUC_MOD		0x200	/* setting structure name modified */
#define DATA_EVENT_DBNEWS_STRUC_MOD		0x300	/* structure name modified */
#define DATA_EVENT_DBNEWS_EXPRESSION_MOD	0x400	/* device expression modified */

typedef struct DATA_EVENT_DBNEWS_DATA
    {
    int		device_index;			/* device index of modified device */
    short	property;			/* device property */
    unsigned long long	modification_flags;	/* modification type flags (DBNEWS_FLAG_xxx) */
    unsigned int	delay;			/* delay in milliseconds */
    } __attribute__((packed)) DATA_EVENT_DBNEWS_DATA;

typedef struct DATA_EVENT_DATE_DATA
    {
    unsigned int	date;			/* date in seconds */
    } __attribute__((packed)) DATA_EVENT_DATE_DATA;

typedef struct DATA_EVENT_TERM_DATA
    {
    union
	{
	DATA_EVENT_PERIODIC_DATA	periodic;
	DATA_EVENT_CLOCK_DATA		clock_event;
	DATA_EVENT_STATE_DATA		state_transition;
	DATA_EVENT_SNAPSHOT_DATA	snapshot;
	DATA_EVENT_FTP_DATA		ftp;
	DATA_EVENT_CLIENT_DATA		client;
	DATA_EVENT_DEFAULT_DATA		default_data;
	DATA_EVENT_ALARM_DATA		alarm;
	DATA_EVENT_ALARM_BYPASS_DATA	bypass;
	DATA_EVENT_TOD_DATA		tod;
	DATA_EVENT_SETTING_DATA		setting;
	DATA_EVENT_DBNEWS_DATA		dbnews;
	DATA_EVENT_DATE_DATA		date;
	} data;
    int		operator_code;
    } __attribute__((packed)) DATA_EVENT_TERM_DATA;

#define	DATA_EVENT_TYPE_DEFAULT		(-2)	/* default data event */
#define	DATA_EVENT_TYPE_NULL		(-1)	/* null data event */
#define	DATA_EVENT_TYPE_ONCE		0	/* once (immediate) request */
#define	DATA_EVENT_TYPE_PERIODIC	1	/* periodic request */
#define	DATA_EVENT_TYPE_CLOCK		2	/* clock event request */
#define	DATA_EVENT_TYPE_STATE		3	/* state transition request */
#define	DATA_EVENT_TYPE_SNAPSHOT	4	/* snapshot request */
#define	DATA_EVENT_TYPE_FTP		5	/* fast time plot request */
#define	DATA_EVENT_TYPE_CLIENT		6	/* client (Lumberjack) event */
#define	DATA_EVENT_TYPE_ALARM		7	/* alarm event */
#define	DATA_EVENT_TYPE_TOD		8	/* time of day event */
#define	DATA_EVENT_TYPE_SETTING		9	/* device setting event */
#define	DATA_EVENT_TYPE_ALARM_BYPASS	10	/* alarm bypass event */
#define	DATA_EVENT_TYPE_DBNEWS		11	/* DBNEWS (device database modification) event */
#define	DATA_EVENT_TYPE_DATE		12	/* date event */

typedef struct DATA_EVENT_DATA
    {
    int		event_type;
    int		num_terms;
    DATA_EVENT_TERM_DATA	terms[1];
    } __attribute__((packed)) DATA_EVENT_DATA;

typedef struct SIMPLE_DATA_EVENT_TERM_DATA
    {
    union
	{
	DATA_EVENT_PERIODIC_DATA	periodic;
	DATA_EVENT_CLOCK_DATA		clock_event;
	DATA_EVENT_STATE_DATA		state_transition;
	DATA_EVENT_ALARM_DATA		alarm;
	DATA_EVENT_ALARM_BYPASS_DATA	bypass;
	DATA_EVENT_TOD_DATA		tod;
	DATA_EVENT_SETTING_DATA		setting;
	} data;
    int		operator_code;
    } __attribute__((packed)) SIMPLE_DATA_EVENT_TERM_DATA;

typedef struct SIMPLE_DATA_EVENT_DATA
    {
    int		event_type;
    int		num_terms;
    SIMPLE_DATA_EVENT_TERM_DATA	terms[1];
    } __attribute__((packed)) SIMPLE_DATA_EVENT_DATA;

typedef struct DATA_SOURCE_DATA
    {
    int		source_type;
    union
	{
	DIO_SR_SPEC	save_file;
	DIO_SDA_SPEC	sda;
	DIO_DL_SPEC	datalogger;
	DIO_MEMORY_SPEC	memory;
	DIO_SNAPMANAGER_SPEC	snapmanager;
	} source_data;
    } __attribute__((packed)) DATA_SOURCE_DATA;

typedef struct DELIMITED_FILE_FORMAT_DATA
    {
    int		convert_type;			/* conversion type */
    int		data_length;			/* column data length */
    } __attribute__((packed)) DELIMITED_FILE_FORMAT_DATA;

typedef struct FIELD_EDIT_DATA
    {
    int		field_number;			/* field number (starts at 1) */
    int		data_type;			/* data type (INP_xxx) */
    void	*value;				/* current field value */
    int		data_length;			/* field data length */
    int		changed;			/* field changed flag (TRUE -> value has been changed */
    } __attribute__((packed)) FIELD_EDIT_DATA;

#define	LEX_DRAW_FILE_NAME_LEN	8		/* length of a Lex Draw file name */

typedef struct LEX_DRAW_IMAGE_DATA		/* Lex Draw image data */
    {
    char	file_name[LEX_DRAW_FILE_NAME_LEN];	/* file name */
    int		image_number;			/* image number */
    } __attribute__((packed)) LEX_DRAW_IMAGE_DATA;

typedef struct CAMAC_BLOCKX_CRATE_SCAN_DATA
    {
    short	data;
    char	unused;
    char	status;
    } __attribute__((packed)) CAMAC_BLOCKX_CRATE_SCAN_DATA;

#define	ERROR_TYPE_ERROR	0
#define	ERROR_TYPE_MESSAGE	1

#define	ERROR_REMOTE_LOG_NAME_LEN	8	/* log file name length */
#define	ERROR_REMOTE_AUTHOR_NAME_LEN	32	/* message author name length */
#define	ERROR_REMOTE_MESSAGE_LEN	132	/* length of an error message strign */

typedef struct REMOTE_ERROR_DATA
    {
    char	process_name[PROCESS_NAME_LEN+2];
    int		message_type;
    int		error_type;
    int		error_code;
    int		priority;
    int		color;
    char	log_file[ERROR_REMOTE_LOG_NAME_LEN+2];
    char	author[ERROR_REMOTE_AUTHOR_NAME_LEN+2];
    char	message_string[ERROR_REMOTE_MESSAGE_LEN+2];
    } __attribute__((packed)) REMOTE_ERROR_DATA;

#define	WEBLOG_REMOTE_TOKEN_LEN	16

typedef struct REMOTE_WEBLOG_MESSAGE_VALUE
    {
    char	*descriptor;
    char	*value_string;
    } __attribute__((packed)) REMOTE_WEBLOG_MESSAGE_VALUE;

typedef struct REMOTE_WEBLOG_MESSAGE_DATA
    {
    char	process_name[PROCESS_NAME_LEN+2];
    int		node;
    char	token_string[WEBLOG_REMOTE_TOKEN_LEN+2];
    int		message_type;
    int		status;
    unsigned int	execution_start;
    unsigned int	execution_end;
    int		num_values;
    REMOTE_WEBLOG_MESSAGE_VALUE	*values;
    } __attribute__((packed)) REMOTE_WEBLOG_MESSAGE_DATA;

typedef int MECCA_INFO_FIELD;
/* Setting up as bit flags so that sets of fields could be expressed. */
const MECCA_INFO_FIELD MECCA_INFO_FIELD_KEEPER      = 0x01;
const MECCA_INFO_FIELD MECCA_INFO_FIELD_AUTHOR      = 0x02;
const MECCA_INFO_FIELD MECCA_INFO_FIELD_DESCRIPTION = 0x04;
const MECCA_INFO_FIELD MECCA_INFO_FIELD_PROGRAM     = 0x08;
const MECCA_INFO_FIELD MECCA_INFO_FIELD_BACKUP      = 0x10;
    
typedef int MECCA_SEARCH_OPT;
/* Setting up as bit flags so that sets can be expressed. */
const MECCA_SEARCH_OPT MECCA_SEARCH_OPT_EXACT	    = 0x0001;
const MECCA_SEARCH_OPT MECCA_SEARCH_OPT_NO_EXACT    = 0x0000;

const MECCA_SEARCH_OPT MECCA_SEARCH_OPT_PAS	    = 0x0002;
const MECCA_SEARCH_OPT MECCA_SEARCH_OPT_SAS	    = 0x0004;
const MECCA_SEARCH_OPT MECCA_SEARCH_OPT_ULS	    = 0x0008;
const MECCA_SEARCH_OPT MECCA_SEARCH_OPT_SERVICES    = 0x0010;
const MECCA_SEARCH_OPT MECCA_SEARCH_OPT_ALL	    = (
                                MECCA_SEARCH_OPT_PAS |
                                MECCA_SEARCH_OPT_SAS |
                                MECCA_SEARCH_OPT_ULS |
                                MECCA_SEARCH_OPT_SERVICES
				);

const MECCA_SEARCH_OPT MECCA_SEARCH_OPT_OBSOLETE    = 0x0100;
const MECCA_SEARCH_OPT MECCA_SEARCH_OPT_ABANDONED   = 0x0200;
const MECCA_SEARCH_OPT MECCA_SEARCH_OPT_ACTIVE	    = 0x1000;
const MECCA_SEARCH_OPT MECCA_SEARCH_OPT_UNKNOWN	    = 0x2000;
const MECCA_SEARCH_OPT MECCA_SEARCH_OPT_OBSOLETE_TEV = 0x4000;
const MECCA_SEARCH_OPT MECCA_SEARCH_OPT_ALL_STATUS  = (
                                MECCA_SEARCH_OPT_OBSOLETE  |
                                MECCA_SEARCH_OPT_ABANDONED |
                                MECCA_SEARCH_OPT_ACTIVE    |
                                MECCA_SEARCH_OPT_UNKNOWN   |
				MECCA_SEARCH_OPT_OBSOLETE_TEV
				);

const MECCA_SEARCH_OPT MECCA_SEARCH_OPT_VMS	    = 0x10000;
const MECCA_SEARCH_OPT MECCA_SEARCH_OPT_LINUX	    = 0x20000;
const MECCA_SEARCH_OPT MECCA_SEARCH_OPT_LOST	    = 0x40000;
const MECCA_SEARCH_OPT MECCA_SEARCH_OPT_JAVA	    = 0x80000;
const MECCA_SEARCH_OPT MECCA_SEARCH_OPT_ALL_LOCATIONS  = (
                                MECCA_SEARCH_OPT_VMS	   |
                                MECCA_SEARCH_OPT_LINUX	   |
                                MECCA_SEARCH_OPT_LOST	   |
                                MECCA_SEARCH_OPT_JAVA
				);

#define	PROGRAM_MOD_FROM_LEN		250

/*
 * This structure is designed so that it is naturally packed, i.e.,
 * such that the compiler will lay it out in memory with no padding
 * even with -fpack-struct off.  That there is no padding is a
 * requirement of clib's DB API routine db_nextrow().
 */
typedef struct
    {
    /* mod_on member has the most demanding alignment so place it first. */
    time_t        mod_on;      /* date and time of last modification */
                               /* type of program - pas, sas, uls, or service */
    /* Adding +2 to _LEN #defines because _LEN are the string lengths.  Buffers
       need to be two chars longer to allow null-termination and still
       be even-length to allow for transmission over Acnet. */           
    char          type[PROGRAM_TYPE_LEN+2];
                               /* name of program, e.g., pa1000, sa1000, ul_foobar, or cservice */
    char          program[PROGRAM_NAME_LEN+2];
    char          description[PROGRAM_DESCRIPTION_LEN+2];
    /* Usernames are expected to be standardized across all Linux controls system machines
       and match the user's kerberos principal so that there in no need to specify a host
       for context. */
    char          author[USER_NAME_LEN+2];	/* author's username */
    char          keeper[USER_NAME_LEN+2];	/* keeper's username */
    char          backup[USER_NAME_LEN+2];	/* backup keeper's username */
    char          mod_by[USER_NAME_LEN+2];	/* last modifier's username */
    char          author_email[EMAIL_LEN+2];	/* author's email */
    char          keeper_email[EMAIL_LEN+2];	/* keeper's email */
    char          backup_email[EMAIL_LEN+2];	/* backup keeper's email */
    char          mod_by_email[EMAIL_LEN+2];	/* last modifier's email */
    char          status[PROGRAM_STATUS_LEN+2];	/* status text, e.g., 'active' or 'obsolete' */
    char          location[PROGRAM_LOCATION_LEN+2];	/* location, e.g., 'VMS only' or 'VMS/Linux' */
    char	  mod_from[PROGRAM_MOD_FROM_LEN+2];	/* original program source directory */
    char          padding[2];  /* pad for alignment of clinks_t in next array element */
    } MECCA_PROGRAM_INFO ;

#define SEQ_FILE	0
#define REL_FILE	1
#define IDX_FILE	2

typedef struct {
    short	type;
    int		rec_size;
    int		rec_count;
} __attribute__((packed)) FS_FILE_INFO;

#define	SR_SYSTEM_NAME_LEN		8
#define	SR_NUM_LEVEL_1_LISTS		18
#define	SR_NUM_LEVEL_2_LISTS		10
#define	SR_LEVEL_1_NAME_LEN		8
#define	SR_LEVEL_2_NAME_LEN		7	
#define	SR_LIST_NAME_LEN		(SR_SYSTEM_NAME_LEN + \
					 SR_LEVEL_1_NAME_LEN + \
					 SR_LEVEL_2_NAME_LEN + 2)

typedef struct SR_LEVEL_1_INFO
    {
    short	level_1_ids[SR_NUM_LEVEL_1_LISTS];
    char	level_1_names[SR_NUM_LEVEL_1_LISTS][SR_LEVEL_1_NAME_LEN];
    } __attribute__((packed)) SR_LEVEL_1_INFO;

typedef struct SR_LEVEL_2_INFO
    {
    short	level_2_ids[SR_NUM_LEVEL_2_LISTS];
    char	level_2_names[SR_NUM_LEVEL_2_LISTS][SR_LEVEL_2_NAME_LEN+1];
    } __attribute__((packed)) SR_LEVEL_2_INFO;

typedef struct SR_FIND_NODE_LIST_DEVICE_DATA
    {
    int		device_index;
    int		list_id;
    } __attribute__((packed)) SR_FIND_NODE_LIST_DEVICE_DATA;

typedef struct SR_FIND_NODE_USER_LIST_DEVICE_DATA
    {
    int		device_index;
    char	list_name[SR_LIST_NAME_LEN+2];
    } __attribute__((packed)) SR_FIND_NODE_USER_LIST_DEVICE_DATA;

#define	GPIB_MODEL_NAME_LEN		32
#define	GPIB_MANUFACTURER_NAME_LEN	64
#define	GPIB_LOCATION_NAME_LEN		64
#define	GPIB_ID_STRING_LEN		32
#define	GPIB_OWNER_NAME_LEN		32

typedef struct GPIB_DEVICE_INFO
    {
    int		node;					/* front end interface node */
    int		gpib_address;				/* GPIB address */
    int		device_index;
    char	model_name[GPIB_MODEL_NAME_LEN];	/* model name */
    char	manufacturer[GPIB_MANUFACTURER_NAME_LEN];	/* manufacturer */
    char	location[GPIB_LOCATION_NAME_LEN];	/* location */
    char	id_string[GPIB_ID_STRING_LEN];		/* ID string */
    char	owner[GPIB_OWNER_NAME_LEN];		/* owner */
    } __attribute__((packed)) GPIB_DEVICE_INFO;

typedef struct KNOB_RAW_DEVICE_INFO
    {
    int		raw_data_type;				/* raw data type */
    int		is_step_motor;				/* is step motor flag */
    float	knob_increment;				/* knob increment multiplier */
    int		handler_code;				/* raw data handler code */
    int		limit_value;				/* flag indicating whether or not limit the scaled value */
    float	minimum_value;				/* minimum scaled value */
    float	maximum_value;				/* maximum scaled value */
    int		scaling_length;
    PDB_RS	scaling_info;				/* scaling information */
    } __attribute__((packed)) KNOB_RAW_DEVICE_INFO;

typedef struct FOREIGN_DATA_TYPE_INFO
    {
    int		system_type;				/* foreign system type (EPICS, APACS, etc) */
    int		data_type;				/* data type value */
    } __attribute__((packed)) FOREIGN_DATA_TYPE_INFO;

#define	LEXT_PROG_NAME_LEN		8
#define	LEXT_PROG_TITLE_LEN		64
#define	LEXT_PROG_DESCRIPTION_LEN	80
#define	LEXT_PROG_OWNER_LEN		32
#define	LEXT_PROG_OWNER_MAIL_LEN	80

typedef struct LEXT_PROG_INFO
    {
    char	lex_sa_name[LEXT_PROG_NAME_LEN+2];
    char	title[LEXT_PROG_TITLE_LEN+2];		/* title of Lex program */
    char	description[LEXT_PROG_DESCRIPTION_LEN+2];	/* description of Lex program */
    char	owner[LEXT_PROG_OWNER_LEN+2];
    char	owner_mail[LEXT_PROG_OWNER_MAIL_LEN+2];
    int		protection;
    char	modify_date[DATE_STRING_LEN+2];
    char	last_execution_date[DATE_STRING_LEN+2];
    int		num_uses;
    int		last_console;
    int		last_slot;
    } __attribute__((packed)) LEXT_PROG_INFO;

typedef struct LEXT_PROG_MATCH_INFO
    {
    char	name[LEXT_PROG_NAME_LEN+2];		/* name of Lex program */
    int		object_type;
    int		x_pos;
    int		y_pos;
    } __attribute__((packed)) LEXT_PROG_MATCH_INFO;

#define	LEXT_PROG_ACL_SCRIPT_NAME_LEN	32

typedef struct LEXT_PROG_ACL_SCRIPT_MATCH_INFO
    {
    char	name[LEXT_PROG_NAME_LEN+2];		/* name of Lex program */
    int		object_type;
    int		x_pos;
    int		y_pos;
    char	script_name[LEXT_PROG_ACL_SCRIPT_NAME_LEN+2];
    } __attribute__((packed)) LEXT_PROG_ACL_SCRIPT_MATCH_INFO;

typedef struct LEXT_PROG_DEVICE_MATCH_INFO
    {
    char	name[LEXT_PROG_NAME_LEN+2];		/* name of Lex program */
    int		object_type;
    int		x_pos;
    int		y_pos;
    int		device_index;
    int		property;
    } __attribute__((packed)) LEXT_PROG_DEVICE_MATCH_INFO;

typedef struct LEXT_PROG_DEVICE_INFO
    {
    int		object_type;
    int		x_pos;
    int		y_pos;
    int		device_index;
    int		property;
    int		array_index;
    } __attribute__((packed)) LEXT_PROG_DEVICE_INFO;

/* ******************* for sa4010 * */

		/* Graphic Plot modes */ 
#define LOG_SA_PLOT_GRAPHICS	 0	/* Graphics mode  */
#define LOG_SA_PLOT_HISTOGRAM	 1	/* Histogram mode */
#define LOG_SA_PLOT_ARRAY_ELEM 	 2	/* Array device element graphics mode */
#define LOG_SA_PLOT_STATUS	 3	/* Status device mode */

		/* fit function types */
#define LOG_SA_FIT_NONE			-1
#define LOG_SA_FIT_EXPONENTIAL		 0
#define LOG_SA_FIT_POLYNOMIAL_MIN	 1
#define LOG_SA_FIT_POLYNOMIAL_MAX       20

		/* symbol shape types */
#define LOG_SA_SYMBOL_POINT	0
#define LOG_SA_SYMBOL_CIRCLE	1
#define LOG_SA_SYMBOL_SQUARE	2
#define LOG_SA_SYMBOL_TRIANGLE	3
#define LOG_SA_SYMBOL_DIAMOND	4
#define LOG_SA_SYMBOL_CROSS	5

		/* symbol size limits */
#define LOG_SA_SYMBOL_SIZE_MIN	4
#define LOG_SA_SYMBOL_SIZE_MAX	20

		/* number of symbols */
#define LOG_SA_NUM_SYMBOLS_MIN	0
#define LOG_SA_NUM_SYMBOLS_MAX	254
#define LOG_SA_NUM_SYMBOLS_ALL	255  /* number of symbols = number of points */

		/* dot group function types */
#define LOG_SA_GROUP_FUNCTION_AVERAGE	0
#define LOG_SA_GROUP_FUNCTION_MAX	1	/* maximum */
#define LOG_SA_GROUP_FUNCTION_MIN	2	/* minimum */
#define LOG_SA_GROUP_FUNCTION_RANGE	3
#define LOG_SA_GROUP_FUNCTION_LAGRANGE	4	/* not in use now */
#define LOG_SA_GROUP_FUNCTION_SUM	5	/* sum */
#define LOG_SA_GROUP_FUNCTION_EVENTS	6    /* number of events (data points)
						in the group (time) interval */
#define LOG_SA_GROUP_FUNCTION_DERIVATIVE  7

		/* dot group time interval units */
#define LOG_SA_GROUP_INTERVAL_POINTS	0
#define LOG_SA_GROUP_INTERVAL_SECONDS	1
#define LOG_SA_GROUP_INTERVAL_MINUTES	2
#define LOG_SA_GROUP_INTERVAL_HOURS	3
#define LOG_SA_GROUP_INTERVAL_DAYS	4

		/* plot types */
#define LOG_SA_PLOT_TYPE_COMMON		0
#define LOG_SA_PLOT_TYPE_LOGARITHM	1
#define LOG_SA_PLOT_TYPE_PRIMARY	2

		/* plot colors */
#define LOG_SA_DEFAULT_COLOR	0
#define LOG_SA_ROSE		1
#define LOG_SA_MAGENTA		2
#define LOG_SA_DEEP_SKY_BLUE	3
#define LOG_SA_BROWN		4
#define LOG_SA_BRONZE		5
#define LOG_SA_INDIGO		6
#define LOG_SA_EMERALD		7
#define LOG_SA_PURPLE		8
#define LOG_SA_ORANGE		9
#define LOG_SA_FLESH		10
#define LOG_SA_MAROON		11 
#define LOG_SA_MEDIUM_GRAY	12
#define LOG_SA_LIGHT_GRAY	13
#define LOG_SA_NUM_COLORS	19 /* Number of all colors (+5 default ones) */	

typedef struct LOG_DEVICE_INFO
    {
    int		use_name;			/* FALSE - use the device index, TRUE - use the device name*/
    char	device_name[DEVICE_TERSE_NAME_LEN];	/* device name if chosen */
    int		device_index;			/* device index if chosen */
    int		array_index;		
    int		end_array_index;		
    short	property;			/* property index  */
    float	plot_minimum;			/* initial grid value */
    float	plot_maximum;			/* final grid value */
    char	data_event_string[DATA_EVENT_MAX_LEN];
    unsigned short	logger_node;		/* logger node */
    int		list_id_number;			/* for the case if data event doesn't work */
    int		num_points_to_skip;		/* number of points to skip */
    int		skip_offset; 			/* offset number of points
    						   to begin skipping points */
    int		minimum_time_between_points;
    unsigned int	start_time_offset;	/* T1 offset for this device */
    char	fit_type[2];			/* fit function types for GRAPHICS Y(t) & HISTOGRAM */
    char	fit_xtype;			/* fit function types for X versus Y */
    char	fit_yxtype;			/* fit function types for Y(X)  */
    int		status_type;			/* status bit number */
    float	cut_minimum;			/* lower limit for the logged data */
    float	cut_maximum;			/* upper limit for the logged data */
    int		sda_case;
    int		sda_set_number;
    int		sda_final_data_value;
	/* next parameters just for Y-devices (not for X-device)*/
    int		symbol_shape;			/* plotted symbol shape
    						   (ignored if not last in expression) */
    int		filled_symbols;			/* FALSE - unfilled; TRUE - filled */
    int		symbol_size;			/* symbol size in pixels */
    int		group_function_type;		/* dot group function type */
    int		group_units;			/* dot group time interval units*/
    int		group_size;			/* dot group interval size */
						/* 0 - means no dot group function used */
    int		plot_type;			/* Logarithm,Common,or Primary grid units */
    int		connect_points;			/* FALSE - not connected; TRUE - connected */
    int		number_of_symbols;		/* number of plotted symbols/characters */
    int		plot_color;			/* graphics/histogram color */
    int		char_bond;			/* if a member of an arithmetic expression:
	    					   the operation sign +,-,*,/ */
    } __attribute__((packed)) LOG_DEVICE_INFO;
    
		/* The graphics window size */
#define	LOG_SA_PLOT_SIZE_DEFAULT	1
#define	LOG_SA_PLOT_SIZE_MEDIUM		2
#define	LOG_SA_PLOT_SIZE_LARGE		3

		/* Methods of finding the corresponding point */
#define LOG_SA_INTERPOLATION		0
#define LOG_SA_MATCHING			1
#define LOG_SA_CORRELATE		2
#define LOG_SA_DEVICE_MATCHING		3

		/* tolerances for matching (in integer seconds) */
#define LOG_SA_MIN_TOLERANCE		0
#define LOG_SA_MAX_TOLERANCE		900

		/* The integrate method preferences */
#define LOG_SA_INTEGRATE_DEFAULT	0	/* no integrate */
#define LOG_SA_INTEGRATE_CHANNELS	1
#define LOG_SA_INTEGRATE_SUMS		2
#define LOG_SA_INTEGRATE_BOTH		3

		/* functions for integrate/derivative procedure */
#define LOG_SA_INTEGRATE_FUNCTION_ABSOLUTE	0	/* abs (F(x)) */
#define LOG_SA_INTEGRATE_FUNCTION_AS_IS		1	/* F(x) */
#define LOG_SA_DERIVATIVE_FUNCTION		2	/* dF(x)/dx */

		/* Time units for integrate */
#define LOG_SA_INTEGRATE_NANOSECONDS	(float)1E-9
#define LOG_SA_INTEGRATE_MICROSECONDS	(float)1E-6
#define LOG_SA_INTEGRATE_MILLISECONDS	(float)1E-3
#define LOG_SA_INTEGRATE_SECONDS	(float)1
#define LOG_SA_INTEGRATE_MINUTES	(float)SECS_PER_MIN
#define LOG_SA_INTEGRATE_HOURS		(float)SECS_PER_HOUR

		/* integrate coefficient (for better fit in the grid) */
#define LOG_SA_INTEGRATE_COEFFICIENT_1E_9	(float)1E-9
#define LOG_SA_INTEGRATE_COEFFICIENT_1E_8	(float)1E-8
#define LOG_SA_INTEGRATE_COEFFICIENT_1E_7	(float)1E-7
#define LOG_SA_INTEGRATE_COEFFICIENT_1E_6	(float)1E-6
#define LOG_SA_INTEGRATE_COEFFICIENT_1E_5	(float)1E-5
#define LOG_SA_INTEGRATE_COEFFICIENT_1E_4	(float)1E-4
#define LOG_SA_INTEGRATE_COEFFICIENT_1E_3	(float)1E-3
#define LOG_SA_INTEGRATE_COEFFICIENT_1E_2	(float)1E-2
#define LOG_SA_INTEGRATE_COEFFICIENT_1E_1	(float)1E-1
#define LOG_SA_INTEGRATE_COEFFICIENT_1		(float)1

		/* limits for number of plot grid divisions  */
#define LOG_SA_DIVISIONS_X_MIN		  2
#define LOG_SA_DIVISIONS_X_MAX		100
#define LOG_SA_DIVISIONS_Y_MIN		  2
#define LOG_SA_DIVISIONS_Y_MAX		100

		/* limits for number of histogram bins */
#define LOG_SA_HISTOGRAM_BINS_MIN	2
#define LOG_SA_HISTOGRAM_BINS_MAX	99

#define LOG_SA_PLOT_TITLE_SIZE		 32

		/* The bits in the logarithmic grid flag */
#define LOG_X_LOGARITHMIC_GRID		1
#define LOG_Y_LOGARITHMIC_GRID		2

		/* the bit which flags about device name or index*/
#define LOG_NAME_IFNO_INDEX		1

typedef struct LOG_PAGE_INFO
    {
    char plot_title[LOG_SA_PLOT_TITLE_SIZE+1];
    int plot_mode;		/* Graphics,Histogram,Array Element,Status */
    int number_of_bins;		
    int histogram_auto_scale;	/* TRUE - upper limits(%%) are taken
				   from the data */
    int points_in_range;	/* for histograms : TRUE - drop the points
    				   which are out of range */
    int plot_size;		/* graphics window size  */
    unsigned int start_time;	/* dlog_t1 in clinks */
    unsigned int end_time;	/* dlog_t2 in clinks */
    int point_match_type;	
    int point_match_tolerance;	/* accuracy in seconds*/
    int integrate_values;	/* default(no),channels,sums or both */
    int integrate_method;	/* abs(F(x) or F(x) */
    float integrate_time_units;
    float integrate_coefficient;
    int  grid_x_divisions;	
    int  grid_y_divisions;	
    int node; 			/* not in use so far */
    int slot;			/* SA_SLOT,SB_SLOT,SC_SLOT */
    int console;
    short list_number;			/* for list plot */
    short list_plot_type;		/* true or offset list plot */
    unsigned short data_source_node;	/* for list plot */ 
    unsigned char list_plot_flag;	/* TRUE - all devices from the list */
    char logarithmic_grid_flag;	/*  */
    unsigned char x_device_plot_type;	/* like plot_type for expressions */
    unsigned char full_device_name_flag;	/* TRUE - full names enabled */
    } __attribute__((packed)) LOG_PAGE_INFO;

#define	LOG_SA_MAX_DEVICES	9		/* the maximum number of devices in D44/sa4010 */

/* The package format (to be sent to SA4010) */

typedef struct LOG_SA_INFO
    {
    LOG_PAGE_INFO	page_info;
    LOG_DEVICE_INFO	logger_device[LOG_SA_MAX_DEVICES];
    } __attribute__((packed)) LOG_SA_INFO;

typedef struct GIF_RGB_ENTRY
    {
    unsigned char	red;
    unsigned char	green;
    unsigned char	blue;
    } __attribute__((packed)) GIF_RGB_ENTRY;

#define	GIF_MAX_COLOR_ENTRIES	256

typedef struct GIF_IMAGE_DATA
    {
    unsigned char	*image_data;
    int		image_width;
    int		image_height;
    int		left_offset;
    int		top_offset;
    int		bits_per_pixel;
    int		is_interlaced;
    int		color_map_size;
    GIF_RGB_ENTRY	rgb_values[GIF_MAX_COLOR_ENTRIES];
    } __attribute__((packed)) GIF_IMAGE_DATA;

typedef struct PACKED_BUFFER_ENTRY
    {
    int		data_type;
    int		data_length;
    } PACKED_BUFFER_ENTRY;

typedef struct PACKED_BUFFER_DATA
    {
    unsigned int	num_bytes;
    void	*data;
    unsigned int	data_offset;
    unsigned int	read_data_offset;
    unsigned int	num_entries;
    PACKED_BUFFER_ENTRY	*entries;
    unsigned int	read_index;
    } PACKED_BUFFER_DATA;

typedef struct DIPOLE_BUMP_ENTRY_DATA
    {
    int		device_index;
    double	multiplier;
    } __attribute__((packed)) DIPOLE_BUMP_ENTRY_DATA;

#define	OAC_NAME_LENGTH		8		/* length of OAC client name */
#define	OAC_ABSTRACT_LENGTH	240		/* max length of OAC client abstract */

typedef struct OAC_CONFIG_INFO			/* data from OAC registration database */
    {
    char	name[OAC_NAME_LENGTH+2];	/* OAC name */
    char	keeper[USER_NAME_LEN+2];	/* OAC keeper */
    char	description[OAC_ABSTRACT_LENGTH+2];	/* OAC description */
    int		node;				/* OAC node */
    int		test_node;			/* OAC text node */
    int		oac_class;			/* OAC class */
    int		is_fe;				/* OAC is front end */
    int		oac_error;			/* OAC down error code */
    int		instantiate_operational;	/* initiate operational OAC on engine startup */
    int		instantiate_test;		/* initiate test OAC on engine startup */
    } __attribute__((packed)) OAC_CONFIG_INFO;

#define	MDAT_FRAME_NAME_LEN		64
#define	MDAT_FRAME_LONG_NAME_LEN	80
#define	MDAT_FRAME_DESCRIPTION_LEN	252

typedef struct MDAT_FRAME_INFO			/* MDAT frame information */
    {
    int		frame_number;
    int		frame_type;
    char	name[MDAT_FRAME_NAME_LEN];
    char	long_name[MDAT_FRAME_LONG_NAME_LEN];
    char	description[MDAT_FRAME_DESCRIPTION_LEN];
    float	minimum_value;
    float	maximum_value;
    int		unipolar;
    int		transmitter_device_index;
    int		receiver_device_index;
    } __attribute__((packed)) MDAT_FRAME_INFO;

#define	SETTING_APPLICATION_NAME_LEN	32
#define	SETTING_DISPLAY_NAME_LEN	32

typedef struct SETTING_REPORT_DATA
    {
    unsigned int	seconds;
    unsigned int	nanoseconds;
    void	*data;
    int		returned_length;
    int		setting_length;
    int		setting_offset;
    int		node;
    int		console;
    char	acnet_name[PROCESS_NAME_LEN+2];
    char	application_name[SETTING_APPLICATION_NAME_LEN+2];
    int		console_user_id;				/* console user ID of setting user */
    char	display_name[SETTING_DISPLAY_NAME_LEN+2];	/* display name where setting was made */
    } __attribute__((packed)) SETTING_REPORT_DATA;


/******************************************************************************/
/* 
**	function prototype typedefs
*/
/******************************************************************************/

typedef int (*abort_update_function)(int update_arg);	/* abort update function */

typedef void (*alarm_handler)(int device_index, int alarm_type, int alarm_state,
			      unsigned int raw_data, unsigned int seconds,
			      unsigned int nanoseconds, void *edp,
			      void *user_data);		/* alarm occurrence callback */

typedef void (*alarm_heartbeat)(unsigned int seconds, unsigned int nanoseconds,
				unsigned int arg1, int num_alarms,
				int arg2);		/* alarm heartbeat callback */

typedef void (*alarm_misc_callback)(unsigned int seconds,
				    unsigned int nanoseconds,
				    void *edp, void *user_data);	/* alarm miscellaneous callback */

typedef int (*array_edit_prompt)(short window_id, void *dummy,
				 int field_number,
				 FIELD_EDIT_DATA *field_data,
				 char *prompt_text,
				 int *prompt_color);			/* array_edit_c prompt callback function */

typedef void (*array_edit_update)(short window_id, void *callback_data,
				  int field_number, int changed,
				  FIELD_EDIT_DATA *field_data);		/* array_edit_c field update callback function */

typedef int (*camac_update_function)(int node, int crate);

typedef void (*clock_event_handler)(int event_number, int event_type,
				    unsigned int clinks,
				    unsigned int nanoseconds,
				    void *user_data);		/* clock event callback */

typedef int (*cns_edit_function)(short window_id,
				 TEXT_CURSOR_DATA *key_data,
				 void *callback_data,
				 CNS_EDIT_DATA *edit_data,
				 int edit_made);		/* console edit key press callback function */

typedef void (*cns_edit_init_function)(short window_id, void *callback_data);	/* console edit initialization function */

typedef void (*db_ast_function)(int);				/* database AST function (not used) */

typedef int (*decide_switch_function)(short window_id, void *callback_data,
				      int switch_number);	/* decide switch callback function */

typedef void (*fv_read_function)(short *window_id, int *row,
				 int *column);			/* file_view_read callback function */

typedef void (*help_function)(short window_id, void *callback_data,
			      HELP_FUNCTION_DATA *help_data,
			      TEXT_BLOCK_DATA *text_data);	/* input field function */

typedef int (*hilite_update_function)(short window_id, void *callback_data,
				      HILITE_UPDATE_DATA *hilite_data);	/* highlight region callback function */

typedef void (*input_field_function)(short window_id, void *callback_data,
				     INPUT_FIELD_DATA *field_data);	/* input field function */

typedef void (*intype_callback_function)(short *type, short *row,
					 short *column);	/* intype callback function */

typedef void (*key_press_function)(KEY_CALLBACK_DATA *key_data,
				   void *callback_data);	/* key press callback function */

typedef void (*knob_init_function)(KNOB_EVENT_DATA *knob_data,
				   void *callback_data);

typedef void (*list_field_function)(short window_id, void *callback_data,
				    LIST_FIELD_DATA *field_data);	/* list field function */

typedef int (*list_field_enable_function)(int entry_number);		/* list field enable/disable menu entry function */

typedef void (*ls_help_function)(short window_id, int row, int column,
				 int text_color);		/* language sensitive editor help callback function */

typedef void (*menu_bar_function)(short window_id, void *callback_data,
				  MENU_BAR_INTERRUPT_DATA *mb_data);	/* menu bar callback function */

typedef void (*menu_button_function)(short window_id, void *callback_data);	/* window menu button callback function */

typedef void (*menu_function)(short menu_id, void *callback_data,
			      MENU_INTERRUPT_DATA *menu_data);		/* menu callback function */

typedef int (*numeric_input_function)(short window_id, int row,
				      int left_column, int num_chars,
				      void *value, void *input_func_data,
				      int limit_type, void *minimum,
				      void *maximum);	/* user defined numeric input function */

typedef int (*numeric_values_function)(void *default_value,
				       void *minimum_value,
				       void *maximum_value,
				       int *basic_type,
				       unsigned int options,
				       void *values_data);		/* intrinsic values function */

typedef int (*paste_handler)(int row, int column, int length, char *paste_text, 
			     void *callback_data);	/* tv paste callback function */
					
typedef void (*pgm_tools_user_function)(void *callback_data,
					int entry_number,
					int row, int column);		/* Pgm Tools user supplied function */

typedef int (*pgm_tools_relabel_function)(char *string, int entry_number);	/* Pgm Tools relabel menu entry function */

typedef int (*pgm_tools_enable_function)(int entry_number);		/* Pgm Tools enable/disable menu entry function */

typedef void (*popup_menu_function)(void *callback_data, int item,
				    char *item_text);			/* popup menu callback function */

typedef void (*remote_error_handler)(void *handler_data,
				     REMOTE_ERROR_DATA *error_data);	/* remote error callback function */

typedef int (*replace_function)(char *original_string, char *replace_string);	/* string replace function */

typedef void (*script_end_function)(int sts, void *callback_data,
				    int dummy);				/* script ending function */

typedef void (*select_field_function)(short window_id, void *callback_data,
				      SELECT_FIELD_DATA *field_data);	/* select field function */

typedef void (*settings_handler)(int device_index, short property,
				 SETTING_REPORT_DATA *setting_data,
				 void *user_data);			/* setting callback */

typedef int (*sf_menu_function)(int row, int column, char *entry_text,
				int *index, void *callback_data,
				int multicolumn);			/* select field menu function */

typedef int (*sf_next_function)(char *entry_text, char *next_entry,
				int direction, int *index,
				void *callback_data);			/* select field next entry function */

typedef int (*sf_verify_function)(char *text, int *index,
				  void *callback_data);			/* select field verify entry function */

typedef int (*sf_verify_value_function)(int value, char *text,
					int *index,
					void *callback_data);		/* select field verify value function */

typedef void (*slider_function)(short window_id, void *callback_data,
				SLIDER_ACTION_DATA *slider_data);	/* slider callback function */

typedef void (*sr_save_output_function)(void *callback_data,
					char *output_string);		/* S/R save output function */

typedef void (*states_handler)(int vm_device_index, unsigned short state_value,
			       short type_code, unsigned int seconds,
			       unsigned int nanoseconds, void *user_data);	/* state transition callback */

typedef void (*switch_function)(short window_id, void *callback_data,
				SWITCH_ACTION_DATA *switch_data);	/* switch callback function */

typedef int (*tcp_abort_function)(void);				/* TCP abort function */

typedef void (*tcp_message_function)(char *host, int port);		/* TCP message function */

typedef void (*text_cursor_function)(short window_id,
				     TEXT_CURSOR_DATA *key_data,
				     void *callback_data);	/* text cursor key press callback function */

typedef void (*toggle_switch_function)(short window_id, void *callback_data,
				       TOGGLE_SWITCH_DATA *switch_data);	/* toggle switch function */

typedef int (*to_ascii_function)(void *value, int num_chars,
				 char *ascii_buffer, void *to_ascii_data,
				 char fill_char);		/* user defined convert numeric to ASCII function */

typedef int (*to_numeric_function)(char *ascii_buffer, int num_chars,
				   void *value, void *to_numeric_data);	/* user defined convert ASCII to numeric function */

typedef void (*window_action_callback_function)(short window_id,
						void *callback_data,
						void *action_data);	/* window action callback function */

typedef void (*window_button_function)(short window_id, void *callback_data,
				       WINDOW_FIELD_INTERRUPT_DATA *interrupt_data);	/* window button function */

typedef void (*window_callback_function)(short *window_id, void *callback_data,
					 WINDOW_INTYPE_DATA *intype_data);	/* window callback function */


typedef void (*window_destructor_function)(short window_id,
					   void *callback_data);	/* window destructor function */

typedef void (*window_expose_function)(short window_id, void *callback_data,
				       WINDOW_EXPOSE_DATA *expose_data);	/* window expose function */

typedef void (*window_occlude_function)(short window_id, void *callback_data,
					WINDOW_OCCLUDE_DATA *expose_data);	/* window occlude function */

typedef void (*window_field_function)(short window_id, void *callback_data,
				      WINDOW_FIELD_INTERRUPT_DATA *interrupt_data);	/* window field callback function */

typedef void (*window_manager_callback_function)(short window_id, int type,
						 void *callback_data,
						 void *window_data);	/* window manager callback function */

typedef void (*window_move_function)(short window_id, void *callback_data,
				     WINDOW_MOVE_DATA *move_data);	/* window move function */

typedef void (*window_op_callback_function)(short window_id, int type,
					    void *callback_data,
					    void *window_data);		/* window operation callback function */

typedef int (*window_output_function)(char *output_string, void *callback_data,
				      int line_number);	/* window output function */

typedef void (*window_register_function)(short window_id, void *callback_data,
					 void *window_data);

typedef void (*window_resize_function)(short window_id, void *callback_data,
				       WINDOW_RESIZE_DATA *resize_data);	/* window resize function */

typedef void (*window_scroll_function)(short window_id, void *callback_data,
				       WINDOW_SCROLL_DATA *scroll_data);	/* window scroll function */

typedef void (*winput_prompt)(short windowid, void *dummy,
			      int field_number);			/* winput(_c) prompt callback function */

typedef void (*winput_term)(short windowid);				/* winput(_c) termination handler function */

typedef void (*winput_update)(short windowid, void *callback_data,
			      int field_num, int chngd,
			      void *new_value);				/* winput(_c) field update callback function */

typedef void (*wn_action_callback_function)(int window_id,
					    void *callback_data,
					    void *action_data);		/* window action callback function */

typedef void (*wn_destructor_function)(int window_id,
				       void *callback_data);		/* window destructor function */

typedef void (*wn_expose_function)(int window_id, void *callback_data,
				   WN_EXPOSE_DATA *expose_data);	/* window expose function */

typedef void (*wn_occlude_function)(int window_id, void *callback_data,
				    WN_OCCLUDE_DATA *expose_data);	/* window occlude function */

typedef void (*wn_select_field_function)(int window_id, void *callback_data,
					 SELECT_FIELD_DATA *field_data);	/* select field function */

typedef void (*wn_switch_function)(int window_id, void *callback_data,
				   SWITCH_ACTION_DATA *switch_data);	/* graphics window switch callback function */

typedef int (*digital_control_user_function)(void *callback_data,
					     int entry_number,
					     int row, int column);	/* digital control user supplied function */

typedef int (*enum_setting_user_function)(void *callback_data,
					  int entry_number,
					  int row, int column);		/* enumerated value setting user supplied function */

#endif