// --------------------------------------------------------------------------- // Program entry point // --------------------------------------------------------------------------- int main(int argc, char* argv[]) { if (parser_param(argc, argv) == 1) return 1; sqlite3_open("dblp.db", &db); memset(sql, '\0', sizeof(sql)); strcpy(sql, "create table id_tb (id INTEGER PRIMARY KEY, title TEXT, author TEXT)"); sqlite3_exec(db, sql, NULL, NULL, NULL); begin_trans(); const char* insertSQL = "INSERT INTO id_tb (title, author) VALUES (?,?)"; if (sqlite3_prepare_v2(db, insertSQL, strlen(insertSQL), &stmt2, NULL) != SQLITE_OK) { if (stmt2) sqlite3_finalize(stmt2); sqlite3_close(db); return 0; } xml_initial(); xml_parser(); xml_terminate(); commit_trans(); sqlite3_close(db); if (errorOccurred) return 4; else return 0; }
void test_gri30_xml() { std::string filename = std::string(ANTIOCH_SHARE_XML_INPUT_FILES_SOURCE_PATH)+"gri30.xml"; const std::string phase("gri30_mix"); Antioch::XMLParser<Scalar> xml_parser(filename,phase,false); std::vector<std::string> species_str_list = xml_parser.species_list(); this->check_species_list(species_str_list); // GRI3 is NASA7 CPPUNIT_ASSERT( xml_parser.is_nasa7_curve_fit_type() ); Antioch::ChemicalMixture<Scalar> chem_mixture( species_str_list ); Antioch::NASAThermoMixture<Scalar, Antioch::NASA7CurveFit<Scalar> > nasa_mixture( chem_mixture ); //xml_parser.read_thermodynamic_data(nasa_mixture); Antioch::read_nasa_mixture_data( nasa_mixture, filename, Antioch::XML ); this->check_curve_fits(nasa_mixture); Antioch::ReactionSet<Scalar> reaction_set( chem_mixture ); Antioch::read_reaction_set_data_xml<Scalar>(filename, true, reaction_set); this->check_reaction_set(reaction_set); Antioch::TransportMixture<Scalar> trans_mixture( chem_mixture, &xml_parser ); this->check_transport_mixture(trans_mixture); }
void msg_distribution::do_msg_send(const string &content, int error_code) { #ifdef _DEBUG //m_send_session->send_pkt(content); //return; vvlog_i("start time:"<< v_get_current_time_str() << "content:" << content); #endif if (v_OK != error_code) { vvlog_w("error msg:" << content << "code_num:" << error_code); return; } msg_xml_parser xml_parser(content); ds_tcp_session_ptr ds_tcp_client_session = nullptr; if (!s_host_session_lists.find(xml_parser.device_id(), ds_tcp_client_session)) { //read_host_info(s_host_list_info_name); read_all_host_lists_info(m_host_listen_dir); if (0 < msg_distribution::s_host_listen_lists.size()) { map<int, string> tmp = msg_distribution::s_host_listen_lists.get_copy(); for (auto item: tmp) { if (v_str_compare_no_case(item.second, xml_parser.manufacture())) { ds_tcp_client_session.reset(new ds_tcp_session("127.0.0.1", item.first, 30000)); ds_tcp_client_session->connect(); ds_tcp_client_session->subscribe_event_handler(std::bind(&msg_distribution::do_msg_receive, shared_from_this(), placeholders::_1, placeholders::_2)); //ds_tcp_client_session->wait_request(); //ds_tcp_client_session->keep_alive(); } } } s_host_session_lists.insert(xml_parser.device_id(), ds_tcp_client_session); } if (ds_tcp_client_session) { //ds_tcp_client_session->subscribe_event_handler(std::bind(&msg_distribution::do_msg_receive, shared_from_this(), placeholders::_1, placeholders::_2)); ds_tcp_client_session->send_pkt(content); ds_tcp_client_session->wait_request(); } vvlog_i("end time:"<< v_get_current_time_str()); }
int main(int ac, char **av) { t_global *global; t_xtree *tree; srandom(time(0) * getpid()); if ((global = malloc(sizeof(*global))) == NULL) return (EXIT_FAILURE); global_thread = global; global->object = NULL; global->param = POSITION; if (!get_cmd_line(ac, av, &(global->info))) return (EXIT_FAILURE); my_putstr("[*] Raytracer: Creation of the tree ..."); if ((tree = xml_parser(global->info.xml)) == NULL) return (my_puterror(" \033[31mFail !\033[00m\n")); my_putstr(" \033[32mDone !\033[00m\n"); if ((main_option(global, tree)) == EXIT_FAILURE) return (EXIT_FAILURE); return (EXIT_SUCCESS); }
/* Loads the levels described in the levels' configuratino file * If any sintax error is found, the program is aborted. */ void load_levels() { xml_node_t *root, **level, **aux; char *attr; int i; root = xml_parser(LEVELS_CONFIG_FILE); if(root->child_nodes == NULL || strcmp(root->child_nodes[0]->name, "chessdbot")) quit("Error: Malformed levels configuration file!\n"); level = get_elements_by_tag_name(root, "level"); if(level == NULL) quit("Error: Malformed levels configuration file!\n"); for(num_levels = 0, aux = level; *aux; aux++, num_levels++); levels = (level_t **) malloc(num_levels * sizeof(level_t *)); if(levels == NULL) quit("Error: Could not load levels configuration file!\n"); for(i = 0; i < num_levels; i++) { levels[i] = (level_t *) malloc(sizeof(level_t)); if(levels[i] == NULL) quit("Error: Could not load levels configuration file!\n"); attr = get_attribute(level[i], "name"); levels[i]->name = malloc((strlen(attr)+1) * sizeof(char)); if(levels[i]->name == NULL) quit("Error: Could not load levels configuration file!\n"); strcpy(levels[i]->name, attr); aux = get_elements_by_tag_name(level[i], "search"); if(aux == NULL) quit("Error: Malformed levels configuration file!\n"); attr = get_attribute(*aux, "max_depth"); if(attr == NULL) quit("Error: Malformed levels configuration file!\n"); levels[i]->max_depth = atoi(attr); if(levels[i]->max_depth < 2) quit("Error: max_depth must be at least 2\n"); attr = get_attribute(*aux, "max_seconds"); if(attr == NULL) quit("Error: Malformed levels configuration file!\n"); levels[i]->max_seconds = atoi(attr); if(levels[i]->max_seconds < 1) quit("Error: max_seconds must be at least 1\n"); free(aux); aux = get_elements_by_tag_name(level[i], "heuristic"); if(aux == NULL) quit("Error: Malformed levels configuration file!\n"); attr = get_attribute(*aux, "pawn_val"); if(attr == NULL) quit("Error: Malformed levels configuration file!\n"); levels[i]->pawn_val = atoi(attr); if(levels[i]->pawn_val < 0) quit("Error: pawn_val must be at least 0\n"); attr = get_attribute(*aux, "bishop_val"); if(attr == NULL) quit("Error: Malformed levels configuration file!\n"); levels[i]->bishop_val = atoi(attr); if(levels[i]->bishop_val < 0) quit("Error: bishop_val must be at least 0\n"); attr = get_attribute(*aux, "knight_val"); if(attr == NULL) quit("Error: Malformed levels configuration file!\n"); levels[i]->knight_val = atoi(attr); if(levels[i]->knight_val < 0) quit("Error: knight_val must be at least 0\n"); attr = get_attribute(*aux, "rook_val"); if(attr == NULL) quit("Error: Malformed levels configuration file!\n"); levels[i]->rook_val = atoi(attr); if(levels[i]->rook_val < 0) quit("Error: rook_val must be at least 0\n"); attr = get_attribute(*aux, "queen_val"); if(attr == NULL) quit("Error: Malformed levels configuration file!\n"); levels[i]->queen_val = atoi(attr); if(levels[i]->queen_val < 0) quit("Error: queen_val must be at least 0\n"); attr = get_attribute(*aux, "king_val"); if(attr == NULL) quit("Error: Malformed levels configuration file!\n"); levels[i]->king_val = atoi(attr); if(levels[i]->king_val < 0) quit("Error: king_val must be at least 0\n"); attr = get_attribute(*aux, "factor_material"); if(attr == NULL) quit("Error: Malformed levels configuration file!\n"); levels[i]->factor_material = atoi(attr); if(levels[i]->factor_material < 0) quit("Error: factor_material must be at least 0\n"); attr = get_attribute(*aux, "factor_development"); if(attr == NULL) quit("Error: Malformed levels configuration file!\n"); levels[i]->factor_development = atoi(attr); if(levels[i]->factor_development < 0) quit("Error: factor_development must be at least 0\n"); attr = get_attribute(*aux, "factor_pawn"); if(attr == NULL) quit("Error: Malformed levels configuration file!\n"); levels[i]->factor_pawn = atoi(attr); if(levels[i]->factor_pawn < 0) quit("Error: factor_pawn must be at least 0\n"); attr = get_attribute(*aux, "factor_bishop"); if(attr == NULL) quit("Error: Malformed levels configuration file!\n"); levels[i]->factor_bishop = atoi(attr); if(levels[i]->factor_bishop < 0) quit("Error: factor_bishop must be at least 0\n"); attr = get_attribute(*aux, "factor_king"); if(attr == NULL) quit("Error: Malformed levels configuration file!\n"); levels[i]->factor_king = atoi(attr); if(levels[i]->factor_king < 0) quit("Error: factor_king must be at least 0\n"); attr = get_attribute(*aux, "factor_knight"); if(attr == NULL) quit("Error: Malformed levels configuration file!\n"); if(levels[i]->factor_knight < 0) quit("Error: factor_knight must be at least 0\n"); levels[i]->factor_knight = atoi(attr); attr = get_attribute(*aux, "factor_queen"); if(attr == NULL) quit("Error: Malformed levels configuration file!\n"); levels[i]->factor_queen = atoi(attr); if(levels[i]->factor_queen < 0) quit("Error: factor_queen must be at least 0\n"); attr = get_attribute(*aux, "factor_rook"); if(attr == NULL) quit("Error: Malformed levels configuration file!\n"); levels[i]->factor_rook = atoi(attr); if(levels[i]->factor_rook < 0) quit("Error: factor_rook must be at least 0\n"); attr = get_attribute(*aux, "bonus_early_queen_move"); if(attr == NULL) quit("Error: Malformed levels configuration file!\n"); levels[i]->bonus_early_queen_move = atoi(attr); attr = get_attribute(*aux, "bonus_early_bishop_stuck"); if(attr == NULL) quit("Error: Malformed levels configuration file!\n"); levels[i]->bonus_early_bishop_stuck = atoi(attr); attr = get_attribute(*aux, "bonus_early_knight_stuck"); if(attr == NULL) quit("Error: Malformed levels configuration file!\n"); levels[i]->bonus_early_knight_stuck = atoi(attr); attr = get_attribute(*aux, "bonus_has_castled"); if(attr == NULL) quit("Error: Malformed levels configuration file!\n"); levels[i]->bonus_has_castled = atoi(attr); attr = get_attribute(*aux, "bonus_hasnt_castled"); if(attr == NULL) quit("Error: Malformed levels configuration file!\n"); levels[i]->bonus_hasnt_castled = atoi(attr); attr = get_attribute(*aux, "bonus_passed_pawn"); if(attr == NULL) quit("Error: Malformed levels configuration file!\n"); levels[i]->bonus_passed_pawn = atoi(attr); attr = get_attribute(*aux, "bonus_isolated_pawn"); if(attr == NULL) quit("Error: Malformed levels configuration file!\n"); levels[i]->bonus_isolated_pawn = atoi(attr); attr = get_attribute(*aux, "bonus_backward_pawn"); if(attr == NULL) quit("Error: Malformed levels configuration file!\n"); levels[i]->bonus_backward_pawn = atoi(attr); attr = get_attribute(*aux, "bonus_doubled_pawn"); if(attr == NULL) quit("Error: Malformed levels configuration file!\n"); levels[i]->bonus_doubled_pawn = atoi(attr); attr = get_attribute(*aux, "bonus_tripled_pawn"); if(attr == NULL) quit("Error: Malformed levels configuration file!\n"); levels[i]->bonus_tripled_pawn = atoi(attr); attr = get_attribute(*aux, "bonus_doubled_bishop"); if(attr == NULL) quit("Error: Malformed levels configuration file!\n"); levels[i]->bonus_doubled_bishop = atoi(attr); attr = get_attribute(*aux, "bonus_fianchetto_bishop"); if(attr == NULL) quit("Error: Malformed levels configuration file!\n"); levels[i]->bonus_fianchetto_bishop = atoi(attr); attr = get_attribute(*aux, "bonus_knight_on_edge"); if(attr == NULL) quit("Error: Malformed levels configuration file!\n"); levels[i]->bonus_knight_on_edge = atoi(attr); attr = get_attribute(*aux, "bonus_knight_on_hole"); if(attr == NULL) quit("Error: Malformed levels configuration file!\n"); levels[i]->bonus_knight_on_hole = atoi(attr); attr = get_attribute(*aux, "bonus_rook_open_file"); if(attr == NULL) quit("Error: Malformed levels configuration file!\n"); levels[i]->bonus_rook_open_file = atoi(attr); attr = get_attribute(*aux, "bonus_rook_halfopen_file"); if(attr == NULL) quit("Error: Malformed levels configuration file!\n"); levels[i]->bonus_rook_halfopen_file = atoi(attr); attr = get_attribute(*aux, "bonus_queen_open_file"); if(attr == NULL) quit("Error: Malformed levels configuration file!\n"); levels[i]->bonus_queen_open_file = atoi(attr); attr = get_attribute(*aux, "bonus_queen_halfopen_file"); if(attr == NULL) quit("Error: Malformed levels configuration file!\n"); levels[i]->bonus_queen_halfopen_file = atoi(attr); attr = get_attribute(*aux, "bonus_center_control"); if(attr == NULL) quit("Error: Malformed levels configuration file!\n"); levels[i]->bonus_center_control = atoi(attr); free(aux); } free(level); clean_xml_node(root); }