home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / graphics / gl.pak / MODE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-31  |  1.4 KB  |  60 lines

  1. #ifndef lint
  2. static char sccsid[] = "@(#) mode.c 5.1 89/02/20";
  3. #endif
  4.  
  5. /*
  6.  *    Copyright (c) David T. Lewis 1987, 1988
  7.  *    All rights reserved.
  8.  *
  9.  *    Permission is granted to use this for any personal noncommercial use.
  10.  *    You may not distribute source or executable code for profit, nor
  11.  *    may you distribute it with a commercial product without the written
  12.  *    consent of the author.  Please send modifications to the author for
  13.  *    inclusion in updates to the program.  Thanks.
  14.  */
  15.  
  16. /* dtlewis 7-13-1987 
  17. ** Take command line argument to set graphics mode.  If no argument, then
  18. ** read standard input until end of file.
  19. */
  20.  
  21. #define NORMAL_MODE 2
  22.  
  23. #include <stdio.h>
  24. #include "config.h"
  25.  
  26. main(argc,argv) 
  27. int argc;
  28. char *argv[];
  29. {
  30.     int setmode();
  31.     int modevalue, stat;
  32.     char *inbuf[20];
  33.  
  34.     if (argc > 2) {
  35.         printf("Usage:  mode n\n");
  36.         exit(0);
  37.     }
  38.  
  39.     else if (argc == 2)  {
  40.         if (sscanf(argv[1],"%d",&modevalue) != 1)  {
  41.             printf("Unknown mode %s\n",argv[1]);
  42.             exit(1);
  43.         }
  44.         setmode(modevalue);
  45.     }
  46.     else if (argc == 1)  {
  47. #ifdef DEBUG
  48.         for ( ; ; ) {
  49.             stat=scanf("%d", &modevalue);
  50.             if (stat == EOF) exit(0);
  51.             /* Clear input stream if bad read. */
  52.             if (stat == 0) gets(inbuf, 20, stdin); 
  53.             if (stat == 1 && modevalue >= 0 && modevalue <=11) 
  54.                 setmode(modevalue);
  55.             }
  56. #endif /* DEBUG */
  57.         setmode(NORMAL_MODE);
  58.         }
  59.     }
  60.