home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power Programming
/
powerprogramming1994.iso
/
progtool
/
microcrn
/
issue_40.arc
/
DAIMS.ARC
/
GENVERS.CPP
< prev
next >
Wrap
Text File
|
1988-02-10
|
2KB
|
49 lines
#include <stream.h>
#include <time.h>
/*
-*++ main(): generates the version.hxx file for the DAIMS interpreter
**
** (*++ history:
** 7 Dec 87 Bruce Eckel Creation date
** ++*)
**
** (*++ detailed:
** ++*)
*/
main()
{
extern int unlink(char * path);
long clock = time(0);
struct tm *ltm;
ltm = localtime(&clock);
filebuf f1, f2;
if (f1.open("version.hxx",input) == 0) {
cerr << "cannot open version header file: version.hxx";
exit(1);
}
istream oldvers(&f1);
char c;
float version;
while (oldvers >> c, c != '+')
; /* find '+' marker at end of comment*/
while (oldvers >> c, c != 'N')
; /* find uppercase N at end of "VERSION" */
oldvers >> version;
f1.close();
unlink("version.hxx");
if (f2.open("version.hxx", output) == 0){
cerr << "cannot open version header file for output: version.hxx";
exit(1);
}
ostream newvers(&f2);
newvers << "/* Machine-generated header file!! If you change anything */\n";
newvers << "/* except the version number, it will */\n";
newvers << "/* Be over-written the next time genversion is run! + */\n";
newvers << form("#define VERSION %2.1f\n", version);
newvers << "#define VMONTH " << ltm->tm_mon + 1 << "\n";
newvers << "#define VDAY " << ltm->tm_mday << "\n";
newvers << "#define VYEAR " << ltm->tm_year << "\n";
}