1 /*-
2 * Copyright (c) 1980 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * %sccs.include.proprietary.c%
6 */
7
8 #ifndef lint
9 char copyright[] =
10 "@(#) Copyright (c) 1980 The Regents of the University of California.\n\
11 All rights reserved.\n";
12 #endif /* not lint */
13
14 #ifndef lint
15 static char sccsid[] = "@(#)mkvers.c 1.2 (Berkeley) 04/12/91";
16 #endif /* not lint */
17
18 char id_mkvers[] = "@(#)mkvers.c 1.2 04/12/91";
19
20 /*
21 * extract sccs id strings from source files
22 * first arg is lib name.
23 * Put them in Version.c
24 */
25
26 #include <stdio.h>
27
28 #define SCCS_ID "@(#)"
29 #define VERSION "Version.c"
30
main(argc,argv)31 main(argc, argv)
32 int argc; char **argv;
33 {
34 char buf[256];
35 char *s, *e;
36 char *index(), *ctime();
37 long t;
38 FILE *V, *fdopen();
39
40 V = stdout; /* fdopen(creat(VERSION, 0644), "w"); */
41 if (!V)
42 {
43 perror("mkvers");
44 exit(1);
45 }
46 if (argc > 1 && argv[1][0] != '.')
47 {
48 fprintf(V, "char *");
49 for (s = argv[1]; *s && *s != '.'; s++)
50 fputc(*s, V);
51 fprintf(V, "_id[] = {\n");
52 }
53 else
54 fprintf(V, "char *sccs_id[] = {\n");
55 if (argc-- > 1)
56 {
57 time(&t);
58 s = ctime(&t) + 4;
59 s[20] = '\0';
60 fprintf(V, "\t\"%s%s\t%s\",\n", SCCS_ID, *++argv, s);
61 }
62 while (--argc)
63 {
64 if (freopen(*++argv, "r", stdin) == NULL)
65 {
66 perror(*argv);
67 continue;
68 }
69 while(gets(buf))
70 {
71 s = buf;
72 while(s = index(s, '@'))
73 if (strncmp(s, SCCS_ID, 4) == 0)
74 break;
75 if (s)
76 {
77 e = index(s, '"');
78 if (e)
79 *e = '\0';
80 fprintf(V, "\t\"%s\",\n", s);
81 break;
82 }
83 }
84 if (feof(stdin))
85 fprintf(stderr, "%s: no sccs id string\n", *argv);
86 }
87 fprintf(V, "};\n");
88 fclose(V);
89 fflush(stdout);
90 fflush(stderr);
91 }
92