All pastes #1479943 Raw Edit

richard

public text v1 · immutable
#1479943 ·published 2009-06-30 20:18 UTC
rendered paste body
/*Slowdown - (C) Richard Whitty 2009ever yearn for those days when you could actually see the textscrolling across your terminal? Want to be able to rewatch the old VT100animations?Well the wait is over! Emulates any baud speed within reason.*/#include <stdio.h>#include <unistd.h>#include <string.h>int main(int argc,char** argv) {	int baud=2400;	// the baud rate to emulate.	int delay=-1;	// how long to sleep between chars.	int x=-1;		// current character.	if(argv[1]) {	// if there's a parameter passed		if(strncmp("--help",argv[1],6)) {	// we have a default if it's not valid.	// no need to check the return value ;)			sscanf(argv[1],"%d",&baud);		} else {			printf("Usage: %s [--help] [baud]\n"					"--help:\tDisplay this help message\n"					"baud:\t The baud rate to emulate\n",*argv);			return 0;		}		if(baud<1) {			printf("Bad baud rate: %d\n",baud);			return 1;		}	}	delay = 1000000/baud;	while( (x=getchar()) != EOF) {		putchar(x);		fflush(stdout);		if(usleep(delay)==-1) return 1;	}	return 0;}