📄 mmsavar.c
字号:
/************************************************************************//************************************************************************//* do_gettype *//* create and send get type name definition request. *//************************************************************************/ST_VOID do_gettype (ST_VOID) {#if MMS_GETTYPE_EN & REQ_ENGETTYPE_REQ_INFO info;ST_INT chan;ST_BOOLEAN data_entered; if (!get_chan (&chan)) { (*menu_set_fun) (); return; } nxt_buf = source_buf; data_entered = get_objname (&info.type_name); if (data_entered && !mp_gettype (chan, &info)) print_req_error (); else { if (num_reps) /* if this an auto repeat - */ { if (start_cont ()) /* wait for 1st to complete */ return; num_outstanding = 1; /* we already sent 1 */ while (rep_count < num_reps) /* if enough done - */ { if (!mp_gettype (chan, &info)) break; num_outstanding++; if (cont_serve ()) /* if user hit a key */ return; } cont_done (); /* display results */ } } (*menu_set_fun) ();#endif }/************************************************************************//* do_deftype *//* create and send a define type name request. *//************************************************************************/ST_VOID do_deftype (ST_VOID) {#if MMS_DEFTYPE_EN & REQ_ENDEFTYPE_REQ_INFO info;ST_INT chan;ST_BOOLEAN data_entered;ST_INT len; if (!get_chan (&chan)) { (*menu_set_fun) (); return; } nxt_buf = source_buf; data_entered = get_objname (&info.type_name); if (data_entered) { info.type_spec.data = (ST_UCHAR *)nxt_buf; if (len = get_var_data ("Type Specification", info.type_spec.data)) { info.type_spec.len = len; nxt_buf += len; } else data_entered = SD_FALSE; } if (data_entered && !mp_deftype (chan, &info)) print_req_error (); else { if (num_reps) /* if this an auto repeat - */ { if (start_cont ()) /* wait for 1st to complete */ return; num_outstanding = 1; /* we already sent 1 */ while (rep_count < num_reps) /* if enough done - */ { if (!mp_deftype (chan, &info)) break; num_outstanding++; if (cont_serve ()) /* if user hit a key */ return; } cont_done (); /* display results */ } } (*menu_set_fun) ();#endif }/************************************************************************//* do_deltype *//* create and send a delete type name request. *//************************************************************************/ST_VOID do_deltype (ST_VOID) {#if MMS_DELTYPE_EN & REQ_ENDELTYPE_REQ_INFO *info;ST_INT chan;ST_BOOLEAN data_entered;ST_INT num;ST_BOOLEAN done;ST_CHAR temp [256];OBJECT_NAME *obj_ptr; if (!get_chan (&chan)) { (*menu_set_fun) (); return; } info = (DELTYPE_REQ_INFO *) dest_buffer; nxt_buf = source_buf; printf ("\n (0:Specific, 1:AA-Specific, 2:Domain, 3:VMD)"); printf ("\n Enter Scope of Delete (default = 0) :"); num = DELVAR_SPEC; intget (&num); if (num != DELTYPE_SPEC && num != DELTYPE_AA && num != DELTYPE_DOM && num != DELTYPE_VMD) { num = DELVAR_SPEC; } info->scope = num; done = SD_FALSE; info->tnames_pres = SD_FALSE; info->num_of_tnames = 0; obj_ptr = (OBJECT_NAME *) (info + 1); while (!done) { data_entered = get_objname (obj_ptr); if (data_entered) { info->tnames_pres = SD_TRUE; info->num_of_tnames++; obj_ptr++; } else done = SD_TRUE; } printf (" Enter Domain Name : (O) "); if (strget (temp)) { info->dname_pres = SD_TRUE; temp [MAX_IDENT_LEN] = '\x00'; strcpy (info->dname,temp); } else info->dname_pres = SD_FALSE; if (!mp_deltype (chan, info)) print_req_error (); else { if (num_reps) /* if this an auto repeat - */ { if (start_cont ()) /* wait for 1st to complete */ return; num_outstanding = 1; /* we already sent 1 */ while (rep_count < num_reps) /* if enough done - */ { if (!mp_deltype (chan, info)) break; num_outstanding++; if (cont_serve ()) /* if user hit a key */ return; } cont_done (); /* display results */ } } (*menu_set_fun) ();#endif }/************************************************************************//* do_add_named_type *//************************************************************************/ST_VOID do_add_named_type (ST_VOID) {#if MMS_VA_ENOBJECT_NAME *obj;DOMAIN_OBJS *dom;OBJECT_NAME temp_obj;ST_RET result;ST_INT chan; nxt_buf = source_buf; if (!get_chan (&chan)) { (*menu_set_fun) (); return; } obj = &temp_obj; printf ("\n Enter Scope to add Standard Named Types : "); if (make_objname (obj)) { if ((dom = ms_find_dom_objs (obj, chan)) != NULL) { result = ms_add_std_types (dom); if (!result) printf ("\n All Standard Named Types have been added to this object."); else if (result < 0) printf ("\n Standard Named Types were already present. They were not readded."); else printf ("\n Standard Named Types were not added."); wait_msg (""); } } (*menu_set_fun) ();#endif }/************************************************************************//* do_add_custom_type *//************************************************************************/ST_VOID do_add_custom_type (ST_VOID) {#if MMS_VA_ENOBJECT_NAME *obj;DOMAIN_OBJS *dom;OBJECT_NAME temp_obj;ST_INT data_entered;ST_INT chan;ST_CHAR temp[256];ST_UCHAR *asn1_buf;ST_UCHAR *asn1_beg;ST_INT asn1_len; nxt_buf = source_buf; if (data_entered = get_chan (&chan)) { obj = &temp_obj; printf ("\n Enter new Type Name : "); data_entered = get_objname (obj); } if (data_entered) { if (dom = ms_find_dom_objs (obj, chan)) { printf ("\n Enter the Type Specification using SISCO TDL notation :\n "); strget (temp); asn1_buf = (ST_UCHAR *)dest_buffer; asn1_len = 10000; } else { wait_msg ("\n The specified Domain does not exist in the MMS-EASE VM."); data_entered = SD_FALSE; } } else wait_msg ("\n Must enter all required information"); if (data_entered) { if (asn1_beg = ms_mk_asn1_type (&asn1_len,asn1_buf,temp)) { asn1_buf = (ST_UCHAR *) chk_malloc (asn1_len); memcpy (asn1_buf,asn1_beg,asn1_len); printf ("\n ASN.1 Encoded Type Specification is : "); list_bytes (asn1_beg, asn1_len); } else { print_perror_wait (mms_op_err,"\n Invalid notation : "); data_entered = SD_FALSE; } } if (data_entered) { if (ms_add_named_type (dom, obj->obj_name.item_id, asn1_buf, asn1_len)) { wait_msg ("\n The specified type has been added to the MMS-EASE VM."); } else { chk_free (asn1_buf); wait_msg ("\n Could not add the specified type. Invalid type spec."); } } (*menu_set_fun) ();#endif }/************************************************************************//* do_del_named_type *//************************************************************************/ST_VOID do_del_named_type (ST_VOID) {#if MMS_VA_ENOBJECT_NAME obj;DOMAIN_OBJS *dom;ST_INT chan;ST_RET ret; nxt_buf = source_buf; if (!get_chan (&chan)) { (*menu_set_fun) (); return; } printf (" \n Enter Type Name : "); if (get_objname (&obj)) { dom = ms_find_dom_objs (&obj, chan); if ((ret = ms_del_named_type (dom,obj.obj_name.item_id))) print_perror_wait (ret,"\n Delete Error : "); } (*menu_set_fun) ();#endif }/************************************************************************//* do_list_named_type *//************************************************************************/ST_VOID do_list_named_type (ST_VOID) {#if MMS_VA_ENOBJECT_NAME *obj;DOMAIN_OBJS *dom;OBJECT_NAME temp_obj;NAMED_TYPE *cur_type;ST_INT chan; nxt_buf = source_buf; chan = 0; obj = &temp_obj; if (make_objname (obj)) { dom = ms_find_dom_objs (obj, chan); if (dom == NULL) printf ("\n Domain Not Found"); else { cur_type = dom->type_list; if (cur_type == NULL) printf ("\n No Types in this Scope"); else { if (ask ("\n Do you want to expand Types (y,n) (default = n) : ", SD_FALSE)) { while (cur_type != NULL) { CLEARSCR; printf ("\n"); printf ("\n Named Type : %s\n\n", cur_type->type_name); printf ("\n Blocked Length : %d",cur_type->blocked_len); printf ("\n Number References : %d",cur_type->nref); printf ("\n MMS Deletable : "); if (cur_type -> deletable) printf ("TRUE"); else printf ("FALSE"); if (cur_type->erased) printf ("\n ERASED"); printf ("\n\n"); ms_print_runtime (cur_type); wait_msg ("\n Hit any key for next type "); cur_type = (NAMED_TYPE *) list_get_next (dom->type_list, cur_type); } } else { CLEARSCR; printf ("\n\n\n\n"); printf ("\n Types associated with this Object are: \n"); while (cur_type != NULL) { printf ("\n %s", cur_type->type_name); cur_type = (NAMED_TYPE *) list_get_next (dom->type_list, cur_type); } } } } wait_msg (""); } (*menu_set_fun) ();#endif }/************************************************************************//* do_add_named_var *//************************************************************************/ST_VOID do_add_named_var (ST_VOID) {#if MMS_VA_ENDOMAIN_OBJS *dom;OBJECT_NAME var;OBJECT_NAME type;VAR_ACC_ADDR vacc;ST_INT chan; nxt_buf = source_buf; if (!get_chan (&chan)) { (*menu_set_fun) (); return; } printf ("\n Select Variable Scope and Name : "); if (get_objname (&var)) { if ((dom = ms_find_dom_objs (&var, chan)) != NULL) { printf (" \nSelect Type : "); if (get_objname (&type)) { if (get_address (&vacc)) { if ((ms_add_named_var (dom, var.obj_name.item_id, &type, &vacc, chan))== NULL) { printf ("\n '%s' was not added.",var.obj_name.item_id); } else { printf ("\n '%s' was added.", var.obj_name.item_id); } wait_msg (""); } } } } (*menu_set_fun) ();#endif }/************************************************************************//* do_del_named_var *//************************************************************************/ST_VOID do_del_named_var (ST_VOID) {#if MMS_VA_ENOBJECT_NAME obj;DOMAIN_OBJS *dom;ST_INT chan;ST_RET ret; nxt_buf = source_buf; if (!get_chan (&chan)) { (*menu_set_fun) (); return; } printf (" \nEnter Variable Name : "); if (get_objname (&obj)) { dom = ms_find_dom_objs (&obj, chan); if ((ret = ms_del_named_var (dom,obj.obj_name.item_id))) print_perror_wait (ret,"\n Delete Error : "); } (*menu_set_fun) ();#endif }/************************************************************************//* list_named_var *//************************************************************************/static ST_VOID list_named_var (NAMED_VAR *cur_var) {#if MMS_VA_EN printf (" \n %s : Type = %s", cur_var->varname, cur_var->type->type_name);#endif }/************************************************************************//* do_list_named_var *//************************************************************************/ST_VOID do_list_named_var (ST_VOID) {#if MMS_VA_ENOBJECT_NAME *obj;DOMAIN_OBJS *dom;OBJECT_NAME temp_obj;ST_INT chan;ST_CHAR tname[MAX_IDENT_LEN + 1];ST_CHAR temp[256];ST_INT i; chan = 0; nxt_buf = source_buf; obj = &temp_obj;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -