home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 7 Games / 07-Games.zip / 32PMCHES.ZIP / OPTIONS.C < prev    next >
Text File  |  1990-12-17  |  3KB  |  91 lines

  1. //
  2. //  Copyright (C) 1986, 1987, 1988, 1989, 1990 Free Software Foundation, Inc.
  3. //  Copyright (c) 1988, 1989, 1990  John Stanback
  4. //
  5. //  Project:    OS/2 PM Port of GNU CHESS 3.1 (PmChess)
  6. //
  7. //  Version:    1.02  1990-12-17
  8. //
  9. //   Module:    Options save and restore logic.
  10. //
  11. //   Author:    Benny N. Ormson
  12. //
  13. //   System:    OS2 1.2 using Microsoft C 6.0
  14. //
  15. //  Remarks:    This code was added in version 1.02 after the PM port.
  16. //
  17. //  License:
  18. //
  19. //    CHESS is distributed in the hope that it will be useful, but WITHOUT ANY
  20. //    WARRANTY.  No author or distributor accepts responsibility to anyone for
  21. //    the consequences of using it or for whether it serves any particular
  22. //    purpose or works at all, unless he says so in writing.  Refer to the
  23. //    CHESS General Public License for full details.
  24. //
  25. //    Everyone is granted permission to copy, modify and redistribute CHESS,
  26. //    but only under the conditions described in the CHESS General Public
  27. //    License.  A copy of this license is supposed to have been given to you
  28. //    along with CHESS so you can know your rights and responsibilities.  It
  29. //    should be in a file named COPYING.  Among other things, the copyright
  30. //    notice and this notice must be preserved on all copies.
  31. //
  32.  
  33. #define  INCL_WINPROGRAMLIST
  34. #define  INCL_WINSHELLDATA
  35. #include <os2.h>
  36. #include "pmchess.h"
  37. #include "GnuChess.h"
  38.  
  39. extern short coords;
  40. extern struct flags flag;
  41.  
  42. static char inifile[] = "pmchess.ini";
  43. static char appname[] = "PmChess";
  44. static char keytone[] = "Tone";
  45. static char keycord[] = "Cord";
  46.  
  47. /**********************************************************************/
  48. /* GetOptions() - Read option settings from ini file.                 */
  49. /**********************************************************************/
  50. void GetOptions(void)
  51. {
  52.    HINI  hini;
  53.    long  ll = sizeof(int);
  54.  
  55.    flag.beep = 1;                       /* default tone on           */
  56.    coords = 1;                          /* default coords on         */
  57.  
  58.    hini = PrfOpenProfile(hab,inifile);
  59.    if(hini == NULL)
  60.       return;
  61.  
  62.    ll = sizeof(flag.beep);
  63.    PrfQueryProfileData(hini,appname,keytone,&flag.beep,&ll);
  64.    ll = sizeof(coords);
  65.    PrfQueryProfileData(hini,appname,keycord,&coords,&ll);
  66.  
  67.    PrfCloseProfile(hini);
  68.    return;
  69. }
  70.  
  71. /**********************************************************************/
  72. /* SaveOptions() - Write option settings to ini file.                 */
  73. /**********************************************************************/
  74. void SaveOptions(void)
  75. {
  76.    HINI  hini;
  77.    long  ll = sizeof(int);
  78.  
  79.    hini = PrfOpenProfile(hab,inifile);
  80.    if(hini == NULL)
  81.       return;
  82.  
  83.    PrfWriteProfileData(hini,appname,keytone,&flag.beep,sizeof(flag.beep));
  84.    PrfWriteProfileData(hini,appname,keycord,&coords,sizeof(coords));
  85.  
  86.    PrfCloseProfile(hini);
  87.    return;
  88. }
  89.  
  90.  
  91.