xref: /csrg-svn/old/dbx/mkdate.c (revision 32081)
121612Sdist /*
221612Sdist  * Copyright (c) 1983 Regents of the University of California.
321612Sdist  * All rights reserved.  The Berkeley software License Agreement
421612Sdist  * specifies the terms and conditions for redistribution.
521612Sdist  */
611802Slinton 
721612Sdist #ifndef lint
8*32081Sbostic static char sccsid[] = "@(#)mkdate.c	5.2 (Berkeley) 08/30/87";
921612Sdist #endif not lint
1011802Slinton 
1118225Slinton static char rcsid[] = "$Header: mkdate.c,v 1.5 84/12/26 10:40:30 linton Exp $";
1218225Slinton 
1311802Slinton #include <stdio.h>
1413737Ssam #include <sys/time.h>
1511802Slinton 
1611802Slinton main()
1711802Slinton {
1811802Slinton     struct tm *t;
1911802Slinton     long clock;
2011802Slinton     char name[100];
2111802Slinton     int namelen;
2211802Slinton 
2311802Slinton     printf("char *date = \"");
2411802Slinton     clock = time(0);
2511802Slinton     t = localtime(&clock);
2611802Slinton     printf("%d/%d/%d ", t->tm_mon + 1, t->tm_mday, t->tm_year % 100);
2711802Slinton     printf("%d:%02d", t->tm_hour, t->tm_min);
2811802Slinton     gethostname(name, &namelen);
2911802Slinton     printf(" (%s)", name);
3011802Slinton     printf("\";\n");
3116613Ssam     DoVersionNumber();
32*32081Sbostic     exit(0);
3311802Slinton }
3416613Ssam 
3516613Ssam DoVersionNumber()
3616613Ssam {
3716613Ssam     FILE *f;
3816613Ssam     int n;
3916613Ssam 
4016613Ssam     f = fopen("version", "r");
4116613Ssam     if (f == NULL) {
4216613Ssam 	n = 1;
4316613Ssam     } else {
4416613Ssam 	fscanf(f, "%d", &n);
4516613Ssam 	n = n + 1;
4616613Ssam 	fclose(f);
4716613Ssam     }
4816613Ssam     f = fopen("version", "w");
4916613Ssam     if (f != NULL) {
5016613Ssam 	fprintf(f, "%d\n", n);
5116613Ssam 	fclose(f);
5216613Ssam     }
5316613Ssam     printf("int versionNumber = %d;\n", n);
5416613Ssam }
55