示例#1
0
文件: main.cpp 项目: ageneau/scid
int main(int argc, char * argv[]) {

   // init

   util_init();
   my_random_init(); // for opening book

   printf("Toga II 1.2.1a UCI based on Fruit 2.1 by Thomas Gaksch and Fabien Letouzey. Settings by Dieter Eberle\n");

   // early initialisation (the rest is done after UCI options are parsed in protocol.cpp)

   option_init();

   square_init();
   piece_init();
   pawn_init_bit();
   value_init();
   vector_init();
   attack_init();
   move_do_init();

   random_init();
   hash_init();

   trans_init(Trans);
   book_init();

   // loop

   loop();

   return EXIT_SUCCESS;
}
示例#2
0
文件: mass.c 项目: starrify/cw4aai
static void mass_init(int argc, char **argv)
{
    option_init(argc, argv);

    if (!option_output_file)
        option_output_file = "a.out";

    if (!option_input_file)
    {
        errmsg("mass: error: no input file specified\n");
        exit(0);
    }

    FILE *tmp_in = fopen(option_input_file, "r");
    if (!tmp_in)
    {
        errmsg("mass: error: %s: %s\n", option_input_file, strerror(errno));
        exit(0);
    }
    yyset_in(tmp_in);

    symbol_table_init();
    buf_init();
    return;
}
示例#3
0
文件: option.c 项目: niklasf/polyglot
void option_init_pg() {

    int i;
    option_t *p=DefaultOptions;
    char *home_dir;
    char SettingsDir[StringSize];
    
    option_init(Option);
    while(p){
        if(p->name){
            option_insert(Option,p);
            p++;
        }else{
            break;
        }
    }
    for(i=0;i<Option->option_nb;i++){
        Option->options[i].value=my_strdup(Option->options[i].default_);
    }
#ifndef _WIN32
    home_dir=getenv("HOME");
    if(!home_dir){
        home_dir=".";
    }
    snprintf(SettingsDir,sizeof(SettingsDir),"%s/.polyglot",home_dir);
    SettingsDir[sizeof(SettingsDir)-1]='\0';
#else
    sprintf(SettingsDir,".\\_PG");
#endif
    option_set(Option,"SettingsDir",SettingsDir);
    option_set_default(Option,"SettingsDir",SettingsDir);
}
示例#4
0
int main(int argc, char *argv[]) {

	// init

	util_init();
	my_random_init(); // for opening book

	printf(
		"Gambit Fruit based on Fruit 2.1 and Toga by Ryan Benitez, Thomas Gaksch and Fabien Letouzey\nEdit by Evgeniy Zheltonozhskiy\n");

	// early initialisation (the rest is done after UCI options are parsed in protocol.cpp)

	option_init();

	square_init();
	piece_init();
	pawn_init_bit();
	value_init();
	vector_init();
	attack_init();
	move_do_init();

	random_init();
	hash_init();

	trans_init(Trans);
	book_init();

	// loop
	loop();

	return EXIT_SUCCESS;
}
示例#5
0
/* Add an integer option to the options table. This is intended to be used at
 * initialization to make a table of valid options and their default values. */
