home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Games / NetHack 3.1.3 / source / src / windows.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-01  |  2.1 KB  |  88 lines  |  [TEXT/R*ch]

  1. /*    SCCS Id: @(#)windows.c    3.1    93/07/13    */
  2. /* Copyright (c) D. Cohrs, 1993. */
  3. /* NetHack may be freely redistributed.  See license for details. */
  4.  
  5. #include "hack.h"
  6. #ifdef TTY_GRAPHICS
  7. #include "wintty.h"
  8. #endif
  9. #ifdef X11_GRAPHICS
  10. /* cannot just blindly include winX.h without including all of X11 stuff */
  11. /* and must get the order of include files right.  Don't bother */
  12. extern struct window_procs X11_procs;
  13. extern void NDECL(win_X11_init);
  14. #endif
  15. #ifdef MAC
  16. extern struct window_procs mac_procs;
  17. #endif
  18. #ifdef AMIGA_INTUITION
  19. extern struct window_procs amii_procs;
  20. extern struct window_procs amiv_procs;
  21. extern void NDECL(amii_loadlib);
  22. extern void NDECL(amiv_loadlib);
  23. #endif
  24.  
  25. static void FDECL(def_raw_print, (const char *s));
  26.  
  27. NEARDATA struct window_procs windowprocs;
  28.  
  29. static
  30. struct win_choices {
  31.     struct window_procs *procs;
  32.     void NDECL((*ini_routine));        /* optional (can be 0) */
  33. } winchoices[] = {
  34. #ifdef TTY_GRAPHICS
  35.     { &tty_procs, win_tty_init },
  36. #endif
  37. #ifdef X11_GRAPHICS
  38.     { &X11_procs, win_X11_init },
  39. #endif
  40. #ifdef MAC
  41.     { &mac_procs, 0 },
  42. #endif
  43. #ifdef AMIGA_INTUITION
  44.     /* A shared library is used for implementing the access to these two
  45.      * different display mechanisms.  This means that the function names
  46.      * are actually the same (assembler stubs) and the libraries do
  47.      * different things.
  48.      */
  49.     { &amii_procs, amii_loadlib },
  50.     { &amiv_procs, amiv_loadlib },
  51. #endif
  52.     { 0, 0 }        /* must be last */
  53. };
  54.  
  55. static
  56. void
  57. def_raw_print(s)
  58. const char *s;
  59. {
  60.     puts(s);
  61. }
  62.  
  63. void
  64. choose_windows(s)
  65. const char *s;
  66. {
  67.     register int i;
  68.  
  69.     for(i=0; winchoices[i].procs; i++)
  70.     if (!strcmpi(s, winchoices[i].procs->name)) {
  71.         windowprocs = *winchoices[i].procs;
  72.         if (winchoices[i].ini_routine) (*winchoices[i].ini_routine)();
  73.         return;
  74.     }
  75.  
  76.     if (!windowprocs.win_raw_print)
  77.     windowprocs.win_raw_print = def_raw_print;
  78.  
  79.     raw_printf("Window type %s not recognized.  Choices are:", s);
  80.     for(i=0; winchoices[i].procs; i++)
  81.     raw_printf("        %s", winchoices[i].procs->name);
  82.  
  83.     if (windowprocs.win_raw_print == def_raw_print)
  84.     terminate(0);
  85. }
  86.  
  87. /*windows.c*/
  88.