home *** CD-ROM | disk | FTP | other *** search
/ Aminet 33 / Aminet 33 - October 1999.iso / Aminet / dev / c / GAPLib.lha / GAPLib / gaplib / mkver.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-07-04  |  945 b   |  50 lines

  1. #include <stdio.h>
  2. #include <time.h>
  3. #include <string.h>
  4.  
  5. int main(int cnt,char *arg[])
  6. {
  7. long    ver=0,rev=0;
  8. char buf[255];
  9. char buf2[255];
  10. struct tm *timep;
  11. time_t tim;
  12. FILE *f;
  13.  
  14. tim = time(NULL);
  15. timep = gmtime(&tim);
  16.  
  17. if((f=fopen("GAP_Version","rb"))!=NULL) {
  18.     fscanf(f,"%d",&ver);
  19.     fclose(f);
  20. }
  21.  
  22. if((f=fopen("GAP_Revision","rb"))!=NULL) {
  23.     fscanf(f,"%d",&rev);
  24.     fclose(f);
  25. }
  26.  
  27. if(cnt>1) {
  28.  
  29.     if(!strcmp(arg[1],"-h")) {
  30.         strcpy(buf,"mkver c  - Make version string.\nmkver doc  - Make doc version info.\n");
  31.     }
  32.  
  33.     if(!strcmp(arg[1],"c")) {
  34.         strftime(buf2,255,"static const char *__v__ = \"$VER: GAP-Lib %%d.%%d (%d.%m.%y) ©1998-%Y Peter Bengtsson\";\n",timep);
  35.         sprintf(buf,buf2,ver,rev);
  36.     }
  37.  
  38.     if(!strcmp(arg[1],"doc")) {
  39.         strftime(buf2,255,"\tThe current version as of %d-%b-%Y is %%d.%%d\n\t(Version %%d, Revision %%d).\n",timep);
  40.         sprintf(buf,buf2,ver,rev,ver,rev);
  41.     }
  42. } else {
  43.     sprintf(buf,"%d.%d",ver,rev);
  44. }
  45.  
  46. printf(buf);
  47.  
  48. return(0);
  49. }
  50.