home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 534.lha / sregexp.library_v11.1 / utils / bumprev.c next >
C/C++ Source or Header  |  1991-08-08  |  1KB  |  60 lines

  1.  
  2. #include <stdio.h>
  3. #include <string.h>
  4. #include <ctype.h>
  5. #include <stdlib.h>
  6.  
  7. int
  8. main(ac,av)
  9. int ac;
  10. char **av;
  11. {
  12.     FILE *fp;
  13.     int i = 0,r,v,f=0;
  14.     char buff[100],*line[100],*p;
  15.  
  16.     if (ac == 2 && strcmp(av[1],"-v") == 0)
  17.     f = 1;
  18.     if (!(fp = fopen("sreg_version.i","r+"))) {
  19.     puts("Unable to open input.");
  20.     return 30;
  21.     }
  22.  
  23.     while (fgets(buff,100,fp) == buff)
  24.     line[i++] = strdup(buff);
  25.     line[i] = NULL;
  26.  
  27.     fseek(fp,0,SEEK_SET);
  28.     for (i = 0; line[i]; i++) {
  29.     if (strncmp(line[i],"VERSION",7) == 0) {
  30.         p = line[i];
  31.         while (!isdigit(*p)) p++;
  32.         v = atoi(p);
  33.         if (f) {
  34.         v++;
  35.         sprintf(p,"%d\n",v);
  36.         }
  37.     } else
  38.     if (strncmp(line[i],"REVISION",8) == 0) {
  39.         p = line[i];
  40.         while (!isdigit(*p)) p++;
  41.         r = atoi(p)+1;
  42.         if (f)
  43.         r = 0;
  44.         sprintf(p,"%d\n",r);
  45.     }
  46.     fputs(line[i],fp);
  47.     }
  48.     fclose(fp);
  49.     if (!(fp = fopen("sreg_version.c","w"))) {
  50.     puts("Unable to open c file.");
  51.     return 10;
  52.     }
  53.     fprintf(fp,
  54. "\n\nconst __far char idString[] = \"sreglib %d.%d (\"__DATE__\")\\x0d\\x0a\";\n"
  55. ,v,r);
  56.     fclose(fp);
  57.     printf("Up to version %d.%d\n",v,r);
  58.     return 0;
  59. }
  60.