1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
$NetBSD: patch-af,v 1.3 2011/10/01 21:42:16 dholland Exp $
Use standard C.
--- demo/playvt.c.orig 1997-11-01 06:49:36.000000000 +0000
+++ demo/playvt.c
@@ -30,7 +30,7 @@
*
*/
-static char *id =
+const char id[] =
"@(#)playvt.c, 1.00, Last Edit-Date: [Sun Jan 1 18:32:22 1995]";
/*---------------------------------------------------------------------------*
@@ -42,22 +42,21 @@ static char *id =
*---------------------------------------------------------------------------*/
#include <stdio.h>
+#include <string.h>
#include <unistd.h>
+#include <stdlib.h>
+#include <err.h>
-main(argc,argv)
-int argc;
-char *argv[];
-{
- extern int optind;
- extern int opterr;
- extern char *optarg;
+void usage(void);
+int
+main(int argc, char *argv[])
+{
int c;
FILE *fp = stdin;
volatile int i;
int delay = 0;
- int fflag = -1;
- char *filename;
+ char *filename = NULL;
while( (c = getopt(argc, argv, "d:f:")) != -1)
{
@@ -69,7 +68,6 @@ char *argv[];
case 'f':
filename = optarg;
- fflag = 1;
break;
case '?':
@@ -79,15 +77,11 @@ char *argv[];
}
}
- if(fflag == 1)
+ if(filename != NULL)
{
if((fp = fopen(filename, "r")) == NULL)
{
- char buffer[80];
- strcpy(buffer,"ERROR opening file ");
- strcat(buffer,filename);
- perror(buffer);
- exit(1);
+ err(1, "ERROR opening file %s", filename);
}
}
@@ -100,7 +94,8 @@ char *argv[];
}
-usage()
+void
+usage(void)
{
fprintf(stderr,"\nplayvt - play a VT animation with programmable delay\n");
fprintf(stderr,"usage: playvt -f [filename] -d [delay]\n");
@@ -108,4 +102,3 @@ usage()
fprintf(stderr," -d <delay> delay between characters\n");
exit(1);
}
-
|