int handshake(char *hoststr,int portno){
    
   check_endianness(); // check endianness
   int i;

   for(i = 0; i< 10; i++) {
        if ( connection_(hoststr,portno) <0 ) {
           #ifdef STANDALONE  
            printf("connection error...trying again in 3 seconds\n");
          #else
            LOG_E(OMG, " Could not connect to TraCIServer - sleeping before trying again...\n");
         #endif
            sleep(5);
        }
        else {
        #ifdef STANDALONE  
  	  printf(" SUMO now connected to OMG on host address\n");
        #else
          LOG_N(OMG, " SUMO now connected to OMG on host address %s and port %i .\n", hoststr, portno);
	#endif
 	      return 0;  
	}
   }
    #ifdef STANDALONE  
      printf(" SUMO unreachable...giving up...\n"); 
    #else
      LOG_E(OMG, " SUMO unreachable...giving up...\n");
     #endif
    return -1;
}
Example #2
0
File: cartio.c Project: d-a-v/if2a
void cart_reinit (void)
{
	// Re/Initialize all global library settings.
	
	check_endianness();

	if (!cartio.setup)
	{
		printerr("Internal error, cart input/output functions not initialized.\n");
		exit(1);
	}

	cartio.linker_reinit();
}
Example #3
0
uint32_t color_to_hex(Color c) {
  uint32_t hex = 0;
  uint8_t *hex_ptr = (uint8_t *)&hex;
  if (check_endianness()) {  // If it's little endian (ie intel)
    hex_ptr[0] = c.b;
    hex_ptr[1] = c.g;
    hex_ptr[2] = c.r;
    hex_ptr[3] = c.a;
  } else {
    hex_ptr[3] = c.b;
    hex_ptr[2] = c.g;
    hex_ptr[1] = c.r;
    hex_ptr[0] = c.a;
  }
  return hex;
}
Example #4
0
// For both these functions, we treat the hex value (a 32-bit uint32_t) like an
// array of 4 8-bit values--a, b, g, r in that order.
Color hex_to_color(uint32_t hex) {
  Color result;
  uint8_t *hex_ptr = (uint8_t *)&hex;
  dblogger("%x\n", hex);
  if (check_endianness()) {  // If it's little endian (ie intel)
    result.a = hex_ptr[3];
    result.r = hex_ptr[2];
    result.g = hex_ptr[1];
    result.b = hex_ptr[0];
  } else {
    result.a = hex_ptr[0];
    result.r = hex_ptr[1];
    result.g = hex_ptr[2];
    result.b = hex_ptr[3];
  }
  return result;
}