static void option_add_int (const char *name, const int value, int (*check) (int, ...), const int count, ...)
{
	int ix, pos;
	va_list va;

	pos = option_init (name, OPTION_INT);
	options[pos].value.num = value;
	options[pos].check = check;
	options[pos].count = count;
	if (count > 0) {
		options[pos].constraints = xcalloc (count, sizeof (int));
		va_start (va, count);
		for (ix = 0; ix < count; ix += 1)
			((int *) options[pos].constraints)[ix] = va_arg (va, int);
		va_end (va);
	}
示例#6
0
int main(int argc, char *argv[])
{
    option_t opt;
    int arg_used = 0;
    const char *command = NULL;
    const char *argv0 = argv[0];
    FILE *fpi = stdin, *fpo = stdout, *fpe = stderr;

    /* Show the copyright information. */
    fprintf(fpe, APPLICATION_S " " VERSION_S "  " COPYRIGHT_S "\n");
    fprintf(fpe, "\n");

    /* Parse the command-line option. */
    option_init(&opt);
    arg_used = option_parse(++argv, --argc, parse_options, &opt);
    if (arg_used < 0) {
        return 1;
    }

    /* Show the help message if specified. */
    if (opt.help) {
        show_usage(fpo, argv0);
        return 0;
    }

    /* Check whether a command is specified in the command-line. */
    if (argc <= arg_used) {
        fprintf(fpe, "ERROR: No command specified. See help (-h) for the usage.\n");
        return 1;
    }

    /* Execute the command. */
    command = argv[arg_used];
    if (strcmp(command, "learn") == 0) {
        return main_learn(argc-arg_used, argv+arg_used, argv0);
    } else if (strcmp(command, "tag") == 0) {
        return main_tag(argc-arg_used, argv+arg_used, argv0);
    } else if (strcmp(command, "dump") == 0) {
        return main_dump(argc-arg_used, argv+arg_used, argv0);
    } else {
        fprintf(fpe, "ERROR: Unrecognized command (%s) specified.\n", command);    
        return 1;
    }

    return 0;
}
示例#7
0
static int test_option_cb()
{
	op_handle op = option_init("option.txt", g_reg, sizeof(g_reg)/sizeof(g_reg[0]), test_option_log_cb_v);

	if (op == NULL){
		fprintf(stderr, "option_init fail\n");
		return 1;
	}
	
#if 0
	option_set_int(&op_int, 5);
	option_set_int(&op_bool, 0);
	option_set_int(&op_combo, 2);
	option_set_float(&op_double, 1.111);
	option_set_string(&op_string, "dulm", 4);
#endif

	option_release(op);

	return 0;
}
示例#8
0
文件: lshosts.c 项目: narupo/bottle
int
main(int argc, char* argv[]) {
	// Initialize default values
	char const* hostbase = "192.168.11.";
	char const* port = "80";

	// Parse options
	Option option;
	if (option_init(&option, argc, argv) != 0) {
		perror("option_init");
	}

	// Change state by options
	if (option.is_help) {
		usage();
	}

	if (option.port) {
		port = option.port;
	}

	// Try connect to all hosts by port
	char hostname[128];
	int i;

	for (i = option.begin; i <= option.end; ++i) {
		snprintf(hostname, sizeof hostname, "%s%d", hostbase, i);

		fprintf(stderr, "Scan \"%s:%s\"\n", hostname, port);

		if (can_connect_host(hostname, port)) {
			printf("%s\n", hostname);
		}		
	}

    return 0;
}
示例#9
0
int main(int argc, char * argv[]) {

	//   board_t board[1];

	// init

	Init = false;
#ifdef _WIN32
	signal(SIGINT,SIG_IGN);
	signal(SIGTERM,SIG_IGN);
#ifdef SIGPIPE
	signal(SIGPIPE,SIG_IGN);
#endif
#endif

	util_init();
	printf("PolyGlot %s by Fabien Letouzey\n",Version);

	option_init();
	uci_options_init();
	square_init();
	piece_init();
	attack_init();

	hash_init();

	my_random_init();

	// build book

	if (argc >= 2 && my_string_equal(argv[1],"make-book")) {
		book_make(argc,argv);
		return EXIT_SUCCESS;
	}

	if (argc >= 2 && my_string_equal(argv[1],"merge-book")) {
		book_merge(argc,argv);
		return EXIT_SUCCESS;
	}

	// read options

	if (argc == 2) option_set("OptionFile",argv[1]); // HACK for compatibility

	parse_option(); // HACK: also launches the engine

	// EPD test

	if (argc >= 2 && my_string_equal(argv[1],"epd-test")) {
		epd_test(argc,argv);
		return EXIT_SUCCESS;
	}

	// opening book

	book_clear();
	if (option_get_bool("Book")){
		if (book_open(option_get_string("BookFile")))
			option_set("Book","false");//some error,set to false
	}
	//adapter_loop();
#ifdef _WIN32
	Engine_ready_ok=CreateEvent(NULL,FALSE,FALSE,NULL);
	Engine_sync_stop = CreateEvent(NULL,FALSE,FALSE,NULL);
	// all set and done.lets open a thread for fun
	DWORD dwThreadID;
	HANDLE hThread;
	hThread= CreateThread(
		NULL,	//default security attributes
		0,	//default stacksize
		ThreadFunc,	//The thread function!
		&sCommand,	//the commands for the thread function
		0,			//default creation flags
		&dwThreadID);	//the thread identifier
	Idle500msecs();//
	if(hThread==NULL){
		my_log("CreateThread failed\n");
	}

#endif
	adapter_loop();
	engine_send(Engine,"quit");
	engine_close(Engine);
#ifdef _WIN32
	CloseHandle(hThread); //close the thread;
#endif
	return EXIT_SUCCESS;
}