int main(int argc, char *argv[]) { // Disable IO buffering setbuf(stdin, NULL); setbuf(stdout, NULL); std::cout.rdbuf()->pubsetbuf(NULL, 0); std::cin.rdbuf()->pubsetbuf(NULL, 0); // Initialization init_mersenne(); init_direction_table(); init_bitboards(); init_uci_options(); Position::init_zobrist(); Position::init_piece_square_tables(); MaterialInfo::init(); MovePicker::init_phase_table(); init_eval(1); init_bitbases(); init_threads(); // Make random number generation less deterministic, for book moves int i = abs(get_system_time() % 10000); for(int j = 0; j < i; j++) genrand_int32(); // Process command line arguments if(argc >= 2) { if(std::string(argv[1]) == "bench") { if(argc != 4) { std::cout << "Usage: glaurung bench <hash> <threads>" << std::endl; exit(0); } benchmark(std::string(argv[2]), std::string(argv[3])); return 0; } } // Print copyright notice std::cout << engine_name() << ". " << "Copyright (C) 2004-2008 Tord Romstad." << std::endl; // Enter UCI mode uci_main_loop(); return 0; }
static void stats_engine(struct Client* to, struct StatDesc* sd, int stat, char* param) { send_reply(to, RPL_STATSENGINE, engine_name()); }
/* void imeActivateEngine (in string engine, out boolean activationSucceeded); */ NS_IMETHODIMP nsNativeEvents::ImeActivateEngine(const char *engine, PRBool *activationSucceeded) { LOG(DEBUG) << "Activating IME engine " << engine; IMELIB_TYPE lib = tryToOpenImeLib(); if (lib == NULL) { return NS_ERROR_FAILURE; } create_h* create_handler = getCreateHandler(lib); ImeHandler* handler = create_handler(); // 1. Make sure the requested engine is in the list of installed engines. std::string engine_name(engine); std::vector<std::string> engines = handler->GetAvailableEngines(); if (std::find(engines.begin(), engines.end(), engine_name) == engines.end()) { // Not found LOG(DEBUG) << "Engine not installed."; *activationSucceeded = false; tryToCloseImeLib(handler, lib); return NS_OK; } // 2. If the engine is available but not loaded, load it. std::vector<std::string> loaded_engines = handler->GetInstalledEngines(); if (std::find(loaded_engines.begin(), loaded_engines.end(), engine_name) == loaded_engines.end()) { LOG(DEBUG) << "Engine not loaded, loading."; // Append the engine to the list of loaded engines - not to override // the engines already in use by the user. int currently_loaded = loaded_engines.size(); loaded_engines.push_back(engine_name); int newly_loaded = handler->LoadEngines(loaded_engines); LOG(DEBUG) << "Number of engines loaded:" << newly_loaded; // Make sure that the engine was loaded by comparing the number of engines // now loaded to the number of engines loaded before the LoadEngine call. if (currently_loaded + 1 != newly_loaded) { LOG(DEBUG) << "Engine is installed but could not be loaded."; *activationSucceeded = false; tryToCloseImeLib(handler, lib); return NS_OK; } // Wait for ibus to register the engine. Without the sleep statement here, // the call to ActivateEngine will fail. This is only needed on Linux. #ifdef BUILD_ON_UNIX sleep(1); #endif } else { LOG(DEBUG) << "Engine already loaded, not calling LoadEngines again."; } // 3. Finally, call ActivateEngine to immediately make this engine active. *activationSucceeded = handler->ActivateEngine(engine); LOG(DEBUG) << "Activation result: " << *activationSucceeded << " isActive: " << handler->IsActivated(); tryToCloseImeLib(handler, lib); return NS_OK; }