home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / ixemul-45.0-src.tgz / tar.out / contrib / ixemul / library / parse_version.c < prev    next >
C/C++ Source or Header  |  1996-09-28  |  1KB  |  53 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main(int argc, char **argv)
  5. {
  6.   FILE *f;
  7.   int major, minor, day, month, year;
  8.   char pathname[1024];
  9.   
  10.   if (argc != 2)
  11.   {
  12.     fprintf(stderr, "Usage: parse_version <srcdir>\n");
  13.     exit(2);
  14.   }
  15.   strcpy(pathname, argv[1]);
  16.   strcat(pathname, "/../version.in");
  17.   f = fopen(pathname, "r");
  18.   if (f == NULL)
  19.   {
  20.     fprintf(stderr, "Cannot open %s\n", pathname);
  21.     exit(2);
  22.   }
  23.   fscanf(f, "%d.%d,%d.%d.%d", &major, &minor, &day, &month, &year);
  24.   fclose(f);
  25.   f = fopen("version.c", "w");
  26.   fprintf(f, "/*\n * version.c file. Automatically generated by parse_version.\n */\n\n");
  27.   fprintf(f, "static const char version_id[] = \"\\000$VER: ixemul.library %d.%d (%d.%d.%d)\";\n",
  28.              major, minor, day, month, year);
  29.   fclose(f);
  30.   fopen("version.h", "w");
  31.   fprintf(f, "/*
  32.  * version.h file. Automatically generated by parse_version.
  33.  */
  34.  
  35. #ifndef __VERSION_H__
  36. #define __VERSION_H__
  37.  
  38. /* Commodities.h defines IX_VERSION too, so wait for our defines
  39.    to come last, and undef the sucker now! */
  40. #undef IX_VERSION
  41.  
  42. #define IX_NAME        \"ixemul.library\"
  43. #define IX_IDSTRING    \"ixemul %d.%d (%d.%d.%d)\"
  44. #define IX_VERSION    %d
  45. #define IX_REVISION    %d
  46. #define IX_PRIORITY    0
  47.  
  48. #endif
  49. ", major, minor, day, month, year, major, minor);
  50.   fclose(f);
  51.   return 0;
  52. }
  53.