Indentation & alignment.
Tabs for indentation, spaces for alignment.
This commit is contained in:
parent
68e58f2a9d
commit
26e7ffbbfc
2 changed files with 10 additions and 9 deletions
|
|
@ -12,6 +12,7 @@ Usage
|
|||
-----
|
||||
|
||||
$ slow [-t usec] [-f]
|
||||
|
||||
|
||||
-t usec : Define sleep between each bytes in micro-second. Default to 1 second.
|
||||
|
||||
-f : Force flushing after each byte. Useful with buffered stdout like ttys.
|
||||
|
|
|
|||
16
slow.c
16
slow.c
|
|
@ -13,10 +13,10 @@ void usage() {
|
|||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
char buffer;
|
||||
size_t nread;
|
||||
useconds_t useconds = 1000000; // default 1 second
|
||||
unsigned int flush = 0;
|
||||
char buffer;
|
||||
size_t nread;
|
||||
useconds_t useconds = 1000000; // default 1 second
|
||||
unsigned int flush = 0;
|
||||
|
||||
ARGBEGIN {
|
||||
case 't':
|
||||
|
|
@ -29,17 +29,17 @@ int main(int argc, char *argv[]) {
|
|||
usage();
|
||||
} ARGEND;
|
||||
|
||||
while((nread = fread(&buffer, 1, sizeof buffer, stdin)) > 0) {
|
||||
while ((nread = fread(&buffer, 1, sizeof buffer, stdin)) > 0) {
|
||||
usleep(useconds);
|
||||
if(fwrite(&buffer, 1, nread, stdout) != nread) {
|
||||
if (fwrite(&buffer, 1, nread, stdout) != nread) {
|
||||
fprintf(stderr, "stdout: write error");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if(flush) {
|
||||
if (flush) {
|
||||
fflush(stdout);
|
||||
}
|
||||
}
|
||||
if(ferror(stdin)) {
|
||||
if (ferror(stdin)) {
|
||||
fprintf(stderr, "stdin: read error");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue