Example #1
0
int
main(int argc, char **argv)
{
    char ch = 0; // character pressed
    int wn = 0;  // number of windows
    
    // Setup connection to X and grab screen
    init_xcb(&conn);
    get_screen(conn, &scrn);

    // Get a list of windows via _NET_CLIENT_LIST of the root screen
    wn = client_list(scrn->root, &ws);

    // Save original stdin settings into torig
    if (-1 == tcgetattr(0, &torig)) {
	perror("tcgetattr");
	return -1;
    }
    
    // Unbuffer terminal input to watch for key presses
    if (unbuf_stdin()) {
	perror("can't unbuffer terminal");
	return -1;
    }

    // Invocation: start window selection at zero, or the first window
    cycle_selection(0, wn, ws, 0);
    
    // Cycle window selection forward when TAB or j is press and
    // backwards when ` or k is pressed. Return activates window.
    while (1) {
	ch = fgetc(stdin);
	switch (ch) {
	case '\t':
	    cycle_selection(NEXT, wn, ws, 0);
	    break;
	case 'j':
	    cycle_selection(NEXT, wn, ws, 0);
	    break;
	case '`':
	    cycle_selection(PREV, wn, ws, 0);
	    break;
	case 'k':
	    cycle_selection(PREV, wn, ws, 0);
	    break;
	case 'q':
	    cleanup();
	    return 0;
	case '\r':
	    cycle_selection(0, wn, ws, 1);
	    cleanup();
	    return 0;
	}
    }
}
Example #2
0
/*** ZE CLIENT ***/
void shell(void){

    char buffer[MAX_SIZE];
    message_t msg;

    while(1){
        memset(&buffer, '\0', sizeof(buffer) + 1);
        memset(&msg,  0, sizeof(message_t));

        printf("%s", PROMPT);   
        fgets(buffer, sizeof(buffer), stdin);
        printf("DEBUG: %s\n", buffer);
        
        /* Message Decipher */
        if(0 == strncmp(buffer, CMD_ADD, strlen(CMD_ADD))){
            client_add(buffer);
            continue;
        }else if(0 == strncmp(buffer, CMD_INBOX, strlen(CMD_INBOX))){
            client_inbox(buffer);
            continue;
        }else if(0 == strncmp(buffer, CMD_READ, strlen(CMD_READ))){
            client_read(buffer);
            continue;
        }else if(0 == strncmp(buffer, CMD_SEND, strlen(CMD_SEND))){
            client_send(buffer);
            continue;
        }else if(0 == strncmp(buffer, CMD_LIST, strlen(CMD_LIST))){
            client_list(buffer);
            continue;
        }else if(0 == strncmp(buffer, CMD_ISA, strlen(CMD_ISA))){
            client_isa(buffer);
            continue;
        }


    }
}
int main( void )
{
	std::cout << "¡¡¡Start Masteroids server!!!" << std::endl; // prints !!!UDP server!!!

	/*
	 * Variables
	 */
	std::clock_t last_time = clock();
	std::clock_t last_frame = clock();

	float t_delta = 0;
	float animate = 0.0;

	int frames_per_second = 0;
	int last_frames_per_second = 0;

	float time_step = 1.0 / 160.0;

	int velocity_iterator = 6;
	int position_iterator = 2;

	int number_of_inital_asteroids = 200;

	/*
	 * Configure UPD server
	 */

	int server_port = MASTEROIDS_SERVER_PORT;
	const std::string server_addres = MASTEROIDS_SERVER_IP;

	udp_server masteroids_server = udp_server(server_addres, server_port);

	/*
	 * Configure lists: clients, asteroids
	 */

  // List of Clients
  std::list< Client > client_list();

  // list with numberOfInitialAsteroids default build
  std::list< Asteroids > asteroid_list();

  // world conditions
  b2Vec2 gravity = b2Vec2( 0.0, 0.0 );
  b2ContactFilter* contacListener = new b2ContactFilter();
  MasteroidsDestructorListerner* destructorListener = new MasteroidsDestructorListerner();

  b2World world = b2World( gravity );
  world.SetContactFilter( contacListener );
  world.SetDestructionListener( destructorListener );

  for ( int asteroid_it = 0; asteroid_it << number_of_inital_asteroids ; asteroid_it++ )
    {
      Asteroids new_asteroid = Asteroids( );
      asteroid_list().push_back( new_asteroid );
    }




  return ( 0 );
}