home *** CD-ROM | disk | FTP | other *** search
/ Launch & Play / spustahrej2.iso / Egoboo / code / configfile.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-12-03  |  2.3 KB  |  79 lines

  1.  
  2. //---------------------------------------------------------------------
  3. //
  4. //    ConfigFile.h
  5. //
  6. //
  7. //---------------------------------------------------------------------
  8.  
  9.  
  10. #ifndef _CONFIGFILE_H_
  11. #define _CONFIGFILE_H_
  12.  
  13. #include "egobootypedef.h"
  14.  
  15. #include <stdio.h>
  16. #include <stdlib.h>
  17.  
  18. #include "egoboostrutil.h"
  19.  
  20. #define MAX_CONFIG_SECTION_LENGTH        64
  21. #define MAX_CONFIG_KEY_LENGTH            64
  22. #define MAX_CONFIG_VALUE_LENGTH            256
  23. #define MAX_CONFIG_COMMENTARY_LENGTH    256
  24.  
  25. typedef struct ConfigFileValue ConfigFileValue;
  26. typedef struct ConfigFileValue
  27.     {
  28.     char KeyName[MAX_CONFIG_KEY_LENGTH];
  29.     char *Value;
  30.     char *Commentary;
  31.     ConfigFileValue *NextValue;
  32.     } *ConfigFileValuePtr;
  33.  
  34. typedef struct ConfigFileSection ConfigFileSection;
  35. typedef struct ConfigFileSection
  36.     {
  37.     char SectionName[MAX_CONFIG_SECTION_LENGTH];
  38.     ConfigFileSection    *NextSection;
  39.     ConfigFileValuePtr    FirstValue;
  40.     } *ConfigFileSectionPtr;
  41.  
  42. typedef struct ConfigFile
  43.     {
  44.     FILE    *f;
  45.     ConfigFileSectionPtr    ConfigSectionList;
  46.  
  47.     ConfigFileSectionPtr    CurrentSection;
  48.     ConfigFileValuePtr        CurrentValue;
  49.     } ConfigFile, *ConfigFilePtr;
  50.  
  51.  
  52. // util
  53. extern void ConvertToKeyCharacters( char *pStr );
  54.  
  55. //
  56. extern ConfigFilePtr OpenConfigFile( const char *pPath );
  57.  
  58. //
  59. extern Sint32 GetConfigValue( ConfigFilePtr pConfigFile, const char *pSection, const char *pKey, char *pValue, Sint32 pValueBufferLength );
  60. extern Sint32 GetConfigBooleanValue( ConfigFilePtr pConfigFile, const char *pSection, const char *pKey, BOOL *pBool );
  61. extern Sint32 GetConfigIntValue( ConfigFilePtr pConfigFile, const char *pSection, const char *pKey, Sint32 *pInt );
  62.  
  63. // 
  64. extern Sint32 SetConfigValue( ConfigFilePtr pConfigFile, const char *pSection, const char *pKey, const char *pValue );
  65. extern Sint32 SetConfigBooleanValue( ConfigFilePtr pConfigFile, const char *pSection, const char *pKey, int pBool);
  66. extern Sint32 SetConfigIntValue( ConfigFilePtr pConfigFile, const char *pSection, const char *pKey, int pInt);
  67. extern Sint32 SetConfigFloatValue( ConfigFilePtr pConfigFile, const char *pSection, const char *pKey, float pFloat);
  68.  
  69. //
  70. extern void CloseConfigFile( ConfigFilePtr pConfigFile );
  71.  
  72. //
  73. extern void SaveConfigFile( ConfigFilePtr pConfigFile );
  74. extern Sint32 SaveConfigFileAs( ConfigFilePtr pConfigFile, const char *pPath );
  75.  
  76.  
  77. #endif // #ifndef _CONFIGFILE_H_
  78.  
  79.