int rcvwinsize( int sock) { char buf[PBS_TERM_BUF_SZ]; if (read_net(sock, buf, PBS_TERM_BUF_SZ) != PBS_TERM_BUF_SZ) { /* FAILURE */ return(-1); } if (sscanf(buf, "WINSIZE %hu,%hu,%hu,%hu", &wsz.ws_row, &wsz.ws_col, &wsz.ws_xpixel, &wsz.ws_ypixel) != 4) { /* FAILURE */ return(-1); } return(0); } /* END rcvwinsize() */
char *rcvttype( int sock) { static char buf[PBS_TERM_BUF_SZ]; /* read terminal type as sent by qsub */ if ((read_net(sock, buf, PBS_TERM_BUF_SZ) != PBS_TERM_BUF_SZ) || (strncmp(buf, "TERM=", 5) != 0)) { return(NULL); } /* get the basic control characters from qsub's termial */ if (read_net(sock, cc_array, PBS_TERM_CCA) != PBS_TERM_CCA) { return(NULL); } return(buf); }
int main(int argc, char* argv[]) { setlocale(LC_ALL, "Russian"); try { if (argc != 2) { std::cerr << "Usage: async_tcp_echo_server <port>\n"; return 1; } config_t config; if( !read_config(config) ) throw simple_exception(std::string("Error : cannot find ") + std::string(CONFIG_FILE)); if( config.count("os") == 0 ) throw simple_exception(std::string("Error : os not defined in") + std::string(CONFIG_FILE) + std::string(". Add something like os=windows or os=linux")); if( config.count("workdir") > 0 ) if( change_dir(config["workdir"].data()) != 0 ) std::cerr << "Warning : cannot change directory to " << config["workdir"] << std::endl; std::vector<std::string> addresses; std::vector< std::stack<int> > ports; if( !read_net(addresses, ports) ) std::cerr << "Warning : cannot read net description file " << NET_DESCRIPTION_FILE << std::endl; os = config["os"]; grid_node node(boost::lexical_cast<short>(argv[1]), addresses, ports); node.run(); node.wait(); return 0; } catch (std::exception& e) { std::cerr << "Exception: " << e.what() << "\n"; } return 1; }
int stack::simulation() { // set printout conditions set_runparms(); // any changes to simulation run profile set in pwan1.cpp should be inserted here // // some good examples are: // // internet = TRUE; // use internet notation for hosts // interactive = TRUE; // makes output interactive // max_DES_ticks = 500000; // changes simulation limit // diskout = NULL; // turns off disk output // print_at[frame_send_interface] = FALSE; // turns off/on layer trace // number_of_hosts_sending_email = 1; // simplifies traffic for debug // link_bit_error_rate = 0; // stops bit errors for debug // // print out authors print_authors(); // initialize network if(read_net()) { if(wan)create_topology(); print_topology(); if(wan)startup_routing(); if(multicast) { create_mc_topology(); print_mc_topology(); } startup_simulation(); } // run simulation while(next_event()); statistics(); return SUCCESS; }
int main(int argc, char *argv[]) { try { setlocale(LC_ALL, "Russian"); std::vector<std::string> addresses; std::vector< std::stack<int> > ports; if( !read_net(addresses, ports) ) throw simple_exception("Error : reading grid net description failed"); grid_client gc; gc.run(addresses, ports); menu_t menu = get_menu(); while(1) { std::string user_str; std::getline(std::cin, user_str); boost::to_lower(user_str); std::vector<std::string> split_vec; boost::algorithm::split(split_vec, user_str, boost::algorithm::is_any_of(" \t")); if( split_vec.empty() ) continue; std::string user_command = split_vec.front(); std::string task_name = split_vec.size() > 1 ? split_vec[1] : std::string(); grid_task gt; //*********************************************************************** if( user_command == menu[QUIT].command ) { break; } //*********************************************************************** else if( user_command == menu[APPLY_TASK].command ) { if( !task_name.empty() ) { std::ifstream fin(task_name.data()); if( fin ) { if( parse_task(gt, fin) ) gc.apply_task(gt); } else std::cerr << "Error : cannot open task.txt" << std::endl; fin.close(); } else std::cout << menu[APPLY_TASK].definition << std::endl; } //*********************************************************************** else if( user_command == menu[REMOVE_TASK].command ) { if( !task_name.empty() ) gc.remove_task(task_name); else std::cout << menu[REMOVE_TASK].definition << std::endl; } //*********************************************************************** else if( user_command == menu[REFRESH_STATUS].command ) { if( !task_name.empty() ) gc.refresh_status(task_name); else std::cout << menu[REFRESH_STATUS].definition << std::endl; } //*********************************************************************** else if( user_command == menu[GET_RESULT].command ) { if( !task_name.empty() ) gc.get_result(task_name); else std::cout << menu[GET_RESULT].definition << std::endl; } //*********************************************************************** else if( user_command == menu[STATUS].command ) { if( !task_name.empty() ) std::cout << gc.task_status_message(task_name) << std::endl; else std::cout << menu[STATUS].definition << std::endl; } //*********************************************************************** else if( user_command == menu[TASKS].command ) { grid_client::pair_string_vector tasks; gc.tasks(tasks); for(grid_client::pair_string_vector::const_iterator i = tasks.begin(); i < tasks.end(); ++i) std::cout << i->first << '\t' << i->second << std::endl; } //*********************************************************************** else { for(menu_t::const_iterator i = menu.begin(); i != menu.end(); ++i) std::cout << i->second.command << '\t' << i->second.definition << std::endl; } //*********************************************************************** } gc.stop(); } catch(const std::exception &ex) { std::cerr << ex.what() << std::endl; } return 0; }
static void get_input (char *net_file, char *arch_file, int place_cost_type, int num_regions, float aspect_ratio, boolean user_sized, enum e_route_type route_type, struct s_det_routing_arch *det_routing_arch, t_segment_inf **segment_inf_ptr, t_timing_inf *timing_inf_ptr, t_subblock_data *subblock_data_ptr, t_chan_width_dist *chan_width_dist_ptr) { /* This subroutine reads in the netlist and architecture files, initializes * * some data structures and does any error checks that require knowledge of * * both the algorithms to be used and the FPGA architecture. */ printf("Reading the FPGA architectural description from %s.\n", arch_file); read_arch (arch_file, route_type, det_routing_arch, segment_inf_ptr, timing_inf_ptr, subblock_data_ptr, chan_width_dist_ptr); printf("Successfully read %s.\n",arch_file); printf("Pins per clb: %d. Pads per row/column: %d.\n", pins_per_clb, io_rat); printf("Subblocks per clb: %d. Subblock LUT size: %d.\n", subblock_data_ptr->max_subblocks_per_block, subblock_data_ptr->subblock_lut_size); if (route_type == DETAILED) { if (det_routing_arch->Fc_type == ABSOLUTE) printf("Fc value is absolute number of tracks.\n"); else printf("Fc value is fraction of tracks in a channel.\n"); printf("Fc_output: %g. Fc_input: %g. Fc_pad: %g.\n", det_routing_arch->Fc_output, det_routing_arch->Fc_input, det_routing_arch->Fc_pad); if (det_routing_arch->switch_block_type == SUBSET) printf("Switch block type: Subset.\n"); else if (det_routing_arch->switch_block_type == WILTON) printf("Switch_block_type: WILTON.\n"); else printf ("Switch_block_type: UNIVERSAL.\n"); printf ("Distinct types of segments: %d.\n", det_routing_arch->num_segment); printf ("Distinct types of user-specified switches: %d.\n", det_routing_arch->num_switch - 2); } printf ("\n"); printf("Reading the circuit netlist from %s.\n",net_file); read_net (net_file, subblock_data_ptr); printf("Successfully read %s.\n", net_file); printf("%d blocks, %d nets, %d global nets.\n", num_blocks, num_nets, num_globals); printf("%d clbs, %d inputs, %d outputs.\n", num_clbs, num_p_inputs, num_p_outputs); /* Set up some physical FPGA data structures that need to * * know num_blocks. */ init_arch(aspect_ratio, user_sized); printf("The circuit will be mapped into a %d x %d array of clbs.\n\n", nx, ny); if (place_cost_type == NONLINEAR_CONG && (num_regions > nx || num_regions > ny)) { printf("Error: Cannot use more regions than clbs in placement cost " "function.\n"); exit(1); } }