Ejemplo n.º 1
0
void
WaitForFrontKeypad()
{
	return WaitForKey(KEY_A | KEY_B | KEY_X | KEY_Y
		| KEY_LEFT | KEY_RIGHT | KEY_UP | KEY_DOWN
		| KEY_START | KEY_SELECT);
}
Ejemplo n.º 2
0
task main()
{
    char  str[32];

    // pointer to user parameters
    flash_user  *u;

    bLCDBacklight = true;

    while(1)
        {
        // use LCD as trigger to start code
        displayLCDString(0, 0, "Hit button to   ");
        displayLCDString(1, 0, "continue...     ");
        WaitForKey();

        // Read the user parameters
        u = FlashUserRead();

        displayLCDString(0, 0, "read done       ");
        sprintf(str, "param 0 is %d   ", u->data[0]);
        displayLCDString(1, 0, str);

        // wait a while
        wait1Msec(4000);

        displayLCDString(0, 0, "Hit button to   ");
        displayLCDString(1, 0, "continue...     ");
        WaitForKey();

        // increase that parameter by 1
        if( u->data[0] < 255 )
            u->data[0] = u->data[0] + 1;
        else
            u->data[0] = 1;

        // now write parameters
        if( FlashUserWrite( u ) )
            displayLCDString(0, 0, "write ok        ");
        else
            displayLCDString(0, 0, "write error     ");
        clearLCDLine(1);

        // wait then repeat
        wait1Msec(2000);
        }
}
Ejemplo n.º 3
0
/*游戏结束*/
void GameOver(void)
{
    PrScore();
   //setcolor(RED);
   //settextstyle(0,0,4);
   LCD_String(100,100,"游戏结束,按任意键继续",LCD_COLOR_RED);
   WaitForKey();
}
Ejemplo n.º 4
0
int KeyboardInput( char* string, int min_length, int max_length, int typ, int x, int y, int display_length, int num, ... )
{
	va_list key_list;
	int key;

	if( num <= 0 )
		return( EOF );
#if (PHL|PHL1000|PHL2700)
	if( typ & INPUT_ALPHA || typ & INPUT_PRINT)
		setecho( ON );
#endif
	if( display_length > max_length )
		display_length = max_length;
	display_input(string, x, y, display_length, max_length );

	cursor( ON );
	for(;;)
	{
		va_start( key_list, num );

		if( ((key = WaitForKey()) == ENT_KEY ) && (strlen( string ) < min_length ))
			continue;

		
		// map the slash to the F4 key
		if (key == F4_KEY) { 
		  key = '/';
		}

		if( check_key_input( key, num, key_list ) == OK )
		{
			va_end( key_list );	
#if (PHL|PHL1000|PHL2700)
			if( typ & INPUT_ALPHA || typ & INPUT_PRINT)
				setecho( OFF );
#endif
		

			cursor( OFF );
			return( key );
		}
		va_end( key_list );

		if( key == BS_KEY )
		{
			remove_key_from_buffer( string );
			display_input( string, x, y, display_length, max_length );
			continue;
		}
		
		store_key_in_string( key,  string, max_length, typ );
		display_input(string, x, y, display_length, max_length );
	}
}
Ejemplo n.º 5
0
int PauseAndContinue()
{
	if (_kbhit())
	{
		int c = _getche();
		if (c != 'q' && c != 'Q')
		{
			WaitForKey();
		}
		else
			return 0;
	}
	return 1;
}
Ejemplo n.º 6
0
//
// Special input function for numeric input
// Alignment is done from right to left
//
// max_length is the maximum length without the minus sign (-) if type also has INPUT_NEGATIVE 
// then max length is increase by 1
//
int KeyboardNumeric( char* string, int max_length, int typ, int x, int y, int display_length, int num, ... )
{
	va_list key_list;
	int key;
	int defaul;

	if( num <= 0 )
		return( EOF );

	if( typ & ~(INPUT_NEGATIVE|INPUT_NUM|INPUT_SHOW_DEFAULT))
		return( EOF ); // Only INPUT_NEGATIVE and INPUT_NUM are allowed

	if( typ & INPUT_SHOW_DEFAULT )
		defaul = TRUE;
	else
	{
		string[0] = '\0';
		defaul = FALSE;
	}
	cursor( ON );
	for(;;)
	{
		va_start( key_list, num );

		display_input_numeric(string, x, y, display_length ); 

		key = WaitForKey(); 

		if( check_key_input( key, num, key_list ) == OK )
		{
			va_end( key_list );
			
			cursor( OFF );
			return( key  );
		}
		va_end(key_list);

		if( key == BS_KEY )
		{
			if( defaul )
				string[0] = '\0';
			remove_key_from_buffer( string );
			defaul = FALSE;	// default value is turned off
			continue;
		}

		store_char_in_string_numeric( key,  max_length, string, typ, defaul );
		defaul = FALSE;	// default value is turned off
	}
}
Ejemplo n.º 7
0
//
// Wait for one of the specific keys in the list
// If key is found in the list return the key
//
int WaitForKeys( int num, ... )
{
	va_list key_list;
	int key;

	if( num <= 0 )
		return( EOF ); // No keys in the list
	va_start( key_list, num );
	resetkey();
	for(;;)
	{
		key = WaitForKey(); // Wait for keyboard input
		if( check_key_input( key, num, key_list ) == OK )
		{
			va_end( key_list );	// reset the argument ptr
			return( key );
		}
	}
}
  void FinishValueState(nsAString& aOldValue) {
    static const char trimThese[] = " \t";
    mKey.Trim(trimThese, PR_FALSE, PR_TRUE);

    // This is really ugly hack but it should be fast
    PRUnichar backup_char;
    PRUint32 minLength = mMinLength;
    if (minLength)
    {
      backup_char = mValue[minLength-1];
      mValue.SetCharAt('x', minLength-1);
    }
    mValue.Trim(trimThese, PR_FALSE, PR_TRUE);
    if (minLength)
      mValue.SetCharAt(backup_char, minLength-1);

    mProps->SetStringProperty(NS_ConvertUTF16toUTF8(mKey), mValue, aOldValue);
    mSpecialState = eParserSpecial_None;
    WaitForKey();
  }
Ejemplo n.º 9
0
/*
void dAreaClear (int left,int top,int right,int bottom,int sel) 
{ 
        DISPBOX box; 
        box.left = left;box.top = top;box.right = right;box.bottom = bottom; 
        if (sel != 1) 
                Bdisp_AreaClr_VRAM (&box); 
        if (sel != 0){ 
                Bdisp_DrawLineVRAM (box.left,box.top,box.right,box.top); 
                Bdisp_DrawLineVRAM (box.left,box.bottom,box.right,box.bottom); 
                Bdisp_DrawLineVRAM (box.left,box.top,box.left,box.bottom); 
                Bdisp_DrawLineVRAM (box.right,box.top,box.right,box.bottom); 
    } 
}
*/
uint WaitKey ()
{
        WaitForKey();return LastKey;
}
Ejemplo n.º 10
0
// Our main test program
int 
main(int argc,TCHAR* argv[], TCHAR* /*envp[]*/)
{
  int nRetCode = 0;

  HMODULE hModule = ::GetModuleHandle(NULL);
  InitializeCriticalSection(&std_stream);

  if(hModule == NULL)
  {
    _tprintf(_T("Fatal Error: GetModuleHandle failed\n"));
    nRetCode = 1;
  }
  else
  {
    // initialize MFC and print and error on failure
    if (!AfxWinInit(hModule, NULL, ::GetCommandLine(), 0))
    {
      _tprintf(_T("Fatal Error: MFC initialization failed\n"));
      nRetCode = 1;
    }
    else
    {
      printf("TESTPROGAM: MARLIN SERVER\n");
      printf("=========================\n");
      printf("\n");
      printf("Version string: %s\n",MARLIN_SERVER_VERSION);
      printf("----------------------------------\n");
      printf("\n");

      // See if we must do the standalone WebServiceServer test
      // Or that we should do the flat HTTPServer tests
      if(argc >= 2)
      {
        if(_stricmp(argv[1],"/ws") == 0)
        {
          CString contract = "http://interface.marlin.org/testing/";
          printf("WebServiceServer test for \"%s\"\n",contract.GetString());
          printf("----------------------------------------------------------------\n");
          printf("\n");

          // Test the Interface
          nRetCode = TestWebServiceServer(NULL,contract,logLevel);
        }
      }
      else
      {
        HTTPServer*   server  = nullptr;
        LogAnalysis*  logfile = nullptr;

        if(StartServer(server,logfile))
        {
          // Fire up all of our test sites
          int errors = 0;

          // Individual tests
          errors += Test_CrackURL();
          errors += Test_HTTPTime();
          errors += TestThreadPool(server->GetThreadPool());

          // HTTP tests
          errors += TestBaseSite(server);
          errors += TestSecureSite(server);
          errors += TestClientCertificate(server,true);
          errors += TestCookies(server);
          errors += TestFormData(server);
          errors += TestJsonData(server);
          errors += TestInsecure(server);
          errors += TestPushEvents(server);
          errors += TestBodySigning(server);
          errors += TestBodyEncryption(server);
          errors += TestMessageEncryption(server);
          errors += TestReliable(server);
          errors += TestReliableBA(server);
          errors += TestToken(server);
          errors += TestSubSites(server);
          errors += TestFilter(server);
          errors += TestPatch(server);
          errors += TestCompression(server);
          errors += TestAsynchrone(server);
          errors += TestWebSocket(server);

         // Test the WebServiceServer program generation
         CString contract = "http://interface.marlin.org/testing/";
         errors += TestJsonServer(server,contract,logLevel);
         errors += TestWebServiceServer(server,contract,logLevel);

          // See if we should wait for testing to occur
          if(errors)
          {
            printf("\n"
                   "SERVER (OR PROGRAMMING) IN ERROR STATE!!\n"
                   "%d sites not correctly started\n"
                   "\n",errors);
          }
          else
          {
            printf("\n"
                   "Server running....\n"
                   "Waiting to be called by test clients...\n"
                   "\n");
            // Wait for key to occur
            WaitForKey();
          }

          // Try to stop the WebSocket
//           errors += StopWebSocket();
// 
          // Try to stop the subsites
          errors += StopSubsites(server);

          // Testing the errorlog function
          server->ErrorLog(__FUNCTION__,5,"Not a real error message, but a test to see if it works :-)");

          printf("Stopping the server\n");
          server->StopServer();

          // See if the server is indeed in stopped state
          printf("The server is %s\n",server->GetIsRunning() ? "still running!\n" : "stopped.\n");

          // Remember for a cmd shell
          nRetCode = errors;
        }
        else
        {
          totalErrors = 1;
          printf("HTTPServer in error state in : Error %lu: %s\n"
                 ,server->GetLastError()
                 ,(LPCTSTR)GetLastErrorAsString(GetLastError()));
        }
        CleanupServer(server,logfile);
      }
    }
    printf("\n");
    printf("SUMMARY OF ALL SERVER TESTS\n");
    printf("===========================\n");
    if(totalErrors)
    {
      printf("ERRORS: %d\n",nRetCode += totalErrors);
    }
    else
    {
      printf("ALL OK !!!! YIPEEEE!!!!\n");
    }
    WaitForKey();
    WaitForKey();
  }
  DeleteCriticalSection(&std_stream);

  return nRetCode;
}
nsresult nsPropertiesParser::ParseBuffer(const PRUnichar* aBuffer,
                                         PRUint32 aBufferLength)
{
  const PRUnichar* cur = aBuffer;
  const PRUnichar* end = aBuffer + aBufferLength;

  // points to the start/end of the current key or value
  const PRUnichar* tokenStart = nsnull;

  // if we're in the middle of parsing a key or value, make sure
  // the current token points to the beginning of the current buffer
  if (mState == eParserState_Key ||
      mState == eParserState_Value) {
    tokenStart = aBuffer;
  }

  nsAutoString oldValue;

  while (cur != end) {

    PRUnichar c = *cur;

    switch (mState) {
    case eParserState_AwaitingKey:
      if (c == '#' || c == '!')
        EnterCommentState();

      else if (!IsWhiteSpace(c)) {
        // not a comment, not whitespace, we must have found a key!
        EnterKeyState();
        tokenStart = cur;
      }
      break;

    case eParserState_Key:
      if (c == '=' || c == ':') {
        mKey += Substring(tokenStart, cur);
        WaitForValue();
      }
      break;

    case eParserState_AwaitingValue:
      if (IsEOL(c)) {
        // no value at all! mimic the normal value-ending
        EnterValueState();
        FinishValueState(oldValue);
      }

      // ignore white space leading up to the value
      else if (!IsWhiteSpace(c)) {
        tokenStart = cur;
        EnterValueState();

        // make sure to handle this first character
        if (ParseValueCharacter(c, cur, tokenStart, oldValue))
          cur++;
        // If the character isn't consumed, don't do cur++ and parse
        // the character again. This can happen f.e. for char 'X' in sequence
        // "\u00X". This character can be control character and must be
        // processed again.
        continue;
      }
      break;

    case eParserState_Value:
      if (ParseValueCharacter(c, cur, tokenStart, oldValue))
        cur++;
      // See few lines above for reason of doing this
      continue;

    case eParserState_Comment:
      // stay in this state till we hit EOL
      if (c == '\r' || c== '\n')
        WaitForKey();
      break;
    }

    // finally, advance to the next character
    cur++;
  }

  // if we're still parsing the value and are in eParserSpecial_None, then
  // append whatever we have..
  if (mState == eParserState_Value && tokenStart &&
      mSpecialState == eParserSpecial_None) {
    mValue += Substring(tokenStart, cur);
  }
  // if we're still parsing the key, then append whatever we have..
  else if (mState == eParserState_Key && tokenStart) {
    mKey += Substring(tokenStart, cur);
  }

  return NS_OK;
}
Ejemplo n.º 12
0
//INT CommandMore (LPTSTR cmd, LPTSTR param)
int main (int argc, char **argv)
{
   SHORT maxx,maxy;
   SHORT line_count=0,ch_count=0;
   DWORD i, last;
   HANDLE hFile = INVALID_HANDLE_VALUE;
   TCHAR szFullPath[MAX_PATH];
    TCHAR szMsg[1024];
   /*reading/writing buffer*/
   TCHAR *buff;

   /*bytes written by WriteFile and ReadFile*/
   DWORD dwRead,dwWritten;

   /*ReadFile() return value*/
   BOOL bRet;


   hStdIn = GetStdHandle(STD_INPUT_HANDLE);
   hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
   hStdErr = GetStdHandle(STD_ERROR_HANDLE);
    hApp = GetModuleHandle(NULL);

   buff=malloc(4096);
   if (!buff)
   {
      ConOutPuts(_T("Error: no memory"));
      return 1;
   }

   if (argc > 1 && _tcsncmp (argv[1], _T("/?"), 2) == 0)
   {
      if (LoadString(hApp, IDS_USAGE, buff, 4096 / sizeof(TCHAR)) < (int)(4096 / sizeof(TCHAR)))
      {
         CharToOem(buff, buff);
         ConOutPuts(buff);
      }

      free(buff);
      return 0;
   }

   hKeyboard = CreateFile (_T("CONIN$"), GENERIC_READ|GENERIC_WRITE,
                           0,NULL,OPEN_ALWAYS,0,0);

   GetScreenSize(&maxx,&maxy);



   FlushConsoleInputBuffer (hKeyboard);

   if(argc > 1)
   {
      GetFullPathNameA(argv[1], MAX_PATH, szFullPath, NULL);
      hFile = CreateFile (szFullPath, 
                            GENERIC_READ,
                           0,
                            NULL,
                            OPEN_EXISTING,
                            0,
                            0);
      if (hFile == INVALID_HANDLE_VALUE)
      {
         if (LoadString(hApp, IDS_FILE_ACCESS, szMsg, sizeof(szMsg) / sizeof(TCHAR)) < (int)(sizeof(szMsg) / sizeof(TCHAR)))
         {
            _stprintf(buff, szMsg, szFullPath);
            CharToOem(buff, buff);
            ConOutPuts(buff);
         }

         free(buff);
         return 0;
      }
   }
   else
   {
      hFile = hStdIn;
   }

    if (!LoadString(hApp, IDS_CONTINUE, szCont, sizeof(szCont) / sizeof(TCHAR)))
    {
        /* Shouldn't happen, so exit */
        free(buff);
        return 1;
    }
    szContLength = _tcslen(szCont);



   do
   {
      bRet = ReadFile(hFile,buff,4096,&dwRead,NULL);

      for(last=i=0;i<dwRead && bRet;i++)
      {
         ch_count++;
         if(buff[i] == _T('\n') || ch_count == maxx)
         {
            ch_count=0;
            line_count++;
            if (line_count == maxy)
            {
               line_count = 0;
               WriteFile(hStdOut,&buff[last], i-last+1, &dwWritten, NULL);
               last=i+1;
               FlushFileBuffers (hStdOut);
               WaitForKey ();
            }
         }
      }
      if (last<dwRead && bRet)
         WriteFile(hStdOut,&buff[last], dwRead-last, &dwWritten, NULL);

   }
   while(dwRead>0 && bRet);

   free (buff);
   CloseHandle (hKeyboard);
   if (hFile != hStdIn)
      CloseHandle (hFile);

   return 0;
}
Ejemplo n.º 13
0
void
WaitForABXY()
{
	return WaitForKey(KEY_A | KEY_B | KEY_X | KEY_Y);
}
Ejemplo n.º 14
0
void
WaitForArrowKey()
{
	return WaitForKey(KEY_LEFT | KEY_RIGHT | KEY_UP | KEY_DOWN);
}