home *** CD-ROM | disk | FTP | other *** search
/ vsiftp.vmssoftware.com / VSIPUBLIC@vsiftp.vmssoftware.com.tar / FREEWARE / FREEWARE40.ZIP / xtron-1_1a / resource.c < prev    next >
C/C++ Source or Header  |  1998-01-01  |  4KB  |  133 lines

  1. /* resource.c - xtron v1.1 resource handler
  2.  *
  3.  *   Copyright (C) 1995 Rhett D. Jacobs <rhett@hotel.canberra.edu.au>
  4.  *
  5.  *  This program is free software; you can redistribute it and/or modify
  6.  *  it under the terms of the GNU General Public License as published by
  7.  *  the Free Software Foundation; either version 1, or (at your option)
  8.  *  any later version.
  9.  *
  10.  *  This program is distributed in the hope that it will be useful,
  11.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  *  GNU General Public License for more details.
  14.  *
  15.  *  You should have received a copy of the GNU General Public License
  16.  *  along with this program; if not, write to the Free Software
  17.  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  *
  19.  *  Last Modified: 16/4/95
  20.  */
  21.  
  22. #include "resource.h"
  23.  
  24. XrmDatabase XTRONresources;
  25.  
  26. char *PixmapsDIR(char *name1)
  27. {
  28.   char *string_type[20];
  29.   XrmValue DBvalue;
  30.  
  31.   XrmGetResource(XTRONresources,"xtron.PixmapsDIR", "Xtron.PixmapsDIR", 
  32.          string_type, &DBvalue);
  33.   strncpy(name1, DBvalue.addr, (int) DBvalue.size);
  34.   return(name1);
  35. }
  36.  
  37.  
  38. char StdGet(char *name1, char *name2)
  39. {
  40.   char *string_type[20];
  41.   XrmValue DBvalue;
  42.   char resource[255];
  43.   
  44.   XrmGetResource(XTRONresources, name1, name2, 
  45.          string_type, &DBvalue);
  46.   strncpy(resource, DBvalue.addr, (int) DBvalue.size);
  47.   return(resource[0]);
  48. }
  49.  
  50.  
  51. char KeyRESOURCE(int plrnum, int keynum)
  52. {
  53.   switch (plrnum) {
  54.   case 1:
  55.     switch (keynum) {
  56.     case 0:
  57.       return(StdGet("xtron.player1UP", "Xtron.player1UP")); break;
  58.     case 1:
  59.       return(StdGet("xtron.player1DOWN", "Xtron.player1DOWN")); break;
  60.     case 2:
  61.       return(StdGet("xtron.player1LEFT", "Xtron.player1LEFT")); break;
  62.     case 3:
  63.       return(StdGet("xtron.player1RIGHT", "Xtron.player1RIGHT")); break;
  64.     }
  65.       break;
  66.   case 2:
  67.     switch (keynum) {
  68.     case 0:
  69.       return(StdGet("xtron.player2UP", "Xtron.player2UP")); break;
  70.     case 1:
  71.       return(StdGet("xtron.player2DOWN", "Xtron.player2DOWN")); break;
  72.     case 2:
  73.       return(StdGet("xtron.player2LEFT", "Xtron.player2LEFT")); break;
  74.     case 3:
  75.       return(StdGet("xtron.player2RIGHT", "Xtron.player2RIGHT")); break;
  76.     }
  77.       break;
  78.   }
  79.   return(' ');
  80. }
  81.  
  82.  
  83. int LookAhead(void)
  84. {
  85.   char *string_type[20];
  86.   XrmValue DBvalue;
  87.   char resource[255];
  88.   
  89.   XrmGetResource(XTRONresources, "xtron.lookAHEAD", "Xtron.lookAHEAD", 
  90.          string_type, &DBvalue);
  91.   strncpy(resource, DBvalue.addr, (int) DBvalue.size);
  92.   return(atoi(resource));
  93. }
  94.  
  95.  
  96. int InitialiseResource(void)
  97. {
  98.   XrmInitialize();
  99.   
  100. #ifndef VMS
  101.    if ((XTRONresources = XrmGetFileDatabase("./xtronrc")) == NULL)  {
  102.       if ((XTRONresources = XrmGetFileDatabase("./.xtronrc")) == NULL)  {
  103.      if ((XTRONresources = XrmGetFileDatabase("$HOME/xtronrc")) == NULL)  {
  104.         if ((XTRONresources = XrmGetFileDatabase("$HOME/.xtronrc")) == NULL)  {
  105.            if ((XTRONresources = XrmGetFileDatabase("/usr/X11/lib/X11/app-defaults/xtronrc")) == NULL)  {
  106.           if ((XTRONresources = XrmGetFileDatabase("/usr/X11/lib/X11/app-defaults/.xtronrc")) == NULL)  {
  107.              fprintf(stderr,"error: unable to open/read resource file xtronrc\n");
  108.              return(0);
  109.           }
  110.            }
  111.         }
  112.      }
  113.       }
  114.    }
  115. #else
  116.    if ((XTRONresources = XrmGetFileDatabase(".xtronrc")) == NULL)  {
  117.       if ((XTRONresources = XrmGetFileDatabase("xtronrc.")) == NULL)  {
  118.      if ((XTRONresources = XrmGetFileDatabase("SYS$LOGIN:xtronrc.")) == NULL)  {
  119.         if ((XTRONresources = XrmGetFileDatabase("SYS$LOGIN:.xtronrc")) == NULL)  {
  120.            if ((XTRONresources = XrmGetFileDatabase("sys$common:[decw$defaukts.user]xtronrc.")) == NULL)  {
  121.           if ((XTRONresources = XrmGetFileDatabase("sys$common:[decw$defaults.user].xtronrc")) == NULL)  {
  122.              fprintf(stderr,"error: unable to open/read resource file xtronrc\n");
  123.              return(0);
  124.           }
  125.            }
  126.         }
  127.      }
  128.       }
  129.    }
  130. #endif
  131.    return(1);
  132. }
  133.