static void test_dhclient_invalid_classless_routes_3 (const char *client) { GHashTable *options; NMIP4Config *ip4_config; const char *expected_route1_dest = "192.168.10.0"; const char *expected_route1_gw = "192.168.1.1"; static Option data[] = { { "new_rfc3442_classless_static_routes", "24 192 168 10 192 168 1 1 32 128 10 17 66 41" }, { NULL, NULL } }; options = fill_table (generic_options, NULL); options = fill_table (data, options); ip4_config = nm_dhcp_manager_test_ip4_options_to_config (client, "eth0", options, "rebind"); ASSERT (ip4_config != NULL, "dhcp-dhclient-classless-invalid-3", "failed to parse DHCP4 options"); /* IP4 routes */ ASSERT (nm_ip4_config_get_num_routes (ip4_config) == 1, "dhcp-dhclient-classless-invalid-3", "unexpected number of IP routes"); ip4_test_route ("dhcp-dhclient-classless-invalid-3", ip4_config, 0, expected_route1_dest, expected_route1_gw, 24); g_hash_table_destroy (options); }
static void test_dhcpcd_gw_in_classless_routes (const char *client) { GHashTable *options; NMIP4Config *ip4_config; const char *expected_route1_dest = "192.168.10.0"; const char *expected_route1_gw = "192.168.1.1"; const char *expected_gateway = "192.2.3.4"; static Option data[] = { { "new_classless_static_routes", "192.168.10.0/24 192.168.1.1 0.0.0.0/0 192.2.3.4" }, { NULL, NULL } }; options = fill_table (generic_options, NULL); options = fill_table (data, options); ip4_config = nm_dhcp_manager_test_ip4_options_to_config (client, "eth0", options, "rebind"); ASSERT (ip4_config != NULL, "dhcp-dhcpcd-classless-gateway", "failed to parse DHCP4 options"); /* IP4 routes */ ASSERT (nm_ip4_config_get_num_routes (ip4_config) == 1, "dhcp-dhcpcd-classless-gateway", "unexpected number of IP routes"); ip4_test_route ("dhcp-dhcpcd-classless-gateway", ip4_config, 0, expected_route1_dest, expected_route1_gw, 24); /* Gateway */ ip4_test_gateway ("dhcp-dhcpcd-classless-gateway", ip4_config, expected_gateway); g_hash_table_destroy (options); }
static void test_dhcpcd_invalid_classless_routes_2 (const char *client) { GHashTable *options; NMIP4Config *ip4_config; const char *expected_route1_dest = "10.1.1.5"; const char *expected_route1_gw = "10.1.1.1"; const char *expected_route2_dest = "100.99.88.56"; const char *expected_route2_gw = "10.1.1.1"; static Option data[] = { { "new_classless_static_routes", "10.0.adfadf/44 10.17.66.41 192.168.10.0/24 192.168.1.1" }, { NULL, NULL } }; options = fill_table (generic_options, NULL); options = fill_table (data, options); ip4_config = nm_dhcp_manager_test_ip4_options_to_config (client, "eth0", options, "rebind"); ASSERT (ip4_config != NULL, "dhcp-dhcpcd-classless-invalid-2", "failed to parse DHCP4 options"); /* Test falling back to old-style static routes if the classless static * routes are invalid. */ /* Routes */ ASSERT (nm_ip4_config_get_num_routes (ip4_config) == 2, "dhcp-dhcpcd-classless-invalid-2", "unexpected number of routes"); ip4_test_route ("dhcp-dhcpcd-classless-invalid-2", ip4_config, 0, expected_route1_dest, expected_route1_gw, 32); ip4_test_route ("dhcp-dhcpcd-classless-invalid-2", ip4_config, 1, expected_route2_dest, expected_route2_gw, 32); g_hash_table_destroy (options); }
static void test_escaped_domain_searches (void) { GHashTable *options; NMIP4Config *ip4_config; const char *expected_search0 = "host1"; const char *expected_search1 = "host2"; const char *expected_search2 = "host3"; options = fill_table (generic_options, NULL); options = fill_table (escaped_searches_options, options); ip4_config = nm_dhcp_manager_options_to_ip4_config ("eth0", options); ASSERT (ip4_config != NULL, "dhcp-escaped-domain-searches", "failed to parse DHCP4 options"); /* domain searches */ ASSERT (nm_ip4_config_get_num_searches (ip4_config) == 3, "dhcp-escaped-domain-searches", "unexpected number of searches"); ASSERT (!strcmp (nm_ip4_config_get_search (ip4_config, 0), expected_search0), "dhcp-escaped-domain-searches", "unexpected domain search #1"); ASSERT (!strcmp (nm_ip4_config_get_search (ip4_config, 1), expected_search1), "dhcp-escaped-domain-searches", "unexpected domain search #1"); ASSERT (!strcmp (nm_ip4_config_get_search (ip4_config, 2), expected_search2), "dhcp-escaped-domain-searches", "unexpected domain search #1"); g_hash_table_destroy (options); }
static void test_classless_static_routes_2 (const char *client) { GHashTable *options; NMIP4Config *ip4_config; const char *expected_route1_dest = "192.168.10.0"; const char *expected_route1_gw = "192.168.1.1"; const char *expected_route2_dest = "10.0.0.0"; const char *expected_route2_gw = "10.17.66.41"; static Option data[] = { /* dhcpcd format */ { "new_classless_static_routes", "192.168.10.0/24 192.168.1.1 10.0.0.0/8 10.17.66.41" }, { NULL, NULL } }; options = fill_table (generic_options, NULL); options = fill_table (data, options); ip4_config = nm_dhcp_manager_test_ip4_options_to_config (client, "eth0", options, "rebind"); ASSERT (ip4_config != NULL, "dhcp-classless-2", "failed to parse DHCP4 options"); /* IP4 routes */ ASSERT (nm_ip4_config_get_num_routes (ip4_config) == 2, "dhcp-classless-2", "unexpected number of IP routes"); ip4_test_route ("dhcp-classless-2", ip4_config, 0, expected_route1_dest, expected_route1_gw, 24); ip4_test_route ("dhcp-classless-2", ip4_config, 1, expected_route2_dest, expected_route2_gw, 8); g_hash_table_destroy (options); }
static void test_wins_options (void) { GHashTable *options; NMIP4Config *ip4_config; NMIP4Address *addr; struct in_addr tmp; const char *expected_wins1 = "63.12.199.5"; const char *expected_wins2 = "150.4.88.120"; options = fill_table (generic_options, NULL); options = fill_table (wins_options, options); ip4_config = nm_dhcp_manager_options_to_ip4_config ("eth0", options); ASSERT (ip4_config != NULL, "dhcp-wins", "failed to parse DHCP4 options"); /* IP4 address */ ASSERT (nm_ip4_config_get_num_addresses (ip4_config) == 1, "dhcp-wins", "unexpected number of IP addresses"); addr = nm_ip4_config_get_address (ip4_config, 0); ASSERT (nm_ip4_config_get_num_wins (ip4_config) == 2, "dhcp-wins", "unexpected number of WINS servers"); ASSERT (inet_pton (AF_INET, expected_wins1, &tmp) > 0, "dhcp-wins", "couldn't convert expected WINS server address #1"); ASSERT (nm_ip4_config_get_wins (ip4_config, 0) == tmp.s_addr, "dhcp-wins", "unexpected WINS server #1"); ASSERT (inet_pton (AF_INET, expected_wins2, &tmp) > 0, "dhcp-wins", "couldn't convert expected WINS server address #1"); ASSERT (nm_ip4_config_get_wins (ip4_config, 1) == tmp.s_addr, "dhcp-wins", "unexpected WINS server #1"); g_hash_table_destroy (options); }
static void test_classless_static_routes (void) { GHashTable *options; NMIP4Config *ip4_config; NMIP4Route *route; struct in_addr tmp; const char *expected_route1_dest = "192.168.10.0"; const char *expected_route1_gw = "192.168.1.1"; const char *expected_route2_dest = "10.0.0.0"; const char *expected_route2_gw = "10.17.66.41"; options = fill_table (generic_options, NULL); options = fill_table (classless_routes_options, options); ip4_config = nm_dhcp_manager_options_to_ip4_config ("eth0", options); ASSERT (ip4_config != NULL, "dhcp-rfc3442", "failed to parse DHCP4 options"); /* IP4 routes */ ASSERT (nm_ip4_config_get_num_routes (ip4_config) == 2, "dhcp-rfc3442", "unexpected number of IP routes"); /* Route #1 */ route = nm_ip4_config_get_route (ip4_config, 0); ASSERT (inet_pton (AF_INET, expected_route1_dest, &tmp) > 0, "dhcp-rfc3442", "couldn't convert expected route destination #1"); ASSERT (nm_ip4_route_get_dest (route) == tmp.s_addr, "dhcp-rfc3442", "unexpected route #1 destination"); ASSERT (inet_pton (AF_INET, expected_route1_gw, &tmp) > 0, "dhcp-rfc3442", "couldn't convert expected route next hop #1"); ASSERT (nm_ip4_route_get_next_hop (route) == tmp.s_addr, "dhcp-rfc3442", "unexpected route #1 next hop"); ASSERT (nm_ip4_route_get_prefix (route) == 24, "dhcp-rfc3442", "unexpected route #1 prefix"); ASSERT (nm_ip4_route_get_metric (route) == 0, "dhcp-rfc3442", "unexpected route #1 metric"); /* Route #2 */ route = nm_ip4_config_get_route (ip4_config, 1); ASSERT (inet_pton (AF_INET, expected_route2_dest, &tmp) > 0, "dhcp-rfc3442", "couldn't convert expected route destination #2"); ASSERT (nm_ip4_route_get_dest (route) == tmp.s_addr, "dhcp-rfc3442", "unexpected route #2 destination"); ASSERT (inet_pton (AF_INET, expected_route2_gw, &tmp) > 0, "dhcp-rfc3442", "couldn't convert expected route next hop #2"); ASSERT (nm_ip4_route_get_next_hop (route) == tmp.s_addr, "dhcp-rfc3442", "unexpected route #2 next hop"); ASSERT (nm_ip4_route_get_prefix (route) == 8, "dhcp-rfc3442", "unexpected route #2 prefix"); ASSERT (nm_ip4_route_get_metric (route) == 0, "dhcp-rfc3442", "unexpected route #2 metric"); g_hash_table_destroy (options); }
static void test_gateway_in_classless_routes (void) { GHashTable *options; NMIP4Config *ip4_config; NMIP4Address *addr; NMIP4Route *route; struct in_addr tmp; const char *expected_route1_dest = "192.168.10.0"; const char *expected_route1_gw = "192.168.1.1"; const char *expected_gateway = "192.2.3.4"; options = fill_table (generic_options, NULL); options = fill_table (gw_in_classless_routes, options); ip4_config = nm_dhcp_manager_options_to_ip4_config ("eth0", options); ASSERT (ip4_config != NULL, "dhcp-rfc3442-gateway", "failed to parse DHCP4 options"); /* IP4 routes */ ASSERT (nm_ip4_config_get_num_routes (ip4_config) == 1, "dhcp-rfc3442-gateway", "unexpected number of IP routes"); /* Route #1 */ route = nm_ip4_config_get_route (ip4_config, 0); ASSERT (inet_pton (AF_INET, expected_route1_dest, &tmp) > 0, "dhcp-rfc3442-gateway", "couldn't convert expected route destination #1"); ASSERT (nm_ip4_route_get_dest (route) == tmp.s_addr, "dhcp-rfc3442-gateway", "unexpected route #1 destination"); ASSERT (inet_pton (AF_INET, expected_route1_gw, &tmp) > 0, "dhcp-rfc3442-gateway", "couldn't convert expected route next hop #1"); ASSERT (nm_ip4_route_get_next_hop (route) == tmp.s_addr, "dhcp-rfc3442-gateway", "unexpected route #1 next hop"); ASSERT (nm_ip4_route_get_prefix (route) == 24, "dhcp-rfc3442-gateway", "unexpected route #1 prefix"); ASSERT (nm_ip4_route_get_metric (route) == 0, "dhcp-rfc3442-gateway", "unexpected route #1 metric"); /* Address */ ASSERT (nm_ip4_config_get_num_addresses (ip4_config) == 1, "dhcp-rfc3442-gateway", "unexpected number of IP addresses"); addr = nm_ip4_config_get_address (ip4_config, 0); ASSERT (inet_pton (AF_INET, expected_gateway, &tmp) > 0, "dhcp-rfc3442-gateway", "couldn't convert expected IP gateway"); ASSERT (nm_ip4_address_get_gateway (addr) == tmp.s_addr, "dhcp-rfc3442-gateway", "unexpected IP gateway"); g_hash_table_destroy (options); }
static void test_ip4_prefix_classless (const char *client) { GHashTable *options; NMIP4Config *ip4_config; NMIP4Address *addr; /* Ensure that the missing-subnet-mask handler doesn't mangle classless * subnet masks at all. The handler should trigger only if the server * doesn't send the subnet mask. */ options = fill_table (generic_options, NULL); g_hash_table_insert (options, "new_ip_address", string_to_byte_array_gvalue ("172.16.54.22")); g_hash_table_insert (options, "new_subnet_mask", string_to_byte_array_gvalue ("255.255.252.0")); ip4_config = nm_dhcp_manager_test_ip4_options_to_config (client, "eth0", options, "rebind"); ASSERT (ip4_config != NULL, "dhcp-ip4-prefix-classless", "failed to parse DHCP4 options"); ASSERT (nm_ip4_config_get_num_addresses (ip4_config) == 1, "dhcp-ip4-prefix-classless", "unexpected number of IP4 addresses (not 1)"); addr = nm_ip4_config_get_address (ip4_config, 0); ASSERT (addr != NULL, "dhcp-ip4-prefix-classless", "missing IP4 address #1"); ASSERT (nm_ip4_address_get_prefix (addr) == 22, "dhcp-ip4-prefix-classless", "unexpected IP4 address prefix %d (expected 22)", nm_ip4_address_get_prefix (addr)); g_hash_table_destroy (options); }
void thero_selection::catalog_page(twindow& window, int page, bool swap) { if (!page_panel_) { return; } if (current_page_ == page) { return; } int selected_row = 0; if (swap) { // because sort, order is changed. tlistbox& list = *lists_[current_page_]; selected_row = list.get_selected_row(); list.clear(); } page_panel_->set_radio_layer(page); tlistbox& list = *lists_[page]; fill_table(list, page); if (swap) { list.select_row(selected_row); list.invalidate_layout(true); } current_page_ = page; }
void tside_list::catalog_page(twindow& window, int catalog, bool swap) { if (catalog < MIN_PAGE || catalog > MAX_PAGE) { return; } int index = catalog - MIN_PAGE; if (window.alternate_index() == index) { // desired page is the displaying page, do nothing. return; } int selected_row = 0; if (swap) { selected_row = hero_table_->get_selected_row(); } window.alternate_uh(hero_table_, index); fill_table(catalog); if (swap) { window.alternate_bh(hero_table_, index); hero_table_->select_row(selected_row); } else { hero_changed(window); } }
void tartifical_list::catalog_page(twindow& window, int catalog, bool swap) { if (catalog < MIN_PAGE || catalog > MAX_PAGE) { return; } int index = catalog - MIN_PAGE; if (hero_table_->current_page() == index) { // desired page is the displaying page, do nothing. return; } int selected_row = 0; if (swap) { selected_row = hero_table_->get_selected_row(); } hero_table_->swap_uh(window, index); fill_table(catalog); if (swap) { hero_table_->swap_bh(window); hero_table_->select_row(selected_row); } else { city_changed(window); } }
main() { fill_table (); simulate_thread_main (); simulate_thread_done (); return 0; }
void ttreasure_list::catalog_page(twindow& window, int catalog, bool swap) { if (catalog < MIN_PAGE || catalog > MAX_PAGE) { return; } int index = catalog - MIN_PAGE; if (hero_table_->current_page() == index) { // desired page is the displaying page, do nothing. return; } unsigned int selected_row = 0; if (swap) { // because sort, order is changed. selected_row = hero_table_->get_selected_row(); tgrid* grid_ptr = hero_table_->get_row_grid(hero_table_->get_selected_row()); selected_row = dynamic_cast<ttoggle_panel*>(grid_ptr->find("_toggle", true))->get_data(); } hero_table_->swap_uh(window, index); fill_table(catalog); if (swap) { hero_table_->swap_bh(window); hero_table_->select_row(selected_row); // swap to other page, there is no sorted column. sorting_widget_ = NULL; } else { hero_changed(window); } // in order to support sortable, form relative data. std::vector<tbutton*> widgets; if (catalog == OWNERSHIP_PAGE) { widgets.push_back(&find_widget<tbutton>(&window, "button_name", false)); widgets.back()->set_active(false); widgets.push_back(&find_widget<tbutton>(&window, "button_feature", false)); widgets.back()->set_active(false); widgets.push_back(&find_widget<tbutton>(&window, "button_side", false)); widgets.back()->set_active(false); widgets.push_back(&find_widget<tbutton>(&window, "button_hero", false)); widgets.back()->set_active(false); } for (std::vector<tbutton*>::iterator i = widgets.begin(); i != widgets.end(); ++ i) { tbutton& widget = **i; connect_signal_mouse_left_click( widget , boost::bind( &ttreasure_list::sort_column , this , boost::ref(window) , boost::ref(widget))); } sorting_widgets_[catalog] = widgets; // speeden compare_row, remember this catalog. current_page_ = catalog; }
static void test_ip4_missing_prefix (const char *client, const char *ip, guint32 expected_prefix) { GHashTable *options; NMIP4Config *ip4_config; NMIP4Address *addr; options = fill_table (generic_options, NULL); g_hash_table_insert (options, "new_ip_address", string_to_byte_array_gvalue (ip)); g_hash_table_remove (options, "new_subnet_mask"); ip4_config = nm_dhcp_manager_test_ip4_options_to_config (client, "eth0", options, "rebind"); ASSERT (ip4_config != NULL, "dhcp-ip4-missing-prefix", "failed to parse DHCP4 options"); ASSERT (nm_ip4_config_get_num_addresses (ip4_config) == 1, "dhcp-ip4-missing-prefix", "unexpected number of IP4 addresses (not 1)"); addr = nm_ip4_config_get_address (ip4_config, 0); ASSERT (addr != NULL, "dhcp-ip4-missing-prefix", "missing IP4 address #1"); ASSERT (nm_ip4_address_get_prefix (addr) == expected_prefix, "dhcp-ip4-missing-prefix", "unexpected IP4 address prefix %d (expected %d)", nm_ip4_address_get_prefix (addr), expected_prefix); g_hash_table_destroy (options); }
int main() { char* tabNums; uint16_t tabNums_Size; tabNums_Size = count_digits(FILE_NAME); tabNums = malloc(sizeof(char)*tabNums_Size); fill_table(FILE_NAME,tabNums,tabNums_Size); algorithm(tabNums,tabNums_Size); return 0; }
static void test_invalid_escaped_domain_searches (void) { GHashTable *options; NMIP4Config *ip4_config; options = fill_table (generic_options, NULL); options = fill_table (invalid_escaped_searches_options, options); ip4_config = nm_dhcp_manager_options_to_ip4_config ("eth0", options); ASSERT (ip4_config != NULL, "dhcp-invalid-escaped-domain-searches", "failed to parse DHCP4 options"); /* domain searches */ ASSERT (nm_ip4_config_get_num_searches (ip4_config) == 0, "dhcp-invalid-escaped-domain-searches", "unexpected domain searches"); g_hash_table_destroy (options); }
int main ( void ) { /* This is our hash table */ char table[10] = {0}; fill_table ( table ); show_table ( table, length ( table ) ); return 0; }
int main(int argc, char *argv[]){ if(parse_args(argc, argv)) print_usage_and_exit(); determine_num_threads(); if(allocate_states()) return 1; if(init_state(argc, argv)) print_usage_and_exit(); fill_table(); if(init_synchronization_objects()) return 1; if(init_threads()) return 1; uint64_t b, e; b = (statelen * nthreads) / (nthreads + 1); e = statelen - 1; // print_state(states[0]); int i; for(curstate = 1; gen <= gens; gen++){ curstate = !curstate; nthreads_left = nthreads - 1; wrap_state(states[curstate]); pthread_barrier_wait(&barrier); cnt = advance_gen_with_bounds(states[curstate], states[!curstate], b, e) + advance_gen_last_word (states[curstate], states[!curstate]); sem_wait(&sem); // print_state(states[!curstate]); for(i = 0; i < nthreads; i++){ cnt += cnts[i]; } cnt -= states[!curstate][0] & 0x01ul; if(cnt > maxpop){ maxpop = cnt; maxgen = gen; } else if(cnt < minpop){ minpop = cnt; mingen = gen; } } pthread_barrier_wait(&barrier); free_states(); if(join_threads()) return 1; if(destroy_synchronization_objects()) return 1; print_results(); return 0; }
static void test_fedora_dhclient_classless_static_routes (const char *client) { GHashTable *options; NMIP4Config *ip4_config; const char *expected_route1_dest = "129.210.177.128"; const char *expected_route1_gw = "192.168.0.113"; const char *expected_route2_dest = "2.0.0.0"; const char *expected_route2_gw = "10.34.255.6"; const char *expected_gateway = "192.168.0.113"; static Option data[] = { /* Fedora dhclient format */ { "new_classless_static_routes", "0 192.168.0.113 25.129.210.177.132 192.168.0.113 7.2 10.34.255.6" }, { NULL, NULL } }; options = fill_table (generic_options, NULL); options = fill_table (data, options); ip4_config = nm_dhcp_manager_test_ip4_options_to_config (client, "eth0", options, "rebind"); ASSERT (ip4_config != NULL, "dhcp-fedora-dhclient-classless", "failed to parse DHCP4 options"); /* IP4 routes */ ASSERT (nm_ip4_config_get_num_routes (ip4_config) == 2, "dhcp-fedora-dhclient-classless", "unexpected number of IP routes"); ip4_test_route ("dhcp-fedora-dhclient-classless", ip4_config, 0, expected_route1_dest, expected_route1_gw, 25); ip4_test_route ("dhcp-fedora-dhclient-classless", ip4_config, 1, expected_route2_dest, expected_route2_gw, 7); /* Gateway */ ip4_test_gateway ("dhcp-fedora-dhclient-classless", ip4_config, expected_gateway); g_hash_table_destroy (options); }
static void init_task_qinq_encap4(struct task_base *tbase, struct task_args *targ) { struct task_qinq_encap4 *task = (struct task_qinq_encap4 *)(tbase); int socket_id = rte_lcore_to_socket_id(targ->lconf->id); task->qinq_tag = targ->qinq_tag; task->cpe_table = targ->cpe_table; task->cpe_timeout = rte_get_tsc_hz()/1000*targ->cpe_table_timeout_ms; if (!strcmp(targ->task_init->sub_mode_str, "pe")) { PROX_PANIC(!strcmp(targ->cpe_table_name, ""), "CPE table not configured\n"); fill_table(targ, task->cpe_table); } #ifdef ENABLE_EXTRA_USER_STATISTICS task->n_users = targ->n_users; task->stats_per_user = rte_zmalloc_socket(NULL, targ->n_users * sizeof(uint32_t), RTE_CACHE_LINE_SIZE, rte_lcore_to_socket_id(targ->lconf->id)); #endif if (targ->runtime_flags & TASK_CLASSIFY) { PROX_PANIC(!strcmp(targ->dscp, ""), "DSCP table not specified\n"); task->dscp = prox_sh_find_socket(socket_id, targ->dscp); if (!task->dscp) { int ret = lua_to_dscp(prox_lua(), GLOBAL, targ->dscp, socket_id, &task->dscp); PROX_PANIC(ret, "Failed to create dscp table from config:\n%s\n", get_lua_to_errors()); prox_sh_add_socket(socket_id, targ->dscp, task->dscp); } } task->runtime_flags = targ->runtime_flags; for (uint32_t i = 0; i < 64; ++i) { task->fake_packets[i] = (struct rte_mbuf*)((uint8_t*)&task->keys[i] - sizeof (struct rte_mbuf)); } targ->lconf->ctrl_timeout = rte_get_tsc_hz()/targ->ctrl_freq; targ->lconf->ctrl_func_m[targ->task] = arp_msg; /* TODO: check if it is not necessary to limit reverse mapping for the elements that have been changing in mapping? */ for (uint32_t i =0 ; i < sizeof(targ->mapping)/sizeof(targ->mapping[0]); ++i) { task->src_mac[targ->mapping[i]] = *(uint64_t*)&prox_port_cfg[i].eth_addr; } /* task->src_mac[entry->port_idx] = *(uint64_t*)&prox_port_cfg[entry->port_idx].eth_addr; */ }
StorageReserveWidget::StorageReserveWidget(ReserveStruct *rstruct, QWidget *parent) : QWidget(parent), ui(new Ui::StorageReserveWidget) { ui->setupUi(this); //ui->table_widget->set_ this->source = rstruct->source_model; model = 0; set_columns_names(); set_layout(); fill_table(); connects(); }
gint main (gint argc, gchar **argv) { GtkWidget *window; GtkWidget *button; GtkWidget *frame; GtkWidget *table; GtkWidget *vbox; g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING); gtk_init (&argc, &argv); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size (GTK_WINDOW (window), 350, 300); gtk_window_set_title (GTK_WINDOW (window), "ExoWrapTable test"); g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL); vbox = gtk_vbox_new (FALSE, 6); gtk_container_add (GTK_CONTAINER (window), vbox); gtk_widget_show (vbox); frame = g_object_new (GTK_TYPE_FRAME, "border-width", 0, NULL); gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0); gtk_widget_show (frame); table = exo_wrap_table_new (TRUE); gtk_container_add (GTK_CONTAINER (frame), table); gtk_widget_show (table); button = gtk_check_button_new_with_label ("Homogeneous"); exo_mutual_binding_new (G_OBJECT (table), "homogeneous", G_OBJECT (button), "active"); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); fill_table (table); gtk_widget_show (window); gtk_main (); return EXIT_SUCCESS; }
//--------------------------------------------------------------------------- void DisplayWindow::create_web_view_finished(bool ok) { if (!web_view || !ok) { create_html(); mainwindow->set_msg_to_status_bar("Problem to load the checker page"); return; } is_finished = true; if (progress_bar) { mainwindow->remove_widget_from_layout(progress_bar); delete progress_bar; progress_bar = NULL; } web_view->show(); fill_table(); web_view->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); mainwindow->set_widget_to_layout(web_view); }
void tside_report::catalog_page(twindow& window, int catalog, bool swap) { fill_table(*hero_table_, catalog); city_changed(window, *hero_table_); // in order to support sortable, form relative data. std::vector<tbutton*> widgets; if (catalog == STATUS_PAGE) { widgets.push_back(&find_widget<tbutton>(&window, "button_name", false)); widgets.back()->set_active(false); widgets.push_back(&find_widget<tbutton>(&window, "button_hp", false)); widgets.back()->set_active(false); widgets.push_back(&find_widget<tbutton>(&window, "button_xp", false)); widgets.back()->set_active(false); widgets.push_back(&find_widget<tbutton>(&window, "button_hero", false)); widgets.back()->set_active(false); widgets.push_back(&find_widget<tbutton>(&window, "button_troop", false)); widgets.back()->set_active(false); widgets.push_back(&find_widget<tbutton>(&window, "button_income", false)); widgets.back()->set_label(tintegrate::generate_img("misc/gold.png") + " " + tintegrate::generate_img("misc/technology.png")); widgets.back()->set_active(false); widgets.push_back(&find_widget<tbutton>(&window, "button_ea", false)); widgets.back()->set_active(false); } for (std::vector<tbutton*>::iterator i = widgets.begin(); i != widgets.end(); ++ i) { tbutton& widget = **i; connect_signal_mouse_left_click( widget , boost::bind( &tside_report::sort_column , this , boost::ref(widget))); } sorting_widgets_[catalog] = widgets; // speeden compare_row, remember this catalog. current_page_ = catalog; }
int ft_putbin(unsigned long long n, int sizeof_type) { int i; char *out; int binlen; binlen = sizeof_type * 8; if (!(binlen % 8)) { out = ft_strnew(binlen + 1); ft_bzero(out, binlen); fill_table(&n, out, binlen); i = 0; while (out[i]) { if (i && !(i % 8)) ft_putchar(' '); ft_putchar(out[i]); i++; } ft_strdel(&out); } return (binlen + (binlen / 8 - 1)); }
/* * fill the addr and mask fields in the instruction as appropriate from av. * Update length as appropriate. * The following formats are allowed: * any matches any IP6. Actually returns an empty instruction. * me returns O_IP6_*_ME * * 03f1::234:123:0342 single IP6 address * 03f1::234:123:0342/24 address/masklen * 03f1::234:123:0342/ffff::ffff:ffff address/mask * 03f1::234:123:0342/24,03f1::234:123:0343/ List of address * * Set of address (as in ipv6) not supported because ipv6 address * are typically random past the initial prefix. * Return 1 on success, 0 on failure. */ static int fill_ip6(ipfw_insn_ip6 *cmd, char *av, int cblen, struct tidx *tstate) { int len = 0; struct in6_addr *d = &(cmd->addr6); /* * Needed for multiple address. * Note d[1] points to struct in6_add r mask6 of cmd */ cmd->o.len &= ~F_LEN_MASK; /* zero len */ if (strcmp(av, "any") == 0) return (1); if (strcmp(av, "me") == 0) { /* Set the data for "me" opt*/ cmd->o.len |= F_INSN_SIZE(ipfw_insn); return (1); } if (strcmp(av, "me6") == 0) { /* Set the data for "me" opt*/ cmd->o.len |= F_INSN_SIZE(ipfw_insn); return (1); } if (strncmp(av, "table(", 6) == 0) { fill_table(&cmd->o, av, O_IP_DST_LOOKUP, tstate); return (1); } av = strdup(av); while (av) { /* * After the address we can have '/' indicating a mask, * or ',' indicating another address follows. */ char *p, *q; int masklen; char md = '\0'; CHECK_LENGTH(cblen, 1 + len + 2 * F_INSN_SIZE(struct in6_addr)); if ((q = strchr(av, ',')) ) { *q = '\0'; q++; } if ((p = strchr(av, '/')) ) { md = *p; /* save the separator */ *p = '\0'; /* terminate address string */ p++; /* and skip past it */ } /* now p points to NULL, mask or next entry */ /* lookup stores address in *d as a side effect */ if (lookup_host6(av, d) != 0) { /* XXX: failed. Free memory and go */ errx(EX_DATAERR, "bad address \"%s\"", av); } /* next, look at the mask, if any */ if (md == '/' && strchr(p, ':')) { if (!inet_pton(AF_INET6, p, &d[1])) errx(EX_DATAERR, "bad mask \"%s\"", p); masklen = contigmask((uint8_t *)&(d[1]), 128); } else { masklen = (md == '/') ? atoi(p) : 128; if (masklen > 128 || masklen < 0) errx(EX_DATAERR, "bad width \"%s\''", p); else n2mask(&d[1], masklen); } APPLY_MASK(d, &d[1]) /* mask base address with mask */ av = q; /* Check this entry */ if (masklen == 0) { /* * 'any' turns the entire list into a NOP. * 'not any' never matches, so it is removed from the * list unless it is the only item, in which case we * report an error. */ if (cmd->o.len & F_NOT && av == NULL && len == 0) errx(EX_DATAERR, "not any never matches"); continue; } /* * A single IP can be stored alone */ if (masklen == 128 && av == NULL && len == 0) { len = F_INSN_SIZE(struct in6_addr); break; } /* Update length and pointer to arguments */ len += F_INSN_SIZE(struct in6_addr)*2; d += 2; } /* end while */
t_forcetable make_tables(FILE *out,const output_env_t oenv, const t_forcerec *fr, gmx_bool bVerbose,const char *fn, real rtab,int flags) { const char *fns[3] = { "ctab.xvg", "dtab.xvg", "rtab.xvg" }; const char *fns14[3] = { "ctab14.xvg", "dtab14.xvg", "rtab14.xvg" }; FILE *fp; t_tabledata *td; gmx_bool b14only,bReadTab,bGenTab; real x0,y0,yp; int i,j,k,nx,nx0,tabsel[etiNR]; t_forcetable table; b14only = (flags & GMX_MAKETABLES_14ONLY); if (flags & GMX_MAKETABLES_FORCEUSER) { tabsel[etiCOUL] = etabUSER; tabsel[etiLJ6] = etabUSER; tabsel[etiLJ12] = etabUSER; } else { set_table_type(tabsel,fr,b14only); } snew(td,etiNR); table.r = rtab; table.scale = 0; table.n = 0; table.scale_exp = 0; nx0 = 10; nx = 0; /* Check whether we have to read or generate */ bReadTab = FALSE; bGenTab = FALSE; for(i=0; (i<etiNR); i++) { if (ETAB_USER(tabsel[i])) bReadTab = TRUE; if (tabsel[i] != etabUSER) bGenTab = TRUE; } if (bReadTab) { read_tables(out,fn,etiNR,0,td); if (rtab == 0 || (flags & GMX_MAKETABLES_14ONLY)) { rtab = td[0].x[td[0].nx-1]; table.n = td[0].nx; nx = table.n; } else { if (td[0].x[td[0].nx-1] < rtab) gmx_fatal(FARGS,"Tables in file %s not long enough for cut-off:\n" "\tshould be at least %f nm\n",fn,rtab); nx = table.n = (int)(rtab*td[0].tabscale + 0.5); } table.scale = td[0].tabscale; nx0 = td[0].nx0; } if (bGenTab) { if (!bReadTab) { #ifdef GMX_DOUBLE table.scale = 2000.0; #else table.scale = 500.0; #endif nx = table.n = rtab*table.scale; } } if (fr->bBHAM) { if(fr->bham_b_max!=0) table.scale_exp = table.scale/fr->bham_b_max; else table.scale_exp = table.scale; } /* Each table type (e.g. coul,lj6,lj12) requires four * numbers per nx+1 data points. For performance reasons we want * the table data to be aligned to 16-byte. */ snew_aligned(table.tab, 12*(nx+1)*sizeof(real),16); for(k=0; (k<etiNR); k++) { if (tabsel[k] != etabUSER) { init_table(out,nx,nx0, (tabsel[k] == etabEXPMIN) ? table.scale_exp : table.scale, &(td[k]),!bReadTab); fill_table(&(td[k]),tabsel[k],fr); if (out) fprintf(out,"%s table with %d data points for %s%s.\n" "Tabscale = %g points/nm\n", ETAB_USER(tabsel[k]) ? "Modified" : "Generated", td[k].nx,b14only?"1-4 ":"",tprops[tabsel[k]].name, td[k].tabscale); } copy2table(table.n,k*4,12,td[k].x,td[k].v,td[k].f,table.tab); if (bDebugMode() && bVerbose) { if (b14only) fp=xvgropen(fns14[k],fns14[k],"r","V",oenv); else fp=xvgropen(fns[k],fns[k],"r","V",oenv); /* plot the output 5 times denser than the table data */ for(i=5*((nx0+1)/2); i<5*table.n; i++) { x0 = i*table.r/(5*(table.n-1)); evaluate_table(table.tab,4*k,12,table.scale,x0,&y0,&yp); fprintf(fp,"%15.10e %15.10e %15.10e\n",x0,y0,yp); } gmx_fio_fclose(fp); } done_tabledata(&(td[k])); } sfree(td); return table; }
saw_table::saw_table(int x) : wavetable::wavetable(x){ fill_table(); }
saw_table::saw_table() : wavetable::wavetable(){ fill_table(); }