home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / dev / gcc / ixemulsrc.lha / ixemul / ixnet / parse_version.c < prev    next >
C/C++ Source or Header  |  1996-12-11  |  1KB  |  66 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 tmp[1024];
  9.   char *format;
  10.   int item = 0;
  11.  
  12.   if (argc != 2)
  13.   {
  14.     fprintf(stderr, "Usage: parse_version <srcdir>\n");
  15.     exit(2);
  16.   }
  17.   strcpy(tmp, argv[1]);
  18.   strcat(tmp, "/../version.in");
  19.   f = fopen(tmp, "r");
  20.   if (f == NULL)
  21.   {
  22.     fprintf(stderr, "Cannot open %s\n", tmp);
  23.     exit(2);
  24.   }
  25.   fscanf(f, "%d.%d,%d.%d.%d", &major, &minor, &day, &month, &year);
  26.   fclose(f);
  27.   format = "/*
  28.  * version.h file. Automatically generated by parse_version.
  29.  */
  30.  
  31. #ifndef __VERSION_H__
  32. #define __VERSION_H__
  33.  
  34. #define IXNET_NAME       \"ixnet.library\"
  35. #define IXNET_IDSTRING       \"ixnet %d.%d %s(%d.%d.%d)\"
  36. #define IXNET_VERSION       %d
  37. #define IXNET_REVISION       %d
  38. #define IXNET_PRIORITY       0
  39.  
  40. #endif
  41. ";
  42.   strcpy(tmp, "[");
  43.  
  44. #ifdef NOTRAP
  45.   if (item)
  46.     strcat(tmp, ", ");
  47.   strcat(tmp, "notrap");
  48.   item++;
  49. #endif
  50.  
  51. #ifdef DEBUG_VERSION
  52.   if (item)
  53.     strcat(tmp, ", ");
  54.   strcat(tmp, "debug");
  55.   item++;
  56. #endif
  57.  
  58.   if (item)
  59.     strcat(tmp, "] ");
  60.   else
  61.     tmp[0] = '\0';
  62.  
  63.   printf(format, major, minor, tmp, day, month, year, major, minor);
  64.   return 0;
  65. }
  66.