Пример #1
0
main(){
	int fd1, fd2;

	exp_loguser = 1;
	exp_timeout = 3600;

	fd1 = exp_spawnl("chess","chess",(char *)0);

	if (-1 == exp_expectl(fd1,exp_glob,"Chess\r\n",0,exp_end)) exit;

	if (-1 == write(fd1,"first\r",6)) exit;

	read_first_move(fd1);

	fd2 = exp_spawnl("chess","chess",(char *)0);

	if (-1 == exp_expectl(fd2,exp_glob,"Chess\r\n",0,exp_end)) exit;

	for (;;) {
		send_move(fd2);
		read_counter_move(fd2);

		send_move(fd1);
		read_move(fd1);
	}
}
Пример #2
0
void
read_first_move(int fd)
{
	if (EXP_TIMEOUT == exp_expectl(fd,exp_glob,"first\r\n1.*\r\n",0,exp_end)) {
		timedout();
	}
	sscanf(exp_match,"%*s 1. %s",move);
}
Пример #3
0
void
read_move(int fd)
{
	switch (exp_expectl(fd,exp_glob,"*...*\r\n*.*\r\n",0,exp_end)) {
	case EXP_TIMEOUT: timedout();
	case EXP_EOF: exit(-1);
	}

	sscanf(exp_match,"%*s %*s ... %*s %*s %s",move);
}
Пример #4
0
int
prof_output_regex(char *text)
{
    return (1 == exp_expectl(fd, exp_regexp, text, 1, exp_end));
}
Пример #5
0
int
prof_output_exact(char *text)
{
    return (1 == exp_expectl(fd, exp_exact, text, 1, exp_end));
}