home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / microcrn / issue_40.arc / DAIMS.ARC / GENVERS.CPP < prev    next >
Text File  |  1988-02-10  |  2KB  |  49 lines

  1. #include <stream.h>
  2. #include <time.h>
  3. /* 
  4. -*++ main(): generates the version.hxx file for the DAIMS interpreter
  5. ** 
  6. ** (*++ history: 
  7. **      7 Dec 87    Bruce Eckel    Creation date
  8. ** ++*)
  9. ** 
  10. ** (*++ detailed: 
  11. ** ++*)
  12. */
  13.  
  14. main()
  15. {
  16.     extern int unlink(char * path);
  17.     long clock = time(0);
  18.     struct  tm *ltm;
  19.     ltm = localtime(&clock);
  20.     filebuf f1, f2;
  21.     if (f1.open("version.hxx",input) == 0) {
  22.     cerr << "cannot open version header file: version.hxx";
  23.     exit(1);
  24.     }
  25.     istream oldvers(&f1);
  26.     char c;
  27.     float version;
  28.     while (oldvers >> c, c != '+')
  29.     ;            /* find '+' marker at end of comment*/
  30.     while (oldvers >> c, c != 'N')
  31.     ;            /* find uppercase N at end of "VERSION" */
  32.     oldvers >> version;
  33.     f1.close();
  34.  
  35.     unlink("version.hxx");
  36.     if (f2.open("version.hxx", output) == 0){
  37.     cerr << "cannot open version header file for output: version.hxx";
  38.     exit(1);
  39.     }
  40.     ostream newvers(&f2);
  41.     newvers << "/* Machine-generated header file!!  If you change anything */\n";
  42.     newvers << "/* except the version number, it will */\n";
  43.     newvers << "/* Be over-written the next time genversion is run! + */\n";
  44.     newvers << form("#define VERSION %2.1f\n", version);
  45.     newvers << "#define VMONTH " << ltm->tm_mon + 1 << "\n";
  46.     newvers << "#define VDAY " << ltm->tm_mday << "\n";
  47.     newvers << "#define VYEAR " << ltm->tm_year << "\n";
  48. }
  49.