home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / ixemul-45.0-src.tgz / tar.out / contrib / ixemul / ixnet / parse_version.c < prev    next >
C/C++ Source or Header  |  1996-09-28  |  1KB  |  49 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: ixnet.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. #define IXNET_NAME       \"ixnet.library\"
  39. #define IXNET_IDSTRING       \"ixnet %d.%d (%d.%d.%d)\"
  40. #define IXNET_VERSION       %d
  41. #define IXNET_REVISION       %d
  42. #define IXNET_PRIORITY       0
  43.  
  44. #endif
  45. ", major, minor, day, month, year, major, minor);
  46.   fclose(f);
  47.   return 0;
  48. }
  49.