1
0

config.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #ifndef NULLSOFT_ONLINEMEDIA_PLUGIN_CONFIG_HEADER
  2. #define NULLSOFT_ONLINEMEDIA_PLUGIN_CONFIG_HEADER
  3. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  4. #pragma once
  5. #endif
  6. #include <wtypes.h>
  7. #define C_CONFIG_WIN32NATIVE
  8. class C_Config
  9. {
  10. public:
  11. C_Config(char *ini);
  12. ~C_Config();
  13. void Flush(void);
  14. void WriteInt(char *name, int value);
  15. char *WriteString(char *name, char *string);
  16. int ReadInt(char *name, int defvalue);
  17. char *ReadString(char *name, char *defvalue);
  18. const char* GetPath() { return m_inifile; }
  19. private:
  20. #ifndef C_CONFIG_WIN32NATIVE
  21. typedef struct
  22. {
  23. char name[16];
  24. char *value;
  25. } strType;
  26. strType *m_strs;
  27. int m_dirty;
  28. int m_num_strs, m_num_strs_alloc;
  29. #else
  30. char m_strbuf[8192];
  31. #endif
  32. char *m_inifile;
  33. };
  34. // set lpSectionName = NULL to write to default section;
  35. DWORD Config_ReadStr(LPCSTR lpSectionName, LPCSTR lpKeyName, LPCSTR lpDefault, LPSTR lpReturnedString, DWORD nSize);
  36. UINT Config_ReadInt(LPCSTR lpSectionName, LPCSTR lpKeyName, INT nDefault);
  37. HRESULT Config_WriteStr(LPCSTR lpSectionName, LPCSTR lpKeyName, LPCSTR lpString);
  38. HRESULT Config_WriteInt(LPCSTR lpSectionName, LPCSTR lpKeyName, INT nValue);
  39. HRESULT Config_WriteSection(LPCSTR lpSectionName, LPCSTR lpData);
  40. typedef BOOL (CALLBACK *ReadServiceIdCallback)(UINT /*serviceId*/, void* /*data*/);
  41. HRESULT Config_ReadServiceIdList(LPCSTR lpSectionName, LPCSTR lpKeyName, CHAR separator, ReadServiceIdCallback callback, void *data);
  42. #endif //NULLSOFT_ONLINEMEDIA_PLUGIN_CONFIG_HEADER