home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume7 / image / part01 / ascii2var / main.c++ next >
Encoding:
C/C++ Source or Header  |  1986-11-30  |  1.3 KB  |  62 lines

  1. /*
  2.     This is the main routine for translating 
  3.     ascii to floating point images
  4. */
  5.  
  6. #include <stream.h>
  7. #include <stdio.h>
  8. #include <vartools.h++>
  9.  
  10. int
  11. main(int argc,char *argv[])
  12.     {
  13.     switch ( argc )
  14.     {
  15.     // with 0 arguments it is a pipe
  16.     case 1:
  17.     ascii2var(stdin,stdout);
  18.     break;
  19.     // with 1 arguments it takes from named file to stdout
  20.     case 2:
  21.     {
  22.     FILE *input;    // pointer to the input file
  23.     if ( NULL == ( input = fopen(argv[1],"r") ) )
  24.         {
  25.         perror("ascii2var");
  26.         return 2;
  27.         }
  28.     ascii2var(input,stdout);
  29.     }
  30.     break;
  31.     // with 2 arguments it takes from named file to named file
  32.     case 3:
  33.     {
  34.     FILE *input;    // pointer to the input file
  35.     FILE *output;    // pointer to the output file
  36.     if ( NULL == ( input = fopen(argv[1],"r") ) )
  37.         {
  38.         perror("ascii2var");
  39.         return 2;
  40.         }
  41.     if ( NULL == ( output = fopen(argv[2],"w") ) )
  42.         {
  43.         perror("ascii2var");
  44.         return 2;
  45.         }
  46.     ascii2var(input,output);
  47.     }
  48.     break;
  49.     // otherwise something is wrong
  50.     default:
  51.     cerr << "Syntax is: ascii2var [input [output]]\n";
  52.     return 1;
  53.     }
  54.     return 0;
  55.     }
  56. /*
  57. Copyright (C) 1986, David Sher in the University of Rochester
  58. Permission is granted to any individual or institution to use, copy, or
  59. redistribute this software so long as it is not sold for profit, provided
  60. this copyright notice is retained.
  61. */
  62.