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