clib_friend_h

/*
**	Copyright 2011-2017, Fermi Research Alliance, LLC.  All rights reserved.
*/
/******************************************************************************/
/* clib_friend.h
**
**	This is a header file containing function prototypes for
**	CLIB routines that are needed by other libraries.
**
**	V0.0	B S Hendricks / Accelerator Controls		11-Apr-11
**	Created
**
*/
/******************************************************************************/

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

#include "cnsparam.h"
#include "cns_data_structs.h"
#include "utilnet.h"

/******************************************************************************/
/* 
**	defined constants for argument values for CLIB friend routines
*/
/******************************************************************************/

#define	ALL_CAMAC_CRATES	(-1)


/******************************************************************************/
/* 
**	returned status definitions for CLIB friend routines
*/
/******************************************************************************/


/******************************************************************************/
/*
**	function prototypes for friend routines in CLIB
*/
/******************************************************************************/

#ifdef __cplusplus
extern "C" {
#endif

void db_setup_clib(char const *account, char const *password = 0);
int calculate_midnight_time(unsigned int clink_time,
			    unsigned int *midnight_time);
int calculate_month_ago_time(unsigned int clink_time, int num_months,
			     unsigned int *month_ago_time);
int calculate_month_from_now_time(unsigned int clink_time, int num_months,
				  unsigned int *month_from_now_time);
int calculate_start_of_hour(unsigned int clinks_time,
			    unsigned int *hour_time,
			    unsigned int options);
int calculate_start_of_minute(unsigned int clinks_time,
			      unsigned int *minute_time,
			      unsigned int options);
int calculate_start_of_month(unsigned int clink_time,
			     unsigned int *start_of_month,
			     unsigned int options);
int calculate_start_of_shift(unsigned int clinks_time,
			     unsigned int *shift_time,
			     unsigned int options);
int calculate_start_of_week(unsigned int clinks_time,
			    unsigned int *week_time);
int calculate_start_of_year(unsigned int clink_time,
			    unsigned int *start_of_year,
			    unsigned int options);
int console_set_is_enabled(void);
int convert_console_class(char const *string, int string_length,
			  unsigned int *console_class);
int convert_hex_string(char const *string, int passed_length,
		       unsigned int *value);
int convert_int_string(char const *string, int length, int *value);
int convert_trunk_node_string(char const *string, int length, int *value);
int evaluate_logger_list_specifier(char *value_string, int *logger_node,
				   int *logger_list);
int evaluate_logger_list_value(char *value_string, int *logger_list);
int get_composite_devices_db_and_owner(char *db_name, char *owner_name);
int get_console_class_settable_devices(unsigned int console_class,
				       int *num_devices,
				       int **device_indices);
void get_oaf_registration_db_and_owner(char *db_name, char *owner_name);
int get_sibling_list(int device_index, int include_first, int max_return,
		     int *num_siblings, int *sibling_dis);
int get_sql_query_devices(char *sql_string, int query_by_name,
			  int *num_devices, int **device_indices);
void get_states_description_db_and_owner(char *db_name, char *owner_name);
int get_wg_list_devices(char *list_name, int max_return, int *num_devices,
			int *device_indices);
int gpib_get_device_c(int node, int gpib_address, int *device_index,
		      int *binary_device);
int gpib_maximum_buffer_length(void);
int gpib_read_binary_c(char *buffer, int num_bytes, int gpib_address,
		       int *bytes_returned);
int intype_callback_level(void);
int is_gas_house_name(int node, char const *string, int *house_code,
		      int *actual_node);
int is_gas_module_name(int node, char const *string, int *module_type);
int is_leap_year_c(int year);
int is_tv_window_id_c(int window_id);
int is_valid_window_id_c(int window_id);
int month_index_to_string(int month_index, char *month_string,
			  int want_long=FALSE);
int mooc_use_class_field(short node);
int parse_ssdn_byte_string(char *string, unsigned char *byte_value);
int parse_ssdn_search_string(char *string, DIO_SSDN_TO_DI_REQ *ssdn_search);
int parse_ssdn_word_string(char *string, unsigned short *word_value);
int read_device_download_file_c(int node, int index, int *num_devices,
				int *device_indices, short *properties);
short sr_set_save_node_c(short node);
int time_interval_dst_correction_c(unsigned int start_time,
				   unsigned int end_time);
int timeval_diff(struct timeval *time_1, struct timeval *time_2,
		 unsigned int *delta_seconds, unsigned int *delta_usec);
int util_add_to_paste_buffer_c(int console, char *string,
			       int end_of_paste=FALSE);
int util_console_display_c(int console, char *display_name);
int util_console_message_c(int console, char *message, int text_color,
			   int num_beeps);
int util_console_message_delete_c(int console);
int util_console_user_c(int console, char *user_name);
int util_daq_redirection_c(int console, UTIL_UTIL_REDIRECT *redirect_info);
int util_delete_logical_value_c(int console, char const *logical_name);
int util_display_url_c(int console, char *url);
int util_draw_image_c(int console, int window_id, int image_type,
		      char *image_name, int image_number,
		      int display_type, int resize_window,
		      int x_pos, int y_pos, int color_map);
int util_end_paste_c(int console);
int util_find_instances_c(int node, int *count, char *process_names);
int util_find_processes_c(int console, int search_type,
			  void const *search_value, int *num_processes,
			  int *num_ret_processes,
			  UTIL_FIND_PROCESS_ENTRY **processes);
int util_get_clock_type_c(int console, int *clock_type);
int util_get_console_config_info_c(int console, UTIL_CONSOLE_INFO *config_info);
int util_get_console_dpm_info_c(int console, UTIL_DPM_INFO *dpm_info);
int util_get_date_c(int console, unsigned int *clinks,
		    unsigned long long *milliseconds=(unsigned long long *) NULL);
int util_get_default_node_c(int console, int *default_node);
int util_get_env_value_c(int console, char const *env_name, char *env_value);
int util_get_logical_value_c(int console, char const *logical_name,
			     char *logical_value);
int util_get_program_status_c(int console, int slot,
			      asbinfo_reply_t *status_info);
int util_get_setting_lock_info_c(int console, int *is_unlocked,
				 int *lock_value=(int *) NULL,
				 int *time_left=(int *) NULL,
				 unsigned int *unlock_time=(unsigned int *) NULL);
int util_get_task_name_c(int console, char *task_name, short *node);
int util_get_window_pixel_sizes_c(int console,
				  UTIL_WINDOW_PIXEL_SIZES *size_info);
int util_get_window_write_time_c(int console, int unused,
				 int window_id, unsigned int *write_time);
int util_make_console_log_entry_c(int console, char *string);
int util_pid_to_process_name_c(int console, int pid, char *process_name);
int util_ping_c(int console);
int util_play_beep_c(int console, int volume);
int util_process_info_c(int console, int pid, PID_INFO *process_info);
int util_process_name_to_pid_c(int console, char const *process_name, int *pid);
int util_restart_alarm_daemon_c(int console);
int util_restart_alarm_display_c(int console, int instance);
int util_restart_console_c(int console, int instance);
int util_restart_util_c(int console, int instance);
int util_save_screen_image_c(int console, int window_id, int image_type,
			     char *file_name, unsigned int options);
int util_send_pid_signal_c(int console, int pid, int signal);
int util_send_process_signal_c(int console, char const *process_name,
			       int signal, int *pid=(int *) NULL);
int util_set_logical_value_c(int console, char const *logical_name,
			     char const *logical_value);
int util_set_window_title_c(int console, int window_id, char *title,
			    char *icon_text);
int week_day_index_to_string_c(int week_day_index, char *week_day_string,
			       int want_long=FALSE);

#ifdef __cplusplus
}
#endif


/******************************************************************************/
/*
**	equivalent name definitions for CLIB friend routines
*/
/******************************************************************************/

#define	CALCULATE_MIDNIGHT_TIME		calculate_midnight_time
#define	CALCULATE_MONTH_AGO_TIME	calculate_month_ago_time
#define	CALCULATE_START_OF_HOUR		calculate_start_of_hour
#define	CALCULATE_START_OF_MINUTE	calculate_start_of_minute
#define	CALCULATE_START_OF_MONTH	calculate_start_of_month
#define	CALCULATE_START_OF_SHIFT	calculate_start_of_shift
#define	CALCULATE_START_OF_WEEK		calculate_start_of_week
#define	CALCULATE_START_OF_YEAR		calculate_start_of_year
#define	CONSOLE_SET_IS_ENABLED		console_set_is_enabled
#define	CONSOLE_WINDOW_CENTER_C		console_window_center_c
#define	CONSOLE_WINDOW_HOME_C		console_window_home_c
#define	CONSOLE_WINDOW_ICONIFY_C	console_window_iconify_c
#define	CONSOLE_WINDOW_LOWER_C		console_window_lower_c
#define	CONSOLE_WINDOW_POSITION_C	console_window_position_c
#define	CONSOLE_WINDOW_RAISE_C		console_window_raise_c
#define	CONSOLE_WINDOW_SET_SIZE_C	console_window_set_size_c
#define	CONVERT_CONSOLE_CLASS		convert_console_class
#define	CONVERT_HEX_STRING		convert_hex_string
#define	CONVERT_INT_STRING		convert_int_string
#define	EVALUATE_LOGGER_LIST_SPECIFIER	evaluate_logger_list_specifier
#define	EVALUATE_LOGGER_LIST_VALUE	evaluate_logger_list_value
#define	GET_CONSOLE_CLASS_SETTABLE_DEVICES	get_console_class_settable_devices
#define	GET_OAF_REGISTRATION_DB_AND_OWNER	get_oaf_registration_db_and_owner
#define	GET_SIBLING_LIST		get_sibling_list
#define	GET_SQL_QUERY_DEVICES		get_sql_query_devices
#define	GET_STATES_DESCRIPTION_DB_AND_OWNER	get_states_description_db_and_owner
#define	GET_WG_LIST_DEVICES		get_wg_list_devices
#define	GPIB_GET_DEVICE_C		gpib_get_device_c
#define	GPIB_MAXIMUM_BUFFER_LENGTH	gpib_maximum_buffer_length
#define	GPIB_READ_BINARY_C		gpib_read_binary_c
#define	INTYPE_CALLBACK_LEVEL		intype_callback_level
#define	IS_GAS_HOUSE_NAME		is_gas_house_name
#define	IS_GAS_MODULE_NAME		is_gas_module_name
#define	IS_LEAP_YEAR_C			is_leap_year_c
#define	IS_TV_WINDOW_ID_C		is_tv_window_id_c
#define	IS_VALID_WINDOW_ID_C		is_valid_window_id_c
#define	MONTH_INDEX_TO_STRING		month_index_to_string
#define	MOOC_USE_CLASS_FIELD		mooc_use_class_field
#define	PARSE_SSDN_SEARCH_STRING	parse_ssdn_search_string
#define	READ_DEVICE_DOWNLOAD_FILE_C	read_device_download_file_c
#define	READ_DEVICE_FILE		read_device_file
#define	SR_SET_SAVE_NODE_C		sr_set_save_node_c
#define	TIME_INTERVAL_DST_CORRECTION_C	time_interval_dst_correction_c
#define	TIMEVAL_DIFF			timeval_diff
#define	UTIL_ADD_TO_PASTE_BUFFER_c	util_add_to_paste_buffer_c
#define	UTIL_CONSOLE_DISPLAY_C		util_console_display_c
#define	UTIL_CONSOLE_MESSAGE_C		util_console_message_c
#define	UTIL_CONSOLE_MESSAGE_DELETE_C	util_console_message_delete_c
#define	UTIL_CONSOLE_USER_C		util_console_user_c
#define	UTIL_DAQ_REDIRECTION_C		util_daq_redirection_c
#define	UTIL_DISPLAY_URL_C		util_display_url_c
#define	UTIL_DRAW_IMAGE_C		util_draw_image_c
#define	UTIL_END_PASTE_C		util_end_paste_c
#define	UTIL_FIND_INSTANCES_C		util_find_instances_c
#define	UTIL_FIND_PROCESSES_C		util_find_processes_c
#define	UTIL_GET_CLOCK_TYPE_C		util_get_clock_type_c
#define	UTIL_GET_CONSOLE_CONFIG_INFO_C	util_get_console_config_info_c
#define	UTIL_GET_CONSOLE_DPM_INFO_C	util_get_console_dpm_info_c
#define	UTIL_GET_DATE_C			util_get_date_c
#define	UTIL_GET_DEFAULT_NODE_C		util_get_default_node_c
#define	UTIL_GET_ENV_VALUE_C		util_get_env_value_c
#define	UTIL_GET_LOGICAL_VALUE_C	util_get_logical_value_c
#define	UTIL_GET_PROGRAM_STATUS_C	util_get_program_status_c
#define	UTIL_GET_SETTING_LOCK_INFO_C	util_get_setting_lock_info_c
#define	UTIL_GET_TASK_NAME_C		util_get_task_name_c
#define	UTIL_GET_WINDOW_PIXEL_SIZES_C	util_get_window_pixel_sizes_c
#define	UTIL_GET_WINDOW_WRITE_TIME_C	util_get_window_write_time_c
#define	UTIL_MAKE_CONSOLE_LOG_ENTRY_C	util_make_console_log_entry_c
#define	UTIL_PID_TO_PROCESS_NAME_C	util_pid_to_process_name_c
#define	UTIL_PING_C			util_ping_c
#define	UTIL_PLAY_BEEP_C		util_play_beep_c
#define	UTIL_PROCESS_INFO_C		util_process_info_c
#define	UTIL_PROCESS_NAME_TO_PID_C	util_process_name_to_pid_c
#define	UTIL_SAVE_SCREEN_IMAGE_C	util_save_screen_image_c
#define	UTIL_SEND_PID_SIGNAL_C		util_send_pid_signal_c
#define	UTIL_SEND_PROCESS_SIGNAL_C	util_send_process_signal_c
#define	UTIL_SET_WINDOW_TITLE_C		util_set_window_title_c
#define	WEEK_DAY_INDEX_TO_STRING_C	week_day_index_to_string_c

#endif