⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mmsamisc.c

📁 ICCP Toolkit 是在 Tru64下开发Tase.2通信协议的开发包
💻 C
📖 第 1 页 / 共 5 页
字号:
      if (!strnicmp (str,line,i))        lc->fc.ctrl |= FIL_CTRL_NO_APPEND; /* overwrite is requested	*/      str = "HardFlush";      i = strlen (str);      if (!strnicmp (str,line,i))        lc->fc.ctrl |= FIL_CTRL_HARD_FLUSH; /* Hard flush is requested	*/      str = "Setbuf";      i = strlen (str);      if (!strnicmp (str,line,i))        lc->fc.ctrl |= FIL_CTRL_SETBUF_EN; /* Setbuf is requested	*/      str = "NoWipe";      i = strlen (str);      if (!strnicmp (str,line,i))        lc->fc.ctrl &= ~FIL_CTRL_WIPE_EN; /* No wipe wanted		*/      str = "NoWrap";      i = strlen (str);      if (!strnicmp (str,line,i))        lc->fc.ctrl &= ~FIL_CTRL_WRAP_EN; /* No wrap wanted		*//*       ********* MEMORY LOGGING CONTROL                       */      str = "DumpFileName=";      i = strlen (str);      if (!strnicmp (str,line,i))        {        sscanf (&line[i], "%s",buf);        lc->mc.dumpFileName = chk_malloc (strlen (buf) + 1);        strcpy (lc->mc.dumpFileName, buf);	}      str = "LogMemItems=";      i = strlen (str);      if (!strnicmp (str,line,i))        sscanf (&line[i], "%d",&lc->mc.maxItems);      str = "MemAutoDump";      i = strlen (str);      if (!strnicmp (str,line,i))        lc->mc.ctrl |= MEM_CTRL_AUTODUMP_EN; /* autodump                */      } /* got an interesting line					*/    }   /* while reading file						*/  fclose (file_ptr);  return (SD_TRUE);		/* Indicate that LOG.CFG exists		*/  }#endif/************************************************************************//*			do_set_cont					*//* This function is called to initialize the continuous send variables	*//************************************************************************/ST_VOID do_set_cont (ST_VOID)  {  printf ("\n\n How many repetitions (%d) ? ",num_reps);  intget (&num_reps);  if (ask (" Print Running Count ? ",0))    cont_print_flag = 1;  else    cont_print_flag = 0;  printf ("\n Enter Desired Pipeline Length (default %d) : ", pipelength);  intget (&pipelength);  if (!pipelength)    num_reps = 0;  rep_count = 0;  resp_rcvd = 0;  (*menu_set_fun)();  }/************************************************************************//*			do_wait_event					*//************************************************************************/ST_VOID do_wait_event (ST_VOID)  {ST_INT wait_time;  printf ("\n\n Enter Number of seconds to wait for an event : ");  if (intget (&wait_time))    {    if (mms_event_wait (wait_time))       printf ("\n Event Occurred !");    else       printf ("\n Event Wait Timeout !");    wait_msg ("\n  Hit a key to continue -");    }  (*menu_set_fun)();  }/************************************************************************//*			do_set_cs					*//************************************************************************/#define CS_BUFFER_LEN  	20ST_UCHAR cs_buffer[CS_BUFFER_LEN];ST_VOID do_set_cs (ST_VOID)  {extern ST_INT cs_send_reset_val;  printf ("\n\n Enter HEX Companion Standard Info : ");  cs_send.cs_len = input_hex (cs_buffer, CS_BUFFER_LEN);  if (cs_send.cs_len)    {    cs_send.cs_ptr = cs_buffer;    cs_send.cs_pres = SD_TRUE;    }  cs_send_reset_val = ask ("\n Send CS on ALL messages (N) ? ",0);  (*menu_set_fun)();  }/************************************************************************//*			do_set_mod					*//************************************************************************/ST_VOID do_set_mod (ST_VOID)  {MODIFIER 	*mod_ptr;ST_INT	i = 0;ST_BOOLEAN data_entered = SD_TRUE;/* This is initalized to NULL in strt_MMS.  Every time we get here	*//* and it's not NULL we should free it and get a new one.		*/  if (modifier_list.mod_list_ptr)    chk_free (modifier_list.mod_list_ptr);  modifier_list.mod_list_ptr = (MODIFIER *)                               chk_calloc (1,                                       sizeof (MODIFIER));  modifier_list.num_of_mods = 0;  while (data_entered)    {    mod_ptr = modifier_list.mod_list_ptr + i;	/* pt to next empty mod	*/    if (data_entered = get_modifier (mod_ptr))      {      i++;      modifier_list.num_of_mods++;		/* account for this one */                                                /* add on an empty one	*/      modifier_list.mod_list_ptr = (MODIFIER *)              chk_realloc ((ST_CHAR *) modifier_list.mod_list_ptr,			(i + 1) * sizeof (MODIFIER));      }    }  if (i == 0)			/* i = 0 means data wasn't entered	*/    {    chk_free (modifier_list.mod_list_ptr);/* give back first one*/    modifier_list.mod_list_ptr = NULL;    modifier_list.info_pres = SD_FALSE;    }  else    {    modifier_list.mod_list_ptr = (MODIFIER *)      chk_realloc ((ST_CHAR *) modifier_list.mod_list_ptr,                  modifier_list.num_of_mods * sizeof (MODIFIER));    modifier_list.info_pres = SD_TRUE;    }  (*menu_set_fun)();  }/************************************************************************//************************************************************************//* The following are miscellaneous user application utility functions.	*//************************************************************************//************************************************************************//*			 get_external_asn1 				*//************************************************************************//* get ASN.1 EXTERNAL data from user and create ASN.1 data element	*//* caller must ensure buffer big enough (100 bytes is plenty)		*/ST_UCHAR ext_data_buf[20] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };ST_UCHAR ext_data_any[] = { 0x81, 0x01, 0x77 };ST_VOID get_external_asn1 (ST_UCHAR *buf, ST_INT *len_ptr)  {EXTERN_INFO ext;ST_UCHAR dest[100];ST_INT dest_len = 100;ST_UCHAR *ext_ptr;  if (ext.dir_ref_pres = (ST_UCHAR) ask ("\n   Do you want to send Direct Reference (y,n) (default = n) : ",0))    {    ext.dir_ref.num_comps = 4;    ext.dir_ref.comps[0] = 1;    ext.dir_ref.comps[1] = 2;    ext.dir_ref.comps[2] = 3;    ext.dir_ref.comps[3] = 4;    }  if (ext.indir_ref_pres = (ST_UCHAR) ask ("   Do you want to send Indirect Reference (y,n) (default = n) : ",0))    ext.indir_ref = 2540020L;  if (ext.dv_descr_pres = (ST_UCHAR) ask ("   Do you want to send Octet Aligned Data (y,n) (default = y) : ",1))    {    ext.dv_descr_len = 10;    ext.dv_descr = (ST_UCHAR *) "SISCO_DATA";    }  ext.data_ptr = ext_data_buf;  if (ask ("   Send Octet Aligned Data ? (Y) ? ",1))    {    ext.encoding_tag = 1;    ext.data_len = 10;    }  else if (ask ("   Do you want to send Arbitrary Data (y,n) (default = y) : ",1))    {    ext.encoding_tag = 2;    ext.num_bits = 64;    }  else    {    ext.data_ptr = ext_data_any;    ext.encoding_tag = 0;    printf ("   Sending ANY Data\n");    ext.data_len = 3;    }/* Now convert structure to ASN.1 encoded EXTERNAL			*/  ms_encode_extern (&ext,dest,dest_len,len_ptr,&ext_ptr);  memcpy (buf,ext_ptr,*len_ptr);  }/************************************************************************//*                      list_external                                   *//* This function is used to print the contents of the extern_info       *//* structure that has been filled in by a parse routine                 *//************************************************************************/ST_VOID list_external (FILE *fp, EXTERN_INFO *info)  {MMS_OBJ_ID *obj;ST_INT i;  fprintf (fp,"\n   Direct Reference : ");  if (info->dir_ref_pres)    {    obj = &(info->dir_ref);    for (i = 0; i < obj->num_comps; ++i)      fprintf (fp," %d",obj->comps[i]);    }  else    fprintf (fp,"Not Present");  fprintf (fp,"\n   Indirect Reference : ");  if (info->indir_ref_pres)    fprintf (fp,"%ld",info->indir_ref);  else    fprintf (fp,"Not Present");  fprintf (fp,"\n   Data Value Descripter : ");  if (info->dv_descr_pres)    log_hex_bytes (stdout,info->dv_descr,info->dv_descr_len);  else    fprintf (fp,"Not Present");  fprintf (fp,"\n   Encoding Tag : %d",info->encoding_tag);  if (info->encoding_tag == 2)    fprintf (fp,"\n   Data Length = %d bits",info->num_bits);  else    fprintf (fp,"\n   Data Length = %d octects",info->data_len);  fprintf (fp,"\n   Data : ");  log_hex_bytes (stdout,info->data_ptr,info->data_len);  }/************************************************************************//*			start_serve					*//* Function used in the continuous send mode				*//************************************************************************/ST_INT start_cont (ST_VOID)  {  flush_keys ();  resp_rcvd = 0;  rep_count = 0;  num_outstanding = 1;  time ((time_t *)&cont_start_time);	/* record start time			*/  return (cont_serve ());	/* if user hit a key			*/  }/************************************************************************//*			cont_serve					*//* Function used in the continuous send mode				*//************************************************************************/ST_INT cont_serve (ST_VOID)  {time_t	sec;#if	(SYSTEM_SEL & (OPEN_VMS))ST_CHAR	trash_char;#endif/* Check for requested pipeline filled, return immediately if not	*/  if ((num_outstanding < pipelength) && (num_reps > pipelength))    {    if (kbhit ())	/* let the user escape if desired		*/      {#if	(SYSTEM_SEL & (OPEN_VMS))      trash_char = getkch ();			/* throw away that char */#endif      flush_keys ();      return (1);	/* user terminated				*/      }    else      return (0);	/* OK to send next request			*/    }  while ((!resp_rcvd) && (pipelength))/* wait for command done	*/    {    mms_comm_service ();    if (kbhit ())	/* let the user escape if desired		*/      {#if	(SYSTEM_SEL & (OPEN_VMS))      trash_char = getkch ();			/* throw away that char */#endif      flush_keys ();      sec = (time (NULL) - cont_start_time); /* calc # seconds	*/      printf ("\n %d repetitions complete",rep_count);      if (rep_count)	printf ("\n %ld seconds elapsed : %.1f ms per transaction",sec,		 (ST_FLOAT) (((ST_FLOAT)sec/(ST_FLOAT)rep_count) * 1000.0));      rep_count = 0;      wait_msg ("\n Hit return to continue - ");      (*menu_set_fun)();      return (1);	/* return != 0 for user terminated		*/      }    }  resp_rcvd = 0;  if (cont_print_flag)    {    BOTTOMSCR;    printf (" %d",rep_count);    }  return (0);		/* return 1 for command complete		*/  }/************************************************************************//*			cont_done					*//* Function used in the continuous send mode				*//************************************************************************/ST_VOID	cont_done (ST_VOID)  {time_t sec;  sec = (time (NULL) - cont_start_time); /* calculate # seconds	*/  printf ("\n\n %d repetitions complete",rep_count);  if (rep_count)    printf ("\n %ld seconds elapsed : %.1f ms per transaction",sec,	 (ST_FLOAT) (((ST_FLOAT)sec/(ST_FLOAT)rep_count) * 1000.0));  rep_count = 0;  wait_msg ("\n Hit return to continue - ");  (*menu_set_fun)();  }/************************************************************************//*			get_chan					*//* Get channel number							*//************************************************************************/ST_INT get_chan (ST_INT *chan_ptr)  {static ST_INT send_chan = 0;  printf ("\n Enter the Channel # to use (default = %d) : ",send_chan);  if (!intget (chan_ptr))    *chan_ptr = send_chan;  if (*chan_ptr >= max_mms_chan || *chan_ptr < 0) /* if not legal channel	*/    {    key_err ("Bad channel number");    return (0);    }  if (mms_chan_info[*chan_ptr].ctxt.chan_state != M_ACTIVE)    {    wait_msg ("Channel Not Active");    return (0);    }  send_chan = *chan_ptr;  return (1);  }/************************************************************************//*			clear_bottom					*//* function to clear the bottom inforamtion area			*//* leaves the cursor positioned to top of area				*//************************************************************************/ST_VOID clear_bottom (ST_VOID)  {register i;    for (i = 19; i < 25; ++i)      CLEARLINE (i);    GOTOLINE (19);  }/************************************************************************//*     		           get_fname_list				*//* Routine gets upto a maximum of file name strings from the user.  It  *//* fills in the file component structure and updates the corresponding  */

⌨️ 快捷键说明

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