mmsadom.c

来自「ICCP Toolkit 是在 Tru64下开发Tase.2通信协议的开发包」· C语言 代码 · 共 1,485 行 · 第 1/3 页

C
1,485
字号
    {    wait_msg ("\n Must enter all required information");    }    (*menu_set_fun) ();#endif  }/************************************************************************//*			do_del_named_dom				*//* Ask the user for a domain name and then go try to delete it. 	*//************************************************************************/ST_VOID do_del_named_dom (ST_VOID)  {#if MMS_NAMED_DOM_ENST_CHAR	temp[256];ST_CHAR	dname[MAX_IDENT_LEN + 1];ST_INT delete_status;ST_INT chan;  if (!get_chan (&chan))    {    (*menu_set_fun) ();    return;    }  printf (" Enter Named Domain to delete: (R) ");  if (strget (temp))    {    temp[MAX_IDENT_LEN] = '\x00';    strcpy (dname,temp);    delete_status = ms_del_named_dom (dname);    if (!delete_status)      printf ("\n '%s' was deleted.", dname);    else      if (delete_status == MVE_DOMAIN_NAME)	printf ("\n '%s' was not found as a Named Domain.", dname);      else	printf ("\n '%s' was not deleted.", dname);    wait_msg ("");    }  else    {    wait_msg ("\n Must enter all required information");    }  (*menu_set_fun) ();#endif  }/************************************************************************//*			     list_named_dom				*//* Display the attributes of the named dom				*//************************************************************************/static ST_VOID list_named_dom (NAMED_DOM_CTRL *ptr)  {ST_INT i;ST_CHAR	**capab_list_ptr;  CLEARSCR;  printf ("\n Domain Name: %s ", ptr->dom_name);  printf ("\n Protected: ");  if (ptr->protection)    printf ("TRUE");  else    printf ("FALSE");  printf ("\n Deletable: ");  if (ptr->deletable)    printf ("TRUE");  else    printf ("FALSE");  printf ("\n Sharable: ");  if (ptr->sharable)    printf ("TRUE");  else    printf ("FALSE");  printf ("\n Current State: %d ", ptr->state);  printf ("\n Domain Content: ");  if (ptr->dom_content)    printf ("is pointing to something");  else    printf ("is NULL");  printf ("\n Number of PI's referencing: %d ", ptr->npi);  if (ptr-> num_of_capab)    {    capab_list_ptr = (ST_CHAR **)(ptr + 1);    printf ("\n Number of Capability lists: %d", ptr->num_of_capab);    for (i=0; i < ptr->num_of_capab; i++, capab_list_ptr++)      printf ("\n     Capability list %d is: %s", i, *capab_list_ptr);    }  else    printf ("\n No Capability Lists for this Domain.");  wait_msg ("");  }/************************************************************************//*			do_list_named_dom				*//* List the names of the domains as they appear in the array.		*//************************************************************************/ST_VOID do_list_named_dom (ST_VOID)  {#if MMS_NAMED_DOM_ENST_INT i;  if (m_vmd_select->num_doms == 0)    wait_msg ("\n There are no Named Domains in the Data Base");  else    {    if (ask ("\n Do you want to expand the domain description (y,n) (default = n) : ",0))      {      for (i=0; i<m_vmd_select->num_doms; i++)         {	list_named_dom (m_vmd_select->dom_array[i]);        }      }    else      {      printf ("\n Data Base of Named Domains is:\n");      for (i=0; i<m_vmd_select->num_doms; i++)         {        printf ("\n %s ", m_vmd_select->dom_array[i]->dom_name);        }      wait_msg ("");      }    }  (*menu_set_fun) ();#endif  }/************************************************************************//*			do_change_named_dom_state			*//* Ask the user for and change the state of a local NamedDomain		*//************************************************************************/ST_VOID do_change_named_dom_state (ST_VOID)  {#if MMS_NAMED_DOM_ENNAMED_DOM_CTRL *dom_ptr;ST_BOOLEAN data_entered;ST_CHAR	temp[256];ST_INT new_state;  printf (" Enter Named Domain to change: (R) ");  if (data_entered = strget (temp))    {    temp[MAX_IDENT_LEN] = '\x00';    }  dom_ptr = ms_find_named_dom (temp);  if ((data_entered) && (dom_ptr != NULL))    {    printf ("\n DOM_NON_EXISTENT  0");    printf ("\n DOM_LOADING	  1");    printf ("\n DOM_READY	  2");    printf ("\n DOM_IN_USE	  3");    printf ("\n DOM_COMPLETE	  4");    printf ("\n DOM_INCOMPLETE	  5");    printf ("\n DOM_D1		  7");    printf ("\n DOM_D2		  8");    printf ("\n DOM_D3		  9");    printf ("\n DOM_D4		 10");    printf ("\n DOM_D5		 11");    printf ("\n DOM_D6		 12");    printf ("\n DOM_D7		 13");    printf ("\n DOM_D8		 14");    printf ("\n DOM_D9		 15");    printf (" Enter new Domain state : (R)");    if (intget (&new_state))      {      dom_ptr->state = new_state;      printf ("\n State of '%s' was changed to %d.", temp, new_state);      wait_msg ("");      }    }  (*menu_set_fun) ();#endif  }/************************************************************************//*			do_vmupload					*//*  Function to do a VM Upload						*//************************************************************************/ST_INT upload_data_fun (UPLOAD_RESP_INFO *);ST_VOID do_vmupload (ST_VOID)  {#if MMS_MV_UPL_EN & REQ_ENST_CHAR	domain[256];ST_INT	chan;ST_INT  type;FILE    *fp;ST_CHAR    filename[256]; if (!get_chan (&chan))    {    (*menu_set_fun) ();    return;    }  printf (" Enter Domain Name : (R) ");  if (strget (domain))    {    printf ("\n Enter destination for domain : (R) ");    printf ("\n     1 - Load to a 100 byte memory buffer");    printf ("\n     2 - Load to a file");    printf ("\n     3 - Load to a function              : ");    if (intget (&type))      {        switch (type)        {        case MEMDOM :          mv_upload (chan,domain,type,100,(ST_UCHAR *)dest_buffer);        break;              case FILDOM :          printf ("\n Enter File Name : (R)");          if (strget (filename))            {            if (fp = fopen (filename, "wb"))              {              mv_upload (chan,domain,type,0,(ST_UCHAR *)fp);              }            }          else            {            wait_msg ("\n Must enter all required information");            }          break;              case FUNDOM :            mv_upload (chan,domain,type,0,(ST_UCHAR *)upload_data_fun);          break;              default :          wait_msg ("\n Bad Type!  Try again.");          break;        }      }      else        {        wait_msg ("\n Must enter all required information");        }    }  else    {    wait_msg ("\n Must enter all required information");    }  (*menu_set_fun) ();#endif  }/************************************************************************//*			do_vmdownload					*//*  Function to do a VM Download					*//************************************************************************/ST_CHAR	*download_data_fun (ST_INT, ST_INT *, ST_CHAR *);ST_VOID do_vmdownload (ST_VOID)  {#if MMS_MV_DWN_EN & REQ_ENST_CHAR	domain[256];ST_INT chan;ST_INT type;FILE    *fp;ST_CHAR    filename[256];ST_INT i,j;ST_INT tot_len;ST_CHAR	**cap_ptr;ST_CHAR	*cap_str;ST_BOOLEAN done;ST_INT num_of_capab;ST_BOOLEAN share;ST_BOOLEAN forced; if (!get_chan (&chan))    {    (*menu_set_fun) ();    return;    }  printf (" Enter Domain Name : (R) ");  if (strget (domain))    {/* enter any capabilities						*/    cap_ptr = (ST_CHAR **) (dest_buffer);	/* use 2 - 4K for the output data strings			*/    cap_str = (dest_buffer + 2048);    tot_len = 0;    num_of_capab = 0;    done = SD_FALSE;    while (!done)      {      printf (" Enter Capability String : (O) ");      if (strget (filename))        {        if ((tot_len += strlen (filename) + 1) < 2048)          {          num_of_capab++; 	/* increment # of capabilities	*/          strcpy (cap_str, filename);          *cap_ptr = cap_str;          cap_ptr++;          cap_str += strlen (cap_str) + 1;          }        else          {          done = SD_TRUE;          wait_msg ("\n Capabilities List too long, last string was lost. ");          }        }      else        done = SD_TRUE;      }    share = ask (" Enter whether domain is sharable (y=TRUE, n=FALSE) (default = y) : ",SD_TRUE);    ms_set_mv_download_sharable (share);    forced = ask (" Enter whether domain should be forced (y,n) (default = n) : ",SD_FALSE);        printf ("\n Enter Source type : (R) ");    printf ("\n     1 - Load from memory buffer");    printf ("\n     2 - Load from file");    printf ("\n     3 - Load from function              : ");    if (intget (&type))      {      switch (type)        {        case MEMDOM :	  j = 65;	  i = 4096;	  while (i < 10000) /* fill up dest_buffer with letters [A..Z]	*/	    {	    *(dest_buffer + i) = (ST_CHAR)j;	    i ++;	    if (j == 90)		/* did we just write the 'Z' ?	*/	      j = 65;	    else	      j++;	    }          if (!forced)            mv_download (chan,domain,num_of_capab,(ST_CHAR **)dest_buffer,                       type,5904,(ST_UCHAR *)dest_buffer+4096);          else            mv_forced_download (chan,domain,num_of_capab,(ST_CHAR **)dest_buffer,                       type,5904,(ST_UCHAR *)dest_buffer+4096);        break;              case FILDOM :          printf ("\n Enter File Name : (R) ");          if (strget (filename))            {            if (fp = fopen (filename, "rb"))              {              if (!forced)                mv_download (chan,domain,num_of_capab,(ST_CHAR **)dest_buffer,                           type,0,(ST_UCHAR *)fp);              else                mv_forced_download (chan,domain,num_of_capab,(ST_CHAR **)dest_buffer,                           type,0,(ST_UCHAR *)fp);              }            }          else            {            wait_msg ("\n Must enter all required information");            }          break;              case FUNDOM :	  j = 97;	  i = 4096;	  while (i < 10000) /* fill up dest_buffer with letters [A..Z]	*/	    {	    *(dest_buffer + i) = (ST_CHAR)j;	    i ++;	    if (j == 122)		/* did we just write the 'z' ?	*/	      j = 97;	    else	      j++;	    }            load_data_ptr = dest_buffer + 4096 ;	/* set up for function	*/            load_data_len = 5904;		/* 10000 - 4K		*/            if (!forced)              mv_download (chan,domain,num_of_capab,(ST_CHAR **)dest_buffer,                         type,0,(ST_UCHAR*)download_data_fun);            else              mv_forced_download (chan,domain,num_of_capab,(ST_CHAR **)dest_buffer,                         type,0,(ST_UCHAR*)download_data_fun);          break;              default :          wait_msg ("\n Bad Type!  Try again.");          break;        }      }    else      {      wait_msg ("\n Must enter all required information");      }    }  else    {    wait_msg ("\n Must enter all required information");    }  (*menu_set_fun) ();#endif  }/************************************************************************//*			download_data_fun				*//*  Sample function on how to get the Download VM to interface to a	*//*  user supplied function when Domain Download Data is needed.  	*//*  In this example Download Data comes from an internal data structure	*//*  However it could come from other sources, mailbox, LAN, other proc.	*//*  etc. NOTE: this function will be called to verify that there is no	*//*  more data to be downloaded.  When this happens the function has to 	*//*  return a NULL ptr or a MVE_DOM_STATE error will be returned by the VM	*//************************************************************************/#if MMS_MV_DWN_EN & REQ_ENST_CHAR *download_data_fun (ST_INT max_len, ST_INT *ret_len_ptr, 	ST_CHAR *more_follows_ptr)  {ST_CHAR 	*ret_data_ptr;  *ret_len_ptr = min (max_len, load_data_len);  ret_data_ptr = load_data_ptr;  load_data_len -= *ret_len_ptr;  if (load_data_len > 0)    {    *more_follows_ptr = SD_TRUE;    load_data_ptr += *ret_len_ptr;    }  else    {    *more_follows_ptr = SD_FALSE;    load_data_ptr = NULL;    }  return (ret_data_ptr);  }#endif/************************************************************************//*				upload_data_fun				*//*  Sample function on how to get the Upload VM to interface to a	*//*  user supplied function when there is Upload data to be stored some	*//*  place.  The data here is just displayed.  It could be sent to	*//*  another part of the system as the application sees fit.		*//************************************************************************/#if MMS_MV_UPL_EN & REQ_ENST_RET upload_data_fun (UPLOAD_RESP_INFO *rsp_info)  {  CLEARSCR;  printf ("\n\n\n %d bytes of Upload data received.", rsp_info->load_data_len);  printf ("\n Upload data received is: ");  list_bytes (rsp_info->load_data, rsp_info->load_data_len);  printf ("\n More follows: ");  if (rsp_info->more_follows)    printf ("TRUE");  else    printf ("FALSE");  wait_msg ("");  (*menu_set_fun) ();  return (SD_SUCCESS);			/* can't fail			*/  }#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?