📄 datademo.c
字号:
/************************************************************************//* SISCO SOFTWARE MODULE HEADER *****************************************//************************************************************************//* (c) Copyright Systems Integration Specialists Company, Inc., *//* 1986 - 2001, All Rights Reserved. *//* *//* MODULE NAME : datademo.c *//* PRODUCT(S) : MMSEASE *//* *//* MODULE DESCRIPTION : *//* *//* GLOBAL FUNCTIONS DEFINED IN THIS MODULE : *//* *//* MODIFICATION LOG : *//* Date Who Rev Comments *//* -------- --- ------ ------------------------------------------- *//* 12/20/01 EJV 01 Changed to use ASN1R *//* 04/15/97 DSF 7.00 MMSEASE 7.0 release. See MODL70.DOC for *//* history. *//************************************************************************/#include "glbtypes.h"#include "sysincs.h"#if (SYSTEM_SEL & (MSOFT | OS2))#include <conio.h>#endif#if (SYSTEM_SEL & (OPEN_VMS))ST_INT kbhit ();#endif#include "mem_chk.h"#include "mms_usr.h" /* to access MMS fucntions, variables */#include "mms_vvar.h"#include "mms_vvmd.h"#include "mms_log.h"#include "mms_ufun.h"#include "mmsop_en.h"#include "asn1defs.h"#include "userdefs.h"#include "fkeydefs.h" /* Function key handling */#include "scrndefs.h" /************************************************************************//************************************************************************/static ST_CHAR *thisFileName = __FILE__;#ifdef DEBUG_SISCO#define LOGMSG0(a) slog (sLogCtrl,1,NULL,0,a);#define LOGMSG1(a,b) slog (sLogCtrl,1,NULL,0,a,b);#define LOGHEX(a,b) slogHex (sLogCtrl,1,NULL,0,a,b);#else#define LOGMSG0(a) #define LOGMSG1(a,b) #define LOGHEX(a,b) #endifstatic ST_CHAR *str1_tdl = "{(b)Bool,(s)Short,(l)Long}";/* This is the basic data structure type we will be working with */struct str1 { ST_BOOLEAN b; ST_INT16 s; ST_INT32 l; };struct str1_P2 { ST_INT32 l; ST_BOOLEAN b; };static ST_UCHAR *asn1_aa = (ST_UCHAR *) "\xA5\x03\x81\x01\x73";static struct named_type *str1_type;static struct str1 server_str1;static struct str1 client_str1;#define ASN1_BUF_SIZE 100static ST_UCHAR asn1_buf[ASN1_BUF_SIZE];static ST_INT confirm_rcvd;static ST_INT num_read_tests = 1;static ST_INT num_write_tests = 1;static ST_INT num_info_tests = 1;static ST_CHAR dest_buf[10][100];/************************************************************************/static ST_VOID vmdt_rdvars_conf (MMSREQ_PEND *req_ptr);static ST_VOID vmdt_wrvars_conf (MMSREQ_PEND *req_ptr);static ST_VOID vmdt_read_ind (MMSREQ_IND *req_ptr);static ST_VOID vmdt_write_ind (MMSREQ_IND *req_ptr);static ST_VOID vmdt_info_ind (MMSREQ_IND *req_ptr);static ST_VOID send_test_read (ST_INT indx, ST_INT chan);static ST_VOID send_test_write (ST_INT indx, ST_INT chan);static ST_VOID send_test_info (ST_INT indx, ST_INT chan);static ST_VOID set_data_test_menu (ST_VOID);static ST_VOID set_data_test_param (ST_VOID);static ST_VOID reset_data_test_param (ST_VOID);static ST_VOID do_print_aa_hw (ST_VOID);static ST_VOID do_print_server_str1 (ST_VOID);static ST_VOID do_client_data_tests (ST_VOID);static ST_VOID do_data_convert (ST_VOID);/************************************************************************//************************************************************************//* Test menu *//************************************************************************/ST_VOID do_data_tests (ST_VOID) {#if MMS_VA_ENST_VOID (*save_menu)(ST_VOID); save_menu = menu_set_fun; set_data_test_menu (); set_data_test_param (); menu_service (); /* Service keyboard/MMS until exit from menu */ menu_set_fun = save_menu; (*menu_set_fun) (); reset_data_test_param ();#endif }/************************************************************************/#if MMS_VA_EN/************************************************************************/static ST_VOID set_data_test_menu (ST_VOID) {ST_CHAR c; c = 'F'; CLEARSCR; print_demo (); printf ("\n\n"); printf ("\t %c1 - DO CLIENT ALTERNATE ACCESS VARIABLE TESTS\n",c); printf ("\t %c2 - PRINT CURRENT SERVER ALTERNATE ACCESS VARIABLE VALUES\n",c); printf ("\t %c3 - PRINT HIGH WATER AA VALUES\n",c); printf ("\t %c4 - LOW LEVEL DATA CONVERSION TESTS (NO NAMED TYPE) \n",c); printf ("\t %c10 - EXIT\n",c); flush_keys (); fun_null (); funct_1 = do_client_data_tests; funct_2 = do_print_server_str1; funct_3 = do_print_aa_hw; funct_4 = do_data_convert; menu_set_fun = set_data_test_menu; /* used to reset the menu */ }/************************************************************************//************************************************************************/static ST_VOID set_data_test_param (ST_VOID) {ST_INT asn1_len;ST_UCHAR *asn1_start;static ST_INT firstTime = SD_TRUE;struct var_acc_addr adr;struct domain_objs *dom;struct object_name type;#if 0 m_data_algn_tbl = m_packed_data_algn_tbl;#endif#if 1 m_data_algn_tbl = m_def_data_algn_tbl;#endif/* Set the indication and confirm function pointers to come here */ mms_conf_serve_fun[101] = vmdt_rdvars_conf; mms_conf_serve_fun[102] = vmdt_wrvars_conf; mms_ind_serve_fun[4] = vmdt_read_ind; mms_ind_serve_fun[5] = vmdt_write_ind; mms_ind_serve_fun[79] = vmdt_info_ind; if (firstTime) { firstTime = SD_FALSE;/* Create named type for the variable of interest *//* First create the ASN.1 type from TDL */ asn1_len = ASN1_BUF_SIZE; asn1_start = ms_mk_asn1_type (&asn1_len,asn1_buf,str1_tdl); if (!asn1_start) { LOGMSG0 ("TDL to ASN.1 type error"); return; }/* Now add the named type */ str1_type = ms_add_named_type (&m_vmd_select->vmd_wide, "str1_type", asn1_start, asn1_len); if (!str1_type) { LOGMSG0 ("TDL to ASN.1 type error"); return; }/* Now add the named variable */ dom = &m_vmd_select->vmd_wide; adr.addr_tag = NUM_ADDR; adr.addr.num_addr = (ST_UINT32) &server_str1; type.object_tag = VMD_SPEC; strcpy (type.obj_name.vmd_spec,"str1_type"); /* select type */ if (!ms_add_named_var (dom,"str1",&type,&adr,0)) wait_msg ("str1 ADD SD_FAILURE"); }/* Initialize the 'server' copy of str1 */ server_str1.b = 1; server_str1.s = 669; server_str1.l = 556110L;/* Initialize the 'client' copy of str1 */ client_str1.b = 0; client_str1.s = -123; client_str1.l = -52L; }/************************************************************************/static ST_VOID reset_data_test_param (ST_VOID) {/* Reset the indication and confirm function pointers */ mms_conf_serve_fun[101] = u_mv_read_vars_conf; mms_conf_serve_fun[102] = u_mv_write_vars_conf; mms_ind_serve_fun[4] = u_read_ind; mms_ind_serve_fun[5] = u_write_ind; mms_ind_serve_fun[79] = u_info_ind; }/************************************************************************//************************************************************************/static ST_VOID do_print_aa_hw (ST_VOID) { printf ("\n Minimum req'd value for 'm_max_dec_aa' was : %d",m_hw_dec_aa); printf ("\n Minimum req'd value for 'm_max_rt_aa_ctrl' was : %d",m_hw_rt_aa_ctrl); wait_msg (" Hit a key to continue ..."); (*menu_set_fun) (); }/************************************************************************/static ST_VOID do_print_server_str1 (ST_VOID) { printf ("\n Current server 'str1' values : "); printf ("\n b = %d", server_str1.b); printf ("\n s = %d", (int) server_str1.s); printf ("\n l = %ld", server_str1.l); wait_msg (" Hit a key to continue ..."); (*menu_set_fun) (); }/************************************************************************//************************************************************************/static ST_VOID do_client_data_tests (ST_VOID) {ST_INT i;ST_INT chan; printf ("\n Issue client variable access requests"); if (!get_chan (&chan)) { (*menu_set_fun)(); return; } for (i = 0; i < num_read_tests; ++i) send_test_read (i,chan); for (i = 0; i < num_write_tests; ++i) send_test_write (i,chan); for (i = 0; i < num_info_tests; ++i) send_test_info (i,chan); }/************************************************************************//************************************************************************//************************************************************************/static ST_VOID send_test_read (ST_INT indx, ST_INT chan) {ST_INT num_var;ST_INT i;struct read_req_info *info;struct mv_read_req_info *mv;struct mv_read_req_info *mv_info_ptr;struct variable_list *vl;MMSREQ_PEND *req_ptr;struct alt_acc_el aa1[1];struct alt_acc_el aa2[2];struct alt_acc_el aa3[2];struct alt_acc_el aa4[1]; num_var = 4;/* Need to calloc a buffer for the VM information, since it needs to be *//* committed until the confirm is received */ mv_info_ptr = (struct mv_read_req_info *) chk_calloc (num_var,sizeof (struct mv_read_req_info)); info = (struct read_req_info *) ((ST_CHAR *)dest_buffer); info->spec_in_result = SD_FALSE; info->va_spec.var_acc_tag = VA_SPEC_NAMED; info->va_spec.num_of_variables = 4; vl = (struct variable_list *) (info+1); mv = mv_info_ptr;/* All elements of this read are about the same, except for the way the *//* returned data is to be handled. */ for (i = 0; i < num_var; ++i, ++vl, ++mv) { if (i == 3) /* for the 4th element only */ { vl->alt_access_pres = SD_TRUE; /* we supply ASN1.1 AA */ vl->alt_access.data = asn1_aa; vl->alt_access.len = 5; } else /* for all others */ vl->alt_access_pres = SD_FALSE; /* let the VM make ASN1.1 AA */ vl->var_spec.var_spec_tag = VA_SPEC_NAMED; vl->var_spec.vs.name.object_tag = VMD_SPEC; strcpy (vl->var_spec.vs.name.obj_name.vmd_spec,"str1");/* Now VM information */ mv->i.type = str1_type; mv->i.data_ptr = dest_buf[i]; mv->i.alt_acc_pres = SD_TRUE; }/* Now do the AA specifications for each variable *//* Non-packed, single component ('s') only */ mv = mv_info_ptr; mv->i.alt_acc_data_packed = SD_FALSE; mv->i.alt_acc.num_aa = 1; mv->i.alt_acc.aa = aa1; aa1[0].comp_name_pres = SD_FALSE; aa1[0].sel_type = AA_COMP; strcpy (aa1[0].u.component,"s");/* Non-packed, two components ('s' and 'l' */ mv++; mv->i.alt_acc_data_packed = SD_FALSE; mv->i.alt_acc.num_aa = 2; mv->i.alt_acc.aa = aa2; aa2[0].comp_name_pres = SD_FALSE; aa2[0].sel_type = AA_COMP; strcpy (aa2[0].u.component,"s"); aa2[1].comp_name_pres = SD_FALSE; aa2[1].sel_type = AA_COMP;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -