Esempio n. 1
0
int main(void){
	
	char prompt[100];
	char *initialprompt = "Yo bitch.";
	//copy the initial prompt into prompt array for changing
	memcpy(prompt, initialprompt, strlen(initialprompt)+1);
	printf("%s %s", prompt, " ");
	
	char userinput[100];
//	printf("%s", userinput);
//	printf("%d", isQuit(userinput));
//	printf("%d", isSetPrompt(userinput));
	while(gets(userinput) != NULL){
	//the user inputs valid things

		if(isSetPrompt(userinput) == 1){
		//we want to set the prompt
		//get subString also sets the prompt
			getSubstring(prompt, userinput);
		}
		if(isQuit(userinput) == 1){
		//we want to quit	
			exit(0);
		}
		else{
			system(userinput);
		}
		printf("%s %s", prompt, " ");
	}
}
Esempio n. 2
0
openGalaxy::~openGalaxy()
{
  if(!isQuit()) exit();
  if(m_Poll) delete m_Poll;
  if(m_Commander) delete m_Commander;
  if(m_Receiver) delete m_Receiver;
  if(m_Websocket) delete m_Websocket;
  if(m_Output) delete m_Output;
  if(m_SIA) delete m_SIA;
  if(m_Galaxy) delete m_Galaxy;
  if(m_Serial) delete m_Serial;
  if(m_Settings) delete m_Settings;
  if(m_Syslog) delete m_Syslog;
}
Esempio n. 3
0
int main ( int argc, char * argv[ ] ) {
  int nbytes;                // Number of bytes
  int sock;                  // This will be our socket
  char buffer[ MAXBUFSIZE ]; // A buffer to buff things
  char cmd[ MAXBUFSIZE ];    // Command to be sent to Server
  char *newline = NULL;      // Get newline
  Folder dir;                // Local list of folder Files
  Repository repo;           // Master file list

  // Make sure name, ip and port are given
  if ( argc < 4 ) {
	printf("USAGE:  <client_name> <server_ip> <server_port>\n");
	exit ( EXIT_FAILURE );
  }

  sprintf( dir.name, "%s", argv[1] );
  ls( &dir );
  
  printf( "$ Welcome '%s'\n", dir.name );
  
  sock = createSocket( inet_addr( argv[2] ), atoi( argv[3] ) );
  connectPlease( &dir, sock );
  //  getMaster( &repo, sock );

  //
  // Enter command loop
  //
  do {
	bzero( cmd, sizeof( cmd ) );
	printf( "> " );
	
	//
	// Grab Command Line
	//
	if ( fgets( cmd, MAXBUFSIZE, stdin ) != NULL ) {
	  newline = strchr( cmd, '\n'); // Find the newline
	  if ( newline != NULL ) *newline = '\0'; // Overwrite
	  
	  switch ( parseCmd ( cmd ) ) 
		{
		case LS:
		  printCatalog ( &dir );
		  break;
		case GET:
		  getMaster( &repo, sock );
		  break;
		case EXIT: 
		  nbytes = write( sock, "EXIT", MAXBUFSIZE );
		  ERROR( nbytes < 0 );
		  break;
		default:
		  nbytes = write( sock, cmd, MAXBUFSIZE );
		  ERROR( nbytes < 0 );
		  bzero( buffer, MAXBUFSIZE );
		  nbytes = read( sock, buffer, MAXBUFSIZE );
		  printf( "$ %s\n", buffer);
		  break;
		}	
	}
  } while ( !isQuit( cmd ) );  

  close( sock );
  
  return EXIT_SUCCESS;
} // main( )
Esempio n. 4
0
void Input::GameInput::update(const sf::Event& ite)
{
	 /*if(!locked && isJoystickEvent(ite.type) && mode == MouseKeyboard)
	 {
	 	mode = Joystick;
	 }
	 else if(!locked && isMouseKeyboardEvent(ite.type) && mode == Joystick)
	 {
	 	mode = MouseKeyboard;
	 }*/

	 if (ite.type == sf::Event::KeyPressed)
	 {
		 clavier[ite.key.code] = true;
	 }

		 else if (ite.type == sf::Event::KeyReleased)
		 {
			 clavier[ite.key.code] = false;
		 }

		 else if (ite.type == sf::Event::MouseButtonPressed)
		 {
			 souris[(const char)ite.mouseButton.button] = true;
			 relX = posX - ite.mouseButton.x;
			 relY = posY - ite.mouseButton.y;
			 posX = ite.mouseButton.x;
			 posY = ite.mouseButton.y;
		 }

		 else if (ite.type == sf::Event::MouseButtonReleased)
		 {
			 souris[(const char)ite.mouseButton.button] = false;
		 }

		 else if (ite.type == sf::Event::JoystickButtonPressed)
		 {
			 joyButtons[ite.joystickButton.button] = true;
		 }

		 else if(ite.type == sf::Event::JoystickButtonPressed)
		 {
			 joyButtons[ite.joystickButton.button] = false;
		 }

		 else if (ite.type == sf::Event::JoystickMoved)
		 {
			 leftJoy = false;
			 downJoy = false;
			 rightJoy = false;
			 upJoy = false;
			
			 if (ite.joystickMove.axis == sf::Joystick::X)/*(joyInput.GetJoystickAxis(0, sf::Joystick::X) < -25)*/
			 {
					leftJoy = true;
			 }
			 /*else if (joyInput.GetJoystickAxis(0, sf::Joystick::X)  > 25)
			 {
					rightJoy = true;
			 }*/
			 if (ite.joystickMove.axis == sf::Joystick::Y)/*(joyInput.GetJoystickAxis(0, sf::Joystick::Y)  > 25)*/
			 {
				 upJoy = true;
			 }
			/* else if(joyInput.GetJoystickAxis(0, sf::Joystick::Y)  < -25)
			 {
				downJoy = true;
			 }*/

				
		 }
		 if(isUp())
		 	Notify(Events::Move(),std::make_pair(0,-1));
		 if(isDown())
		 	Notify(Events::Move(),std::make_pair(0,1));
		 if(isRight())
		 	Notify(Events::Move(),std::make_pair(1,0));
		 if(isLeft())
		 	Notify(Events::Move(),std::make_pair(-1,0));
		 if(isShoot())
		 	Notify(Events::Shoot());
		 if(isQuit())
		 	Notify(Events::Quit());
}