home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / utilities / utilsf / libtiff / c / mkversion < prev    next >
Encoding:
Text File  |  1995-10-15  |  1.1 KB  |  66 lines

  1. /*
  2.  * mkversion.c
  3.  *
  4.  * Syntax: mkversion <infile> [<outfile>]
  5.  */
  6.  
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9.  
  10. int main(int argc, char* argv[])
  11. {
  12.     FILE* infile = NULL;
  13.     FILE* outfile = NULL;
  14.     char ch;
  15.  
  16.     switch (argc)
  17.     {
  18.         case 2:
  19.         {
  20.             infile = fopen(argv[1], "r");
  21.             if (!infile)
  22.             {
  23.                 printf("File %s would not open for input.\n", argv[1]);
  24.                 exit(EXIT_FAILURE);
  25.             }
  26.             outfile = stdout;
  27.             break;
  28.         }
  29.         case 3:
  30.         {
  31.             infile = fopen(argv[1], "r");
  32.             if (!infile)
  33.             {
  34.                 printf("File %s would not open for input.\n", argv[1]);
  35.                 exit(EXIT_FAILURE);
  36.             }
  37.             outfile = fopen(argv[2], "w");
  38.             if (!outfile)
  39.             {
  40.                 printf("File %s would not open for output.\n", argv[2]);
  41.                 exit(EXIT_FAILURE);
  42.             }
  43.             break;
  44.         }
  45.         default:
  46.         {
  47.             printf("Syntax: mkversion <infile> [<outfile>]\n");
  48.             exit(EXIT_FAILURE);
  49.         }
  50.     }
  51.  
  52.     fputs("#define VERSION \"LIBTIFF, Version ", outfile);
  53.     ch = fgetc(infile);
  54.     while (ch >= ' ')
  55.     {
  56.         fputc(ch, outfile);
  57.         ch = fgetc(infile);
  58.     }
  59.     fputs("\\nCopyright (c) 1988-1995 Sam Leffler\\nCopyright (c) 1991-1995 Silicon Graphics, Inc.\"\n", outfile);
  60.  
  61.     fclose(infile);
  62.     if (outfile != stdout) fclose(outfile);
  63.  
  64.     exit(EXIT_SUCCESS);
  65. }
  66.