home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / XAP / XGAMES / SPIDER.TAR / spider / main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-09-28  |  1.5 KB  |  89 lines

  1. /*
  2.  *    Spider
  3.  *
  4.  *    (c) Copyright 1989, Donald R. Woods and Sun Microsystems, Inc.
  5.  *    (c) Copyright 1990, David Lemke and Network Computing Devices Inc.
  6.  *
  7.  *    See copyright.h for the terms of the copyright.
  8.  *
  9.  *    @(#)main.c    2.1    90/04/25
  10.  *
  11.  */
  12.  
  13. /*
  14.  * Spider solitaire
  15.  */
  16.  
  17. #include    "defs.h"
  18. #include    "globals.h"
  19.  
  20. static char    *display = NULL;
  21. extern char    *getenv();
  22.  
  23. static void
  24. usage(arg)
  25. char    *arg;
  26. {
  27.     if (arg)
  28.         (void) fprintf(stderr,"spider: illegal argument %s\n", arg);
  29.     (void) fprintf(stderr,
  30.     "usage: -display <display> -geometry < geometry> -save <save_file>\n");
  31. }
  32.  
  33. main(argc, argv)
  34. int    argc;
  35. char    **argv;
  36. {
  37. int    i;
  38. char    *save_file = NULL;
  39. char    *geometry = NULL;
  40.  
  41.     /* argument processing */
  42.     /* display, save file */
  43.     for (i = 1; i < argc; i++)    {
  44.         if (strncmp(argv[i], "-d", 2) == 0)    {
  45.             display = argv[++i];
  46.         } else if (strncmp(argv[i], "-g", 2) == 0)    {
  47.             if (argv[i+1])    {
  48.                 geometry = argv[++i];
  49.             } else    {
  50.                 usage(NULL);
  51.                 exit(-1);
  52.             }
  53.         } else if (strncmp(argv[i], "-s", 2) == 0)    {
  54.             if (argv[i+1])    {
  55.                 save_file = argv[++i];
  56.             } else    {
  57.                 usage(NULL);
  58.                 exit(-1);
  59.             }
  60.         } else    {
  61.             usage(argv[i]);
  62.             exit(-1);
  63.         }
  64.     }
  65.  
  66.  
  67.     display_init();
  68.     gfx_init(dpy, screen);
  69.     window_init(argc, argv, geometry);
  70.     card_init();
  71.     if (save_file)
  72.         read_file(save_file);
  73.     event_loop();
  74.     exit(0);
  75. }
  76.  
  77. display_init()
  78. {
  79.     if ((dpy = XOpenDisplay(display)) == NULL)    {
  80.         (void) fprintf(stderr,"Can't open display %s\n", 
  81.             (display ? display : getenv("DISPLAY")));
  82.         exit(-1);
  83.     }
  84.     screen = DefaultScreen(dpy);
  85. #ifdef DEBUG
  86.     XSynchronize(dpy, True);
  87. #endif
  88. }
  89.