Example #1
0
/*
 * getchar with timeout.
 */
int
tgetchar(void)
{
	static struct timeval timeleft;
	char c;

	/*
	 * Reset timeleft to fallrate whenever it is not positive.
	 * In any case, wait to see if there is any input.  If so,
	 * take it, and update timeleft so that the next call to
	 * tgetchar() will not wait as long.  If there is no input,
	 * make timeleft zero or negative, and return -1.
	 *
	 * Most of the hard work is done by rwait().
	 */
	if (!TV_POS(&timeleft)) {
		faster();	/* go faster */
		timeleft.tv_sec = 0;
		timeleft.tv_usec = fallrate;
	}
	if (!rwait(&timeleft))
		return (-1);
	if (read(0, &c, 1) != 1)
		stop("end of file, help");
	return ((int)(unsigned char)c);
}
Example #2
0
/*
 * Eat up any input (used at end of game).
 */
void
eat_input(void)
{
	struct timeval tv;
	char c;

	do {
		tv.tv_sec = tv.tv_usec = 0;
	} while (rwait(&tv) && read(0, &c, 1) == 1);
}
Example #3
0
/*
 * `sleep' for the current turn time (using select).
 * Eat any input that might be available.
 */
void
tsleep(void)
{
	struct timeval tv;
	char c;

	tv.tv_sec = 0;
	tv.tv_usec = fallrate;
	while (TV_POS(&tv))
		if (rwait(&tv) && read(0, &c, 1) != 1)
			break;
}
Example #4
0
int main(){
	
	init();
	int u1,u2;
	int s;
	
	u1=rexecute(M1,"ls");
	sleep(1);
	
	u1=rexecute(M2,"../test/test2");
	sleep(1);
	
	u1=rexecute(M2,"../test/test");
	sleep(1);


	/*
	affichage();
	sleep(5);
	/*
	if (!rkill(u1,SIGUSR1)) {printf("Erreur\n");}
	
	sleep(1);
	*/
	/*
	u2=rexecute(M1,"./test/test");
	//u2=rexecute("127.0.0.1","ls");
	printf("MAIN : UID recu %d\n",u2);

	*/
	rwait(&s);
	
	rwait(&s);
	
	rwait(&s);
	
	printf("MAIN : FIN DE PROG\n");
	
	return EXIT_SUCCESS;
}
Example #5
0
do_batch(void)
{
int hd,sec,hd2;
char line[80],*l;
long timer;

    if (fsel("*.TTB",tbuf,"Batch starten") == 1){
        if ((hd=Fopen(tbuf,0)) > 0) {
            while (readline(hd,line)){
                l=line;
                while (*l++ > 32);
                *(l-1)=0;
                strupr(line);
                if (!strcmp(line,"DIAL")) {
                    if (call_modem(-1,l)) break;
                    else continue;
                }
                if (!strcmp(line,"WAIT")) {
                    sec=atoi(l);
                    timer=get_timer();
                    while ((get_timer()-timer) < (sec*200))
                        evnt_timer(0,0);
                    continue;
                }
                if (!strcmp(line,"RWAIT")) {
                    if (rwait(l) == 0) continue;
                    else break;
                }
                if (!strcmp(line,"SEND")) {
                    while(*l) send(*l++);
                    send(13);
                    continue;
                }
                if (!strcmp(line,"END")) {
                    break;
                }
                if (!strcmp(line,"BAUDRATE")) {
                    continue;
                }
                if (!strcmp(line,"UPLOAD")) {
                    if (*l == 'X') {
                        para.blklen=128;
                        para.chk=CHKSUM;
                    }
                    if (*l == 'Y') {
                        para.blklen=1024;
                        para.chk=CRC;
                    }
                    while (*l++ > 32);
                    *(l-1)=0;
                    open_dial(1);
                    if ((hd2=Fopen(l,0)) > 0) {
                        send_xmodem(hd2);
                        Fclose(hd2);
                    }
                    open_dial(0);
                }   
                if (!strcmp(line,"DOWNLOAD")) {
                    if (*l == 'X') {
                        para.blklen=128;
                        para.chk=CHKSUM;
                    }
                    if (*l == 'Y') {
                        para.blklen=1024;
                        para.chk=CRC;
                    }
                    while (*l++ > 32);
                    *(l-1)=0;
                    open_dial(1);
                    if ((hd2=Fcreate(l,0)) > 0) {
                        receive_xmodem(hd2);
                        Fclose(hd2);
                    }
                    open_dial(0);
                }   
            }
            Fclose(hd);
        }
    }
}