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