now you can specifiy the slowdown
This commit is contained in:
parent
70545d9355
commit
b1ebd390b4
@ -1,14 +1,35 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int c;
|
int c, sec, nano;
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
|
int slowdown = 300; /* set a default value */
|
||||||
|
float delay;
|
||||||
|
/*
|
||||||
|
* get the desired slowdown from command-line
|
||||||
|
*/
|
||||||
|
if (2 == argc) {
|
||||||
|
if (1 != sscanf(argv[1], "%d", &slowdown)) {
|
||||||
|
fprintf(stderr, "%s: bad arg, sorry\n", argv[0]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
if (slowdown < 1) {
|
||||||
|
fprintf(stderr, "%d is invalid\n", slowdown);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ts.tv_sec = 0;
|
/* convert the slowdown value to delay */
|
||||||
ts.tv_nsec = 115 * 1000 * 1000;
|
delay = 1.0 / (float)slowdown;
|
||||||
|
sec = (int)delay;
|
||||||
|
nano = (int)(1000*1000*1000*(delay - (int)delay));
|
||||||
|
|
||||||
|
ts.tv_sec = sec;
|
||||||
|
ts.tv_nsec = nano;
|
||||||
while ( EOF != (c=getchar()) )
|
while ( EOF != (c=getchar()) )
|
||||||
{
|
{
|
||||||
putchar(c);
|
putchar(c);
|
||||||
|
Loading…
Reference in New Issue
Block a user