tamashell: now pause in milliseconds

This commit is contained in:
Philippe Teuwen 2011-04-08 19:50:09 +00:00
parent 9c7c4307d4
commit 9a101943b8
2 changed files with 17 additions and 4 deletions

View file

@ -22,7 +22,7 @@ Shebang is supported, simply start your script with:
.SH COMMANDS
\fIp N\fP to introduce a pause of N seconds.
\fIp N\fP to introduce a pause of N milliseconds.
\fIq\fP or \fICtrl-d\fP to quit.

View file

@ -47,7 +47,20 @@
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <time.h>
#ifndef _WIN32
// Needed by sleep() under Unix
# include <unistd.h>
# define sleep usleep
# define SUSP_TIME 1000 // usecs.
#else
// Needed by Sleep() under Windows
# include <winbase.h>
# define sleep Sleep
# define SUSP_TIME 1 // msecs.
#endif
#include <nfc/nfc.h>
@ -132,9 +145,9 @@ int main(int argc, const char* argv[])
offset++;
}
sscanf(cmd+offset, "%d", &s);
printf("Pause for %i secs\n", s);
printf("Pause for %i msecs\n", s);
if (s>0) {
sleep(s);
sleep(s * SUSP_TIME);
}
free(cmd);
continue;