コード例 #1
0
ファイル: chesslib++.c プロジェクト: aosm/gcc3
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
ファイル: chesslib++.c プロジェクト: aosm/gcc3
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
ファイル: chesslib++.c プロジェクト: aosm/gcc3
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
ファイル: proftest.c プロジェクト: 0xPoly/profanity
int
prof_output_regex(char *text)
{
    return (1 == exp_expectl(fd, exp_regexp, text, 1, exp_end));
}
コード例 #5
0
ファイル: proftest.c プロジェクト: 0xPoly/profanity
int
prof_output_exact(char *text)
{
    return (1 == exp_expectl(fd, exp_exact, text, 1, exp_end));
}