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

📄 getval5.c

📁 ICCP Toolkit 是在 Tru64下开发Tase.2通信协议的开发包
💻 C
📖 第 1 页 / 共 2 页
字号:
      str_ptr[i+1] = '\000';      AKeyWasHit = 0;      switch (str_ptr[i])	{	case '\000' :                    /* check for function key      */	  getkch ();			 /* discard if found		*/	  break;	case '\010'  :                   /* check for a backspace       */	case '\177'  :	  if (i > 0)	    {	    printf ("%c%c%c", '\010', ' ', '\010');	    str_ptr[--i] = '\040';	    str_ptr[i+1] = '\000';	    str_ptr[i] = '\000';	    }	    break;	case 0x0a      :                  /* check for a carriage return  */	  exit_flag = 1;	  str_ptr[i] = '\000';	  ADD_LF;	  break;	case '\033'  :                  /* check for an escape sequence */	  exit_flag = 1;			/* discard information and exit */	  for (0; i < maxlen; i++)	    str_ptr[i] = '\040';	  str_ptr[maxlen] = '\000';	  str_ptr[0] = '\000';	  break;	default      :			/* addition data		*/	  /* printf ("%c", str_ptr[ i ]); */  /* Dont Echo */	  if (i >= maxlen)		/* data greater than buffer	*/	    {				/* scroll buffer		*/	    for (i1=0; i1 < maxlen; ++i1)	      str_ptr[i1] = str_ptr[i1+1];	      str_ptr[maxlen] = '\000';	    }	  else	    ++i;			/* data less than buffer length */	}  /* End of Switch  */				/* add in data to end of string */      }/* End of the if this is a key press */     /* Do the server function */    (*servefun)();			/* perform function while waiting */    }#endif/**************************/#if (SYSTEM_SEL & SYSTEM_SEL_OPEN_VMS)  maxlen -= 1;	   /* eliminates overwrite of buffers */  i1 = 0;  i = 0;  exit_flag = 0;  str_ptr[0] = '\000';  while (exit_flag == 0)    {    if (suspend_till_key (1) == 1)      {      str_ptr[i] = (ST_CHAR) getkch ();      str_ptr[i+1] = '\000';      switch (str_ptr[i])	{	case '\000' :                    /* check for function key      */	  getkch ();			 /* discard if found		*/	  break;	case '\010'  :                   /* check for a backspace       */	case '\177'  :	  if (i > 0)	    {	    printf ("%c%c%c", '\010', ' ', '\010');	    str_ptr[--i] = '\040';	    str_ptr[i+1] = '\000';	    str_ptr[i] = '\000';	    }	    break;	case CR      :                  /* check for a carriage return  */	  exit_flag = 1;	  str_ptr[i] = '\000';	  ADD_LF;	  break;	case '\033'  :                  /* check for an escape sequence */	  exit_flag = 1;			/* discard information and exit */	  for (0; i < maxlen; i++)	    str_ptr[i] = '\040';	  str_ptr[maxlen] = '\000';	  str_ptr[0] = '\000';	  break;	default      :			/* addition data		*/	  printf ("%c", str_ptr[ i ]);	  if (i >= maxlen)		/* data greater than buffer	*/	    {				/* scroll buffer		*/	    for (i1=0; i1 < maxlen; ++i1)	      str_ptr[i1] = str_ptr[i1+1];	      str_ptr[maxlen] = '\000';	    }	  else	    ++i;			/* data less than buffer length */	}				/* add in data to end of string */      }    (*servefun)();			/* perform function while waiting */    }#endif/**************************/#if (SYSTEM_SEL & 			\     (SYSTEM_SEL_SYS_5 | 		\      SYSTEM_SEL_SYS_BSD | 		\      SYSTEM_SEL_QNX_C86 | 		\      SYSTEM_SEL_OS2 | 			\      SYSTEM_SEL_SYSVXWORKS | 		\      SYSTEM_SEL_SYS_QNX4 | 		\      SYSTEM_SEL_NEW_SYSTEM)) ||  defined (_WIN32)  maxlen -= 1;	   /* eliminates overwrite of buffers */  i1 = 0;  i = 0;  exit_flag = 0;  str_ptr[0] = '\000';  while (exit_flag == 0)    {#if (SYSTEM_SEL & SYSTEM_SEL_OS2) || defined (_WIN32)    do_key_wait_service ();		/* Wait for key or other event	*/#endif    if (kbhit ())			/* If a key was hit		*/      {      str_ptr[i] = (ST_CHAR) get_a_char ();      str_ptr[i+1] = '\000';      switch (str_ptr[i])	{	case '\000' :                    /* check for function key      */	  getkch ();			 /* discard if found		*/	  break;	case '\010'  :                   /* check for a backspace       */	case '\177'  :	  if (i > 0)	    {	    printf ("%c%c%c", '\010', ' ', '\010');	    str_ptr[--i] = '\040';	    str_ptr[i+1] = '\000';	    str_ptr[i] = '\000';	    }	    break;	case CR      :                  /* check for a carriage return  */	  exit_flag = 1;	  str_ptr[i] = '\000';	  ADD_LF;	  break;	case '\033'  :                  /* check for an escape sequence */	  exit_flag = 1;			/* discard information and exit */	  for (i = 0; i < maxlen; i++)	    str_ptr[i] = '\040';	  str_ptr[maxlen] = '\000';	  str_ptr[0] = '\000';	  break;	default      :			/* addition data		*/	  printf ("%c", str_ptr[ i ]);	  if (i >= maxlen)		/* data greater than buffer	*/	    {				/* scroll buffer		*/	    for (i1=0; i1 < maxlen; ++i1)	      str_ptr[i1] = str_ptr[i1+1];	      str_ptr[maxlen] = '\000';	    }	  else	    ++i;			/* data less than buffer length */	}				/* add in data to end of string */      }#if !((SYSTEM_SEL & SYSTEM_SEL_OS2)) && !defined (_WIN32)    (*servefun)();			/* perform function while waiting */#endif    }#endif/**************************/#if (SYSTEM_SEL & SYSTEM_SEL_MSOFT) && !defined (_WIN32)  maxlen -= 1;	   /* eliminates overwrite of buffers */  i1 = 0;  i = 0;  exit_flag = 0;  str_ptr[0] = '\x0';  while (exit_flag == 0)    {    if (kbhit ())      {      str_ptr[i] = (ST_CHAR) getch ();      str_ptr[i+1] = '\x0';      switch (str_ptr[i])	{	case '\x0' :                     /* check for function key      */	  getch ();			 /* discard if found		*/	  break;	case '\x08'  :                   /* check for a backspace       */	  if (i > 0)	    {	    str_ptr[--i] = '\x20';	    str_ptr[i+1] = '\x0';	    str_ptr[i] = '\x0';	    }	break;	case CR  :			/* check for a carriage return	*/	  exit_flag = 1;	  str_ptr[i] = '\x0';	  ADD_LF;	  break;	case '\x1b'  :                  /* check for an escape sequence */	  exit_flag = 1;			/* discard information and exit */	  for (i = 0; i < maxlen; i++)	    str_ptr[i] = '\x20';	  str_ptr[maxlen] = '\x0';	  str_ptr[0] = '\x0';	  break;	default      :			/* addition data		*/#if defined (_WINDOWS)   	  printf ("%c", str_ptr[ i ]);#endif	  if (i >= maxlen)		/* data greater than buffer	*/	    {				/* scroll buffer		*/	    for (i1=0; i1 < maxlen; ++i1)	      str_ptr[i1] = str_ptr[i1+1];	      str_ptr[maxlen] = '\x0';	    }	  else	    ++i;			/* data less than buffer length */	}				/* add in data to end of string *//* print data string on console 					*/#if defined (_WINDOWS)   #else      if (!exit_flag)	{	RESTORESCR;	PRINTSTR;	}#endif      }    (*servefun)();			/* perform function while waiting */    }#endif  }/************************************************************************//*			input_hex					*//*  Function to accept sequence of bytes (in hex) from user.		*//************************************************************************/ST_INT input_hex (ST_UCHAR *dest_str, ST_INT maxbytes)  {ST_BOOLEAN done;ST_INT dest_len;ST_CHAR	input[2];ST_INT16 temp_word;  dest_len   = 0;  done	     = SD_FALSE;  while (!done && (dest_len < maxbytes))    {    printf ("\n Byte %d : ", dest_len+1);    flush_keys ();#ifdef PSOS_SYSTEM    input[0] = (ST_CHAR) get_a_char ();#else#if (SYSTEM_SEL & (SYSTEM_SEL_OPEN_VMS | SYSTEM_SEL_SYS_5 | \     SYSTEM_SEL_SYS_BSD | SYSTEM_SEL_QNX_C86))    input [0] = (ST_CHAR) get_a_char ();#endif#if (SYSTEM_SEL & (SYSTEM_SEL_SYSVXWORKS | SYSTEM_SEL_SYS_QNX4 | SYSTEM_SEL_NEW_SYSTEM))	/* DEBUG: why can't everyone use this?	*/    input [0] = (ST_CHAR) getchar ();#endif#if (SYSTEM_SEL & SYSTEM_SEL_MSOFT) && !defined (_WIN32)    input [0] = (ST_CHAR) getch ();#endif#if (SYSTEM_SEL & SYSTEM_SEL_OS2) || defined (_WIN32)    while (!kbhit ())			/* Wait for key or other event	*/      do_key_wait_service ();		    input [0] = getkch ();#endif#endif    printf ("%c", input [0]);    if ((input [0] < '0' || input [0] > '9') &&	(input [0] < 'A' || input [0] > 'F') &&	(input [0] < 'a' || input [0] > 'f'))      done = SD_TRUE;    else      {      flush_keys ();#ifdef PSOS_SYSTEM      input[1] = (ST_CHAR) get_a_char ();#else#if (SYSTEM_SEL & (SYSTEM_SEL_OPEN_VMS | SYSTEM_SEL_SYS_BSD | \                   SYSTEM_SEL_SYS_5 | SYSTEM_SEL_QNX_C86))      input [1] = (ST_CHAR) get_a_char ();#endif#if (SYSTEM_SEL & (SYSTEM_SEL_SYSVXWORKS | SYSTEM_SEL_SYS_QNX4 | SYSTEM_SEL_NEW_SYSTEM))	/* DEBUG: why can't everyone use this?	*/      input [1] = (ST_CHAR) getchar ();#endif#if (SYSTEM_SEL & SYSTEM_SEL_MSOFT) && !defined (_WIN32)      input [1] = (ST_CHAR) getch ();#endif#if (SYSTEM_SEL & SYSTEM_SEL_OS2) || defined (_WIN32)      while (!kbhit ())			/* Wait for key or other event	*/        do_key_wait_service ();		      input [1] = getkch ();#endif#endif      printf ("%c", input [1]);      if ((input [1] < '0' || input [1] > '9') &&	  (input [1] < 'A' || input [1] > 'F') &&	  (input [1] < 'a' || input [1] > 'f'))	done = SD_TRUE;      else	{				/* both characters are valid	*/	sscanf (input, "%2hx\n",&temp_word);	*(dest_str+(dest_len)) = (ST_UCHAR) temp_word;	dest_len++;	}      }    }  if ((dest_len != maxbytes) && (input [0] != CR)) /* check for CR	*/    dest_len = 0;  return (dest_len);  }

⌨️ 快捷键说明

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