Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
2.7 KiB

  1. /*++
  2. Copyright (c) 2002 Microsoft Corporation
  3. Module Name :
  4. parseini.h
  5. Abstract:
  6. Class used to parse the ini file
  7. Author:
  8. Christopher Achille (cachille)
  9. Project:
  10. URLScan Update
  11. Revision History:
  12. March 2002: Created
  13. --*/
  14. #include "stdafx.h"
  15. #define INIFILE_INITIALNUMBEROFLINES 10
  16. #define INIFILE_READ_CHUNK_SIZE 1024
  17. class CIniFileLine {
  18. private:
  19. TCHAR m_szLine[MAX_PATH];
  20. TCHAR m_szStrippedLineContents[MAX_PATH];
  21. void StripOffComments(LPTSTR szString);
  22. void StripOffEOL(LPTSTR szString);
  23. void StripOffTrailingWhite(LPTSTR szString);
  24. public:
  25. CIniFileLine();
  26. BOOL CopyLine(LPWSTR szNewLineContents);
  27. BOOL CopyLine(LPSTR szNewLineContents);
  28. LPTSTR QueryLine();
  29. LPTSTR QueryStrippedLine();
  30. };
  31. class CIniFile {
  32. private:
  33. CIniFileLine **m_pIniLines;
  34. DWORD m_dwNumberofLines;
  35. DWORD m_dwLinesAllocated;
  36. BOOL m_bUnicodeFile;
  37. DWORD m_dwCurrentLine;
  38. BOOL CreateRoomForMoreLines();
  39. CIniFileLine *AddLine( DWORD dwLineNumber );
  40. BOOL FindSectionNumber(LPTSTR szSectionName, DWORD *pdwSection);
  41. BOOL IsSameSection(LPTSTR szSectionName, LPTSTR szLine);
  42. BOOL IsSameItem(LPTSTR szItemName, LPTSTR szLine);
  43. BOOL IsSameSetting(LPTSTR szSettingName, LPTSTR szLine);
  44. CIniFileLine *GetLine(DWORD dwLineNumber);
  45. DWORD GetNumberofLines();
  46. BOOL ReadFileContents( HANDLE hFile );
  47. BOOL LoadChunk( LPBYTE pData, DWORD *pdwCurrentLocation, BOOL bIsLastChunk);
  48. BOOL WriteFileContents( HANDLE hFile );
  49. void ClearIni();
  50. // Iterators
  51. BOOL SetStartforSectionIterator( DWORD dwIndex );
  52. BOOL FindSection( LPTSTR szSectionName );
  53. BOOL FindNextLineInSection( CIniFileLine **ppCurrentLine );
  54. DWORD GetCurrentSectionIteratorLine();
  55. public:
  56. CIniFile();
  57. ~CIniFile();
  58. // Find a section by a specific name
  59. BOOL DoesSectionExist(LPTSTR szSectionName);
  60. // Find a stand along Item in a secion by a specific name (ie. PROPFIND)
  61. BOOL DoesItemInSectionExist(LPTSTR szSectionName, LPTSTR szItem);
  62. // Find a Setting in a section by the setting name (ie. AllowHighBitCharacters=...)
  63. BOOL DoesSettingInSectionExist(LPTSTR szSectionName, LPTSTR szSetting);
  64. // Add a specific section
  65. BOOL AddSection(LPTSTR szNewSectionName);
  66. // Add a line to a specific section
  67. BOOL AddLinesToSection(LPTSTR szSectionName, DWORD dwNumLines, LPTSTR *szLines);
  68. BOOL LoadFile( LPTSTR szFileName );
  69. BOOL SaveFile( LPTSTR szFileName );
  70. };