static int farm_init(char *p) { struct siocb iocb; dprintf("use farm store driver\n"); if (create_directory(p) < 0) goto err; if ((listxattr(p, NULL, 0) == -1) && (errno == ENOTSUP)) goto err; if (trunk_init() < 0) goto err; if (snap_init() < 0) goto err; if (init_sys_vdi_bitmap(p) < 0) goto err; iocb.epoch = sys->epoch ? sys->epoch - 1 : 0; farm_cleanup_sys_obj(&iocb); return SD_RES_SUCCESS; err: return SD_RES_EIO; }
void snap_test_get_reset_state() { snap_t snap; snap_init( &snap ); SNAP_ASSERT( snap_is_ready( &snap ) ); snap.last_error = SNAP_ERROR_BOUND; SNAP_ASSERT( !snap_is_ready( &snap ) ); snap.packet.size = 1; SNAP_ASSERT( !snap_is_ready( &snap ) ); snap.last_error = SNAP_ERROR_NONE; SNAP_ASSERT( !snap_is_ready( &snap ) ); snap_clear( &snap ); SNAP_ASSERT( snap_is_ready( &snap ) ); snap.packet.size = 1; SNAP_ASSERT( !snap_is_ready( &snap ) ); snap_clear( &snap ); SNAP_ASSERT( snap_is_ready( &snap ) ); }
void snap_test_size() { snap_t snap; snap_init( &snap ); SNAP_ASSERT( snap_get_metadata_size( &snap ) == 3 ); SNAP_ASSERT( snap_get_error_detection_mode_size( &snap ) == 0 ); SNAP_ASSERT( snap_get_local_address_size( &snap ) == 0 ); SNAP_ASSERT( snap_get_peer_address_size( &snap ) == 0 ); snap_set_error_detection_mode( &snap, EDM_CRC16 ); SNAP_ASSERT( snap_get_metadata_size( &snap ) == 3 + 2 ); SNAP_ASSERT( snap_get_error_detection_mode_size( &snap ) == 2 ); SNAP_ASSERT( snap_get_local_address_size( &snap ) == 0 ); SNAP_ASSERT( snap_get_peer_address_size( &snap ) == 0 ); snap_set_error_detection_mode( &snap, EDM_CRC32 ); snap_set_local_address( &snap, 100 ); SNAP_ASSERT( snap_get_metadata_size( &snap ) == 3 + 4 + 1); SNAP_ASSERT( snap_get_error_detection_mode_size( &snap ) == 4 ); SNAP_ASSERT( snap_get_local_address_size( &snap ) == 1 ); SNAP_ASSERT( snap_get_peer_address_size( &snap ) == 0 ); snap_reset( &snap ); SNAP_ASSERT( snap_get_metadata_size( &snap ) == 3 ); SNAP_ASSERT( snap_get_error_detection_mode_size( &snap ) == 0 ); SNAP_ASSERT( snap_get_local_address_size( &snap ) == 0 ); SNAP_ASSERT( snap_get_peer_address_size( &snap ) == 0 ); }
void snap_test_init_and_reset() { snap_t snap; snap_init( &snap ); SNAP_ASSERT( !snap_get_acknowledgement( &snap ) ); SNAP_ASSERT( snap_get_error_detection_mode( &snap ) == EDM_NONE ); SNAP_ASSERT( snap_get_local_address( &snap ) == 0 ); SNAP_ASSERT( snap_get_peer_address( &snap ) == 0 ); SNAP_ASSERT( snap_get_metadata_size( &snap ) == 3 ); SNAP_ASSERT( snap_is_ready( &snap ) ); SNAP_ASSERT( snap.last_decode_error_pos == 0 ); SNAP_ASSERT( snap.packet.bound == 0 ); SNAP_ASSERT( snap.packet.edm == EDM_NONE ); SNAP_ASSERT( snap.packet.local_address == 0 ); SNAP_ASSERT( snap.packet.peer_address == 0 ); SNAP_ASSERT( snap.packet.size == 0 ); snap.ack = true; snap.edm = EDM_CRC8; snap.local_address = 323; snap.peer_address = 94323; snap.last_decode_error_pos = 43; snap.packet.bound = 324; snap.packet.edm = EDM_CRC16; snap.packet.local_address = 4321; snap.packet.peer_address = 4; snap.packet.size = 1; SNAP_ASSERT( snap_get_acknowledgement( &snap ) ); SNAP_ASSERT( snap_get_error_detection_mode( &snap ) != EDM_NONE ); SNAP_ASSERT( snap_get_local_address( &snap ) != 0 ); SNAP_ASSERT( snap_get_peer_address( &snap ) != 0 ); SNAP_ASSERT( snap_get_metadata_size( &snap ) != 3 ); SNAP_ASSERT( !snap_is_ready( &snap ) ); SNAP_ASSERT( snap.last_decode_error_pos != 0 ); SNAP_ASSERT( snap.packet.bound != 0 ); SNAP_ASSERT( snap.packet.edm != EDM_NONE ); SNAP_ASSERT( snap.packet.local_address != 0 ); SNAP_ASSERT( snap.packet.peer_address != 0 ); SNAP_ASSERT( snap.packet.size != 0 ); snap_reset( &snap ); SNAP_ASSERT( !snap_get_acknowledgement( &snap ) ); SNAP_ASSERT( snap_get_error_detection_mode( &snap ) == EDM_NONE ); SNAP_ASSERT( snap_get_local_address( &snap ) == 0 ); SNAP_ASSERT( snap_get_peer_address( &snap ) == 0 ); SNAP_ASSERT( snap_get_metadata_size( &snap ) == 3 ); SNAP_ASSERT( snap_is_ready( &snap ) ); SNAP_ASSERT( snap.last_decode_error_pos == 0 ); SNAP_ASSERT( snap.packet.bound == 0 ); SNAP_ASSERT( snap.packet.edm == EDM_NONE ); SNAP_ASSERT( snap.packet.local_address == 0 ); SNAP_ASSERT( snap.packet.peer_address == 0 ); SNAP_ASSERT( snap.packet.size == 0 ); }
void snap_test_acknowledgement() { snap_t snap; snap_init( &snap ); SNAP_ASSERT( !snap_get_acknowledgement( &snap ) ); snap_set_acknowledgement( &snap, true ); SNAP_ASSERT( snap_get_acknowledgement( &snap ) ); snap_reset( &snap ); SNAP_ASSERT( !snap_get_acknowledgement( &snap ) ); }
void snap_test_header() { snap_t snap; snap_init( &snap ); for(int i = 0; i <= 512; ++i) { uint16_t value = snap_get_hdb2( &snap, i ) * ( (uint16_t) 256 ); value += snap_get_hdb1( &snap, i ); SNAP_ASSERT( value == snap_get_header( &snap, i ) ); } }
void snap_test_get_last_error() { snap_t snap; snap_init( &snap ); SNAP_ASSERT( snap_get_last_error( &snap ) == SNAP_ERROR_NONE ); snap.last_error = SNAP_ERROR_UNKNOWN; SNAP_ASSERT( snap_get_last_error( &snap ) == SNAP_ERROR_UNKNOWN ); snap_reset( &snap ); SNAP_ASSERT( snap_get_last_error( &snap ) == SNAP_ERROR_NONE ); }
void snap_test_hdb2() { // TODO Optional "Number of Protocol specific Flag Bytes" (Page 7) snap_t snap; snap_init( &snap ); for(int i = 0; i <= 512; ++i) { snap_reset( &snap ); SNAP_ASSERT( snap_get_hdb2( &snap, i ) == 0 ); snap_set_acknowledgement( &snap, true ); SNAP_ASSERT( snap_get_hdb2( &snap, i ) == 1 ); snap_set_acknowledgement( &snap, false ); SNAP_ASSERT( snap_get_hdb2( &snap, i ) == 0 ); priv_test_hdb2_address( &snap, i, 0, 0 ); priv_test_hdb2_address( &snap, i, 0, 1 ); priv_test_hdb2_address( &snap, i, 0, 127 ); priv_test_hdb2_address( &snap, i, 0, 128 ); priv_test_hdb2_address( &snap, i, 0, 255 ); priv_test_hdb2_address( &snap, i, 0, 256 ); priv_test_hdb2_address( &snap, i, 0, 32767 ); priv_test_hdb2_address( &snap, i, 0, 32768 ); priv_test_hdb2_address( &snap, i, 0, 65535 ); priv_test_hdb2_address( &snap, i, 0, 65536 ); priv_test_hdb2_address( &snap, i, 0, 8388607 ); priv_test_hdb2_address( &snap, i, 0, 8388608 ); priv_test_hdb2_address( &snap, i, 0, 16777215 ); snap_set_acknowledgement( &snap, true ); priv_test_hdb2_address( &snap, i, 1, 0 ); priv_test_hdb2_address( &snap, i, 1, 1 ); priv_test_hdb2_address( &snap, i, 1, 127 ); priv_test_hdb2_address( &snap, i, 1, 128 ); priv_test_hdb2_address( &snap, i, 1, 255 ); priv_test_hdb2_address( &snap, i, 1, 256 ); priv_test_hdb2_address( &snap, i, 1, 32767 ); priv_test_hdb2_address( &snap, i, 1, 32768 ); priv_test_hdb2_address( &snap, i, 1, 65535 ); priv_test_hdb2_address( &snap, i, 1, 65536 ); priv_test_hdb2_address( &snap, i, 1, 8388607 ); priv_test_hdb2_address( &snap, i, 1, 8388608 ); priv_test_hdb2_address( &snap, i, 1, 16777215 ); snap_set_acknowledgement( &snap, false ); } }
bool write_binary(Graph& g, const char* src_filename, const char* dest_filename, int_type val) { typedef typename graph_traits<Graph>::size_type size_type; typedef typename graph_traits<Graph>::edge_iterator edge_iterator; typedef typename graph_traits<Graph>::edge_descriptor edge_descriptor; size_type m = num_edges(g); vertex_id_map<Graph> vid_map = get(_vertex_id_map, g); int_type* tmpbuf = (int_type*) malloc(m * sizeof(int_type)); if (snap_init() != SNAP_ERR_OK) { perror("Can't initialize libsnapshot.\n"); return false; } edge_iterator eIter = edges(g); #pragma mta assert nodep for (size_type i = 0; i < m; ++i) { edge_descriptor e = eIter[i]; tmpbuf[i] = static_cast<int_type>(get(vid_map, source(e, g))); } if (snap_snapshot(const_cast<char*>(src_filename), tmpbuf, m * sizeof(int_type), NULL) != SNAP_ERR_OK) { return false; } #pragma mta assert nodep for (size_type i = 0; i < m; ++i) { edge_descriptor e = eIter[i]; tmpbuf[i] = static_cast<int_type>(get(vid_map, target(e, g))); } if (snap_snapshot(const_cast<char*>(dest_filename), tmpbuf, m * sizeof(int_type), NULL) != SNAP_ERR_OK) { return false; } free(tmpbuf); return true; }
void snap_test_statistic() { snap_t snap; snap_init( &snap ); SNAP_ASSERT( snap_get_statistic( &snap ).rejected_packets == 0 ); SNAP_ASSERT( snap_get_statistic( &snap ).transmitted_packets == 0 ); SNAP_ASSERT( snap_get_statistic( &snap ).received_packets == 0 ); SNAP_ASSERT( snap_get_statistic( &snap ).total_packets == 0 ); SNAP_ASSERT( snap_get_statistic( &snap ).rejected_bytes == 0 ); SNAP_ASSERT( snap_get_statistic( &snap ).transmitted_bytes == 0 ); SNAP_ASSERT( snap_get_statistic( &snap ).received_bytes == 0 ); SNAP_ASSERT( snap_get_statistic( &snap ).total_bytes == 0 ); snap.stat.rejected_packets = 1; snap.stat.transmitted_packets = 5; snap.stat.received_packets = 4; snap.stat.total_packets = 2; snap.stat.rejected_bytes = 3; snap.stat.transmitted_bytes = 6; snap.stat.received_bytes = 8; snap.stat.total_bytes = 7; SNAP_ASSERT( snap_get_statistic( &snap ).rejected_packets == 1 ); SNAP_ASSERT( snap_get_statistic( &snap ).transmitted_packets == 5 ); SNAP_ASSERT( snap_get_statistic( &snap ).received_packets == 4 ); SNAP_ASSERT( snap_get_statistic( &snap ).total_packets == 2 ); SNAP_ASSERT( snap_get_statistic( &snap ).rejected_bytes == 3 ); SNAP_ASSERT( snap_get_statistic( &snap ).transmitted_bytes == 6 ); SNAP_ASSERT( snap_get_statistic( &snap ).received_bytes == 8 ); SNAP_ASSERT( snap_get_statistic( &snap ).total_bytes == 7 ); snap_clear_statistic( &snap ); SNAP_ASSERT( snap_get_statistic( &snap ).rejected_packets == 0 ); SNAP_ASSERT( snap_get_statistic( &snap ).transmitted_packets == 0 ); SNAP_ASSERT( snap_get_statistic( &snap ).received_packets == 0 ); SNAP_ASSERT( snap_get_statistic( &snap ).total_packets == 0 ); SNAP_ASSERT( snap_get_statistic( &snap ).rejected_bytes == 0 ); SNAP_ASSERT( snap_get_statistic( &snap ).transmitted_bytes == 0 ); SNAP_ASSERT( snap_get_statistic( &snap ).received_bytes == 0 ); SNAP_ASSERT( snap_get_statistic( &snap ).total_bytes == 0 ); }
static int farm_init(const char *p) { dprintf("use farm store driver\n"); if (create_directory(p) < 0) goto err; if (!is_xattr_enabled(p)) { eprintf("xattrs are not enabled on %s\n", p); goto err; } if (snap_init() < 0) goto err; if (default_init(p) < 0) goto err; return SD_RES_SUCCESS; err: return SD_RES_EIO; }
static int farm_init(void) { sd_dprintf("use farm store driver"); if (create_directory(obj_path) < 0) goto err; if (!is_xattr_enabled(obj_path)) { sd_eprintf("xattrs are not enabled on %s", obj_path); goto err; } if (snap_init() < 0) goto err; if (default_init() < 0) goto err; return SD_RES_SUCCESS; err: return SD_RES_EIO; }
void priv_test_hdb1(int value, int result) { // TODO Optional "CMD = Command mode bit" (Page 7) snap_t snap; snap_init( &snap ); SNAP_ASSERT( snap_get_hdb1( &snap, value ) == result ); snap_set_error_detection_mode( &snap, EDM_THREETIMES ); SNAP_ASSERT( snap_get_hdb1( &snap, value ) == result + 16 ); snap_set_error_detection_mode( &snap, EDM_CHECKSUM ); SNAP_ASSERT( snap_get_hdb1( &snap, value ) == result + 32 ); snap_set_error_detection_mode( &snap, EDM_CRC8 ); SNAP_ASSERT( snap_get_hdb1( &snap, value ) == result + 48 ); snap_set_error_detection_mode( &snap, EDM_CRC16 ); SNAP_ASSERT( snap_get_hdb1( &snap, value ) == result + 64 ); snap_set_error_detection_mode( &snap, EDM_CRC32 ); SNAP_ASSERT( snap_get_hdb1( &snap, value ) == result + 80 ); snap_set_error_detection_mode( &snap, EDM_FEC ); SNAP_ASSERT( snap_get_hdb1( &snap, value ) == result + 96 ); snap_set_error_detection_mode( &snap, EDM_USER ); SNAP_ASSERT( snap_get_hdb1( &snap, value ) == result + 112 ); snap_set_error_detection_mode( &snap, EDM_CRC16 ); SNAP_ASSERT( snap_get_hdb1( &snap, value ) == result + 64 ); snap_set_error_detection_mode( &snap, EDM_NONE ); SNAP_ASSERT( snap_get_hdb1( &snap, value ) == result ); }
void priv_test_address( uint32_t (*getAddress)(snap_t *ptr), void (*setAddress)(snap_t *ptr, uint32_t value), size_t (*getAddressSize)(snap_t *ptr)) { snap_t snap; snap_init( &snap ); SNAP_ASSERT( getAddress( &snap ) == 0 ); SNAP_ASSERT( getAddressSize( &snap ) == 0 ); size_t v[][2] = { { 0, 0 }, { 1, 1 }, { 127, 1 }, { 128, 1 }, { 255, 1 }, { 256, 2 }, { 32767, 2 }, { 32768, 2 }, { 65535, 2 }, { 65536, 3 }, { 8388607, 3 }, { 8388608, 3 }, { 16777215, 3 } }; for(size_t i = 0; i < sizeof( v ) / sizeof( v[0] ); ++i) { setAddress( &snap, v[ i ][ 0 ] ); SNAP_ASSERT( getAddress( &snap ) == (uint32_t) v[ i ][ 0 ] ); SNAP_ASSERT( getAddressSize( &snap ) == v[ i ][ 1 ] ); } snap_reset( &snap ); SNAP_ASSERT( getAddress( &snap ) == 0 ); SNAP_ASSERT( getAddressSize( &snap ) == 0 ); }
static int farm_init(char *p) { struct siocb iocb; dprintf("use farm store driver\n"); if (create_directory(p) < 0) goto err; if (trunk_init() < 0) goto err; if (snap_init() < 0) goto err; if (init_sys_vdi_bitmap(p) < 0) goto err; iocb.epoch = sys->epoch - 1; farm_cleanup_sys_obj(&iocb); return SD_RES_SUCCESS; err: return SD_RES_EIO; }
int snap_resume( void ) { return snap_init(); }
void snap_test_error_detection_mode() { snap_t snap; snap_init( &snap ); SNAP_ASSERT( snap_get_error_detection_mode( &snap ) == EDM_NONE ); SNAP_ASSERT( snap_get_error_detection_mode_size( &snap ) == 0 ); snap_set_error_detection_mode( &snap, EDM_NONE ); SNAP_ASSERT( snap_get_error_detection_mode( &snap ) == EDM_NONE ); SNAP_ASSERT( snap_get_error_detection_mode_size( &snap ) == 0 ); snap_set_error_detection_mode( &snap, EDM_THREETIMES ); SNAP_ASSERT( snap_get_error_detection_mode( &snap ) == EDM_THREETIMES ); SNAP_ASSERT( snap_get_error_detection_mode_size( &snap ) == 0 ); snap_set_error_detection_mode( &snap, EDM_CHECKSUM ); SNAP_ASSERT( snap_get_error_detection_mode( &snap ) == EDM_CHECKSUM ); SNAP_ASSERT( snap_get_error_detection_mode_size( &snap ) == 1 ); snap_set_error_detection_mode( &snap, EDM_CRC8 ); SNAP_ASSERT( snap_get_error_detection_mode( &snap ) == EDM_CRC8 ); SNAP_ASSERT( snap_get_error_detection_mode_size( &snap ) == 1 ); snap_set_error_detection_mode( &snap, EDM_CRC16 ); SNAP_ASSERT( snap_get_error_detection_mode( &snap ) == EDM_CRC16 ); SNAP_ASSERT( snap_get_error_detection_mode_size( &snap ) == 2 ); snap_set_error_detection_mode( &snap, EDM_CRC32 ); SNAP_ASSERT( snap_get_error_detection_mode( &snap ) == EDM_CRC32 ); SNAP_ASSERT( snap_get_error_detection_mode_size( &snap ) == 4 ); snap_set_error_detection_mode( &snap, EDM_FEC ); SNAP_ASSERT( snap_get_error_detection_mode( &snap ) == EDM_FEC ); SNAP_ASSERT( snap_get_error_detection_mode_size( &snap ) == 0 ); snap_set_error_detection_mode( &snap, EDM_USER ); SNAP_ASSERT( snap_get_error_detection_mode( &snap ) == EDM_USER ); SNAP_ASSERT( snap_get_error_detection_mode_size( &snap ) == 0 ); snap_set_error_detection_mode( &snap, EDM_CRC8 ); SNAP_ASSERT( snap_get_error_detection_mode( &snap ) == EDM_CRC8 ); SNAP_ASSERT( snap_get_error_detection_mode_size( &snap ) == 1 ); snap_set_error_detection_mode( &snap, EDM_NONE ); SNAP_ASSERT( snap_get_error_detection_mode( &snap ) == EDM_NONE ); SNAP_ASSERT( snap_get_error_detection_mode_size( &snap ) == 0 ); snap_set_error_detection_mode( &snap, EDM_CRC32 ); SNAP_ASSERT( snap_get_error_detection_mode( &snap ) == EDM_CRC32 ); SNAP_ASSERT( snap_get_error_detection_mode_size( &snap ) == 4 ); snap_reset( &snap ); SNAP_ASSERT( snap_get_error_detection_mode( &snap ) == EDM_NONE ); SNAP_ASSERT( snap_get_error_detection_mode_size( &snap ) == 0 ); // illegal value snap.edm = 900; SNAP_ASSERT( snap_get_error_detection_mode( &snap ) == EDM_NONE ); SNAP_ASSERT( snap_get_error_detection_mode_size( &snap ) == 0 ); snap_reset( &snap ); SNAP_ASSERT( snap_get_error_detection_mode( &snap ) == EDM_NONE ); SNAP_ASSERT( snap_get_error_detection_mode_size( &snap ) == 0 ); // illegal value snap_set_error_detection_mode( &snap, 900 ); SNAP_ASSERT( snap_get_error_detection_mode( &snap ) == EDM_NONE ); SNAP_ASSERT( snap_get_error_detection_mode_size( &snap ) == 0 ); }
bool read_binary(Graph& g, const char* src_filename, const char* dest_filename) { typedef typename graph_traits<Graph>::size_type size_type; #ifdef DEBUG mt_timer timer; timer.start(); #endif if (snap_init() != SNAP_ERR_OK) { perror("Can't initialize libsnapshot.\n"); return false; } // fstat both files. char* swEP_string = getenv("SWORKER_EP"); luc_endpoint_id_t swEP = 0; if (swEP_string != NULL) swEP = strtoul(swEP_string, NULL, 16); #ifdef DEBUG if (swEP_string) { std::cout << "swEP_string: " << swEP_string << std::endl; } else { std::cout << "swEP_string: " << "NULL" << std::endl; } std::cout << " swEP: " << std::setfill('0') << std::hex << std::setw(16) << swEP << std::endl << std::setfill(' ') << std::dec; #endif snap_stat_buf statBuf; int64_t sn_err = 0; // Get size of data in src and dest files; compute number of records in // each file. if (!src_filename || snap_stat(const_cast<char*>(src_filename), swEP, &statBuf, &sn_err) != SNAP_ERR_OK) { perror("Can't stat sources file.\n"); return false; } size_t src_size = statBuf.st_size / sizeof(size_type); if (!dest_filename || snap_stat (const_cast<char*>(dest_filename), swEP, &statBuf, &sn_err) != SNAP_ERR_OK) { perror("Can't stat destinations file.\n"); return false; } size_t dest_size = statBuf.st_size / sizeof(size_type); if (src_size != dest_size) { perror("The number of entries in the srcs and dests files are " "not equal.\n"); return false; } // Allocate arrays for srcs and dests. size_type* srcs = (size_type*) malloc(src_size * sizeof(size_type)); size_type* dests = (size_type*) malloc(dest_size * sizeof(size_type)); // Restore srcs into buffer. if (snap_restore(const_cast<char*>(src_filename), srcs, statBuf.st_size, NULL) != SNAP_ERR_OK) { perror("Couldn't snap_restore sources file.\n"); return false; } // Restore dests into buffer. if (snap_restore(const_cast<char*>(dest_filename), dests, statBuf.st_size, NULL) != SNAP_ERR_OK) { perror("couldn't snap_restore destinations file.\n"); return false; } #ifdef DEBUG timer.stop(); std::cout << " File read time: " << std::setw(10) << std::fixed << std::setprecision(6) << timer.getElapsedSeconds() << std::endl; timer.start(); #endif // Scan for max vertex to find the number of verices in the graph. size_type max_vertex = 0; #pragma mta block schedule for (size_t i = 0; i < src_size; ++i) { if (srcs[i] > max_vertex) max_vertex = srcs[i]; } #pragma mta block schedule for (size_t i = 0; i < dest_size; ++i) { if (dests[i] > max_vertex) max_vertex = dests[i]; } #ifdef DEBUG timer.stop(); std::cout << "Max vertex find time: " << std::setw(10) << std::fixed << std::setprecision(6) << timer.getElapsedSeconds() << std::endl; #endif size_type n = max_vertex + 1; size_type m = src_size; #ifdef DEBUG timer.start(); #endif init(n, m, srcs, dests, g); #ifdef DEBUG timer.stop(); std::cout << " Graph creation time: " << std::setw(10) << std::fixed << std::setprecision(6) << timer.getElapsedSeconds() << std::endl; #endif free(srcs); free(dests); return true; }
int main( int argc, char *arvg[] ) { int quit = 0; int config_status = 0; int event; #ifdef __WIN32__ freopen( "cabrio.out", "w", stdout ); freopen( "cabrio.err", "w", stderr ); #endif config_status = config_open( NULL ); if( config_status == -1 ) return -1; if( sdl_init() != 0 ) bail(); if( ogl_init() != 0 ) bail(); /* Clear the screen as soon as we can. This avoids graphics * glitches which can occur with some SDL implementations. */ ogl_clear(); sdl_swap(); if( event_init() != 0 ) bail(); if( font_init() != 0 ) bail(); if( config_status == 1 ) { /* Config file didn't exist, so run the setup utility */ if( setup() != 0 ) return -1; config_update(); if( config_create() != 0 ) return -1; } location_init(); /* If config or location results in a new font, it'll be loaded here. */ font_free(); font_init(); /* Large game lists take a while to initialise, * so show the background while we wait... */ bg_init(); bg_clear(); bg_draw(); sdl_swap(); if( platform_init() != 0 ) bail(); if( category_init() != 0 ) bail(); if( game_sel_init() != 0 ) bail(); if( hint_init() != 0 ) bail(); if( snap_init() != 0 ) bail(); if( game_list_create() != 0 ) bail(); if( menu_init() != 0 ) bail(); if( submenu_init() != 0 ) bail(); sound_init(); video_init(); event_flush(); if( !config_get()->iface.theme.menu.auto_hide ) menu_show(); focus_set( FOCUS_GAMESEL ); while( !quit ) { ogl_clear(); bg_draw(); snap_draw(); if (!config_get()->iface.hide_buttons) hint_draw(); menu_draw(); submenu_draw(); game_sel_draw(); sdl_swap(); if (Mix_PlayingMusic() != 1 && config_get()->iface.theme_sound && reader_running == 0) playmusic(); if (( event = event_poll() )) { if( supress_wait == 0 ) { if( event == EVENT_QUIT ) { quit = 1; } else { supress(); event_process( event ); } } } if( supress_wait > 0 ) supress_wait--; sdl_frame_delay(); } clean_up(); return 0; }