home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume1 / 8709 / 5 / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-09-11  |  1.1 KB  |  71 lines

  1. /*
  2.  * main -- driver for suntops
  3.  */
  4.  
  5. #include <stdio.h>
  6.  
  7. extern double   atof();
  8. extern char    *optarg;
  9. extern int      optind;
  10.  
  11. #include "suntops.h"
  12.  
  13. main(argc, argv)
  14.     int             argc;
  15.     char          **argv;
  16. {
  17.     FILE           *fpi;
  18.     int             opt;
  19.     double          height;
  20.     int             rotate;
  21.     double          width;
  22.  
  23.     rotate = FALSE;
  24.     height = IMG_HEIGHT;
  25.     width = IMG_WIDTH;
  26.  
  27.     while ((opt = getopt(argc, argv, "h:rw:")) != EOF) {
  28.         switch (opt) {
  29.  
  30.         case 'r':
  31.             rotate = TRUE;
  32.             break;
  33.  
  34.         case 'h':
  35.             height = atof(optarg);
  36.             if (height <= 0.0 || height > PAGE_HEIGHT) {
  37.                 error("-h: bad height");
  38.             }
  39.  
  40.             break;
  41.  
  42.         case 'w':
  43.             width = atof(optarg);
  44.             if (width <= 0.0 || width > PAGE_WIDTH) {
  45.                 error("-w: bad width");
  46.             }
  47.  
  48.             break;
  49.  
  50.         default:
  51.             error(
  52.              "Usage: suntops [-r] [-h height] [-w width] [file]"
  53.                 );
  54.         }
  55.     }
  56.  
  57.     if (argv[optind] == NULL) {
  58.         fpi = stdin;
  59.     }
  60.     else {
  61.         fpi = fopen(argv[optind], "r");
  62.         if (fpi == NULL) {
  63.             error(argv[optind]);
  64.         }
  65.     }
  66.  
  67.     suntops(fpi, PAGE_HEIGHT, PAGE_WIDTH, height, width, rotate, stdout);
  68.  
  69.     exit(0);
  70. }
  71.