1 /* Copyright (c) 1982 Regents of the University of California */ 2 3 static char sccsid[] = "@(#)mkdate.c 1.4 (Berkeley) 03/01/85"; 4 5 static char rcsid[] = "$Header: mkdate.c,v 1.5 84/12/26 10:40:30 linton Exp $"; 6 7 #include <stdio.h> 8 #include <sys/time.h> 9 10 main() 11 { 12 struct tm *t; 13 long clock; 14 char name[100]; 15 int namelen; 16 17 printf("char *date = \""); 18 clock = time(0); 19 t = localtime(&clock); 20 printf("%d/%d/%d ", t->tm_mon + 1, t->tm_mday, t->tm_year % 100); 21 printf("%d:%02d", t->tm_hour, t->tm_min); 22 gethostname(name, &namelen); 23 printf(" (%s)", name); 24 printf("\";\n"); 25 DoVersionNumber(); 26 } 27 28 DoVersionNumber() 29 { 30 FILE *f; 31 int n; 32 33 f = fopen("version", "r"); 34 if (f == NULL) { 35 n = 1; 36 } else { 37 fscanf(f, "%d", &n); 38 n = n + 1; 39 fclose(f); 40 } 41 f = fopen("version", "w"); 42 if (f != NULL) { 43 fprintf(f, "%d\n", n); 44 fclose(f); 45 } 46 printf("int versionNumber = %d;\n", n); 47 } 48