| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: script.c,v 1.19 2009/10/17 22:36:23 christos Exp $ */ | | 1 | /* $NetBSD: script.c,v 1.20 2011/06/08 13:51:13 yamt Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1980, 1992, 1993 | | 4 | * Copyright (c) 1980, 1992, 1993 |
5 | * The Regents of the University of California. All rights reserved. | | 5 | * The Regents of the University of California. All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -29,27 +29,27 @@ | | | @@ -29,27 +29,27 @@ |
29 | * SUCH DAMAGE. | | 29 | * SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | #include <sys/cdefs.h> | | 32 | #include <sys/cdefs.h> |
33 | #ifndef lint | | 33 | #ifndef lint |
34 | __COPYRIGHT("@(#) Copyright (c) 1980, 1992, 1993\ | | 34 | __COPYRIGHT("@(#) Copyright (c) 1980, 1992, 1993\ |
35 | The Regents of the University of California. All rights reserved."); | | 35 | The Regents of the University of California. All rights reserved."); |
36 | #endif /* not lint */ | | 36 | #endif /* not lint */ |
37 | | | 37 | |
38 | #ifndef lint | | 38 | #ifndef lint |
39 | #if 0 | | 39 | #if 0 |
40 | static char sccsid[] = "@(#)script.c 8.1 (Berkeley) 6/6/93"; | | 40 | static char sccsid[] = "@(#)script.c 8.1 (Berkeley) 6/6/93"; |
41 | #endif | | 41 | #endif |
42 | __RCSID("$NetBSD: script.c,v 1.19 2009/10/17 22:36:23 christos Exp $"); | | 42 | __RCSID("$NetBSD: script.c,v 1.20 2011/06/08 13:51:13 yamt Exp $"); |
43 | #endif /* not lint */ | | 43 | #endif /* not lint */ |
44 | | | 44 | |
45 | #include <sys/types.h> | | 45 | #include <sys/types.h> |
46 | #include <sys/wait.h> | | 46 | #include <sys/wait.h> |
47 | #include <sys/stat.h> | | 47 | #include <sys/stat.h> |
48 | #include <sys/ioctl.h> | | 48 | #include <sys/ioctl.h> |
49 | #include <sys/time.h> | | 49 | #include <sys/time.h> |
50 | #include <sys/param.h> | | 50 | #include <sys/param.h> |
51 | #include <sys/uio.h> | | 51 | #include <sys/uio.h> |
52 | | | 52 | |
53 | #include <err.h> | | 53 | #include <err.h> |
54 | #include <errno.h> | | 54 | #include <errno.h> |
55 | #include <fcntl.h> | | 55 | #include <fcntl.h> |
| @@ -375,27 +375,27 @@ playback(FILE *fp) | | | @@ -375,27 +375,27 @@ playback(FILE *fp) |
375 | | | 375 | |
376 | for (nread = 0; !reg || nread < pst.st_size; nread += save_len) { | | 376 | for (nread = 0; !reg || nread < pst.st_size; nread += save_len) { |
377 | if (fread(&stamp, sizeof(stamp), 1, fp) != 1) { | | 377 | if (fread(&stamp, sizeof(stamp), 1, fp) != 1) { |
378 | if (reg) | | 378 | if (reg) |
379 | err(1, "reading playback header"); | | 379 | err(1, "reading playback header"); |
380 | else | | 380 | else |
381 | break; | | 381 | break; |
382 | } | | 382 | } |
383 | swapstamp(stamp); | | 383 | swapstamp(stamp); |
384 | save_len = sizeof(stamp); | | 384 | save_len = sizeof(stamp); |
385 | | | 385 | |
386 | if (reg && stamp.scr_len > | | 386 | if (reg && stamp.scr_len > |
387 | (uint64_t)(pst.st_size - save_len) - nread) | | 387 | (uint64_t)(pst.st_size - save_len) - nread) |
388 | err(1, "invalid stamp"); | | 388 | errx(1, "invalid stamp"); |
389 | | | 389 | |
390 | save_len += stamp.scr_len; | | 390 | save_len += stamp.scr_len; |
391 | tclock = stamp.scr_sec; | | 391 | tclock = stamp.scr_sec; |
392 | tso.tv_sec = stamp.scr_sec; | | 392 | tso.tv_sec = stamp.scr_sec; |
393 | tso.tv_nsec = stamp.scr_usec * 1000; | | 393 | tso.tv_nsec = stamp.scr_usec * 1000; |
394 | | | 394 | |
395 | switch (stamp.scr_direction) { | | 395 | switch (stamp.scr_direction) { |
396 | case 's': | | 396 | case 's': |
397 | if (!quiet) | | 397 | if (!quiet) |
398 | (void)printf("Script started on %s", | | 398 | (void)printf("Script started on %s", |
399 | ctime(&tclock)); | | 399 | ctime(&tclock)); |
400 | tsi = tso; | | 400 | tsi = tso; |
401 | (void)consume(fp, stamp.scr_len, buf, reg); | | 401 | (void)consume(fp, stamp.scr_len, buf, reg); |
| @@ -420,19 +420,19 @@ playback(FILE *fp) | | | @@ -420,19 +420,19 @@ playback(FILE *fp) |
420 | if (usesleep) | | 420 | if (usesleep) |
421 | (void)nanosleep(&tsi, NULL); | | 421 | (void)nanosleep(&tsi, NULL); |
422 | tsi = tso; | | 422 | tsi = tso; |
423 | while (stamp.scr_len > 0) { | | 423 | while (stamp.scr_len > 0) { |
424 | l = MIN(DEF_BUF, stamp.scr_len); | | 424 | l = MIN(DEF_BUF, stamp.scr_len); |
425 | if (fread(buf, sizeof(char), l, fp) != l) | | 425 | if (fread(buf, sizeof(char), l, fp) != l) |
426 | err(1, "cannot read buffer"); | | 426 | err(1, "cannot read buffer"); |
427 | | | 427 | |
428 | (void)write(STDOUT_FILENO, buf, l); | | 428 | (void)write(STDOUT_FILENO, buf, l); |
429 | stamp.scr_len -= l; | | 429 | stamp.scr_len -= l; |
430 | } | | 430 | } |
431 | break; | | 431 | break; |
432 | default: | | 432 | default: |
433 | err(1, "invalid direction"); | | 433 | errx(1, "invalid direction"); |
434 | } | | 434 | } |
435 | } | | 435 | } |
436 | (void)fclose(fp); | | 436 | (void)fclose(fp); |
437 | exit(0); | | 437 | exit(0); |
438 | } | | 438 | } |