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.

99 lines
2.0 KiB

  1. //**************************************************************************************************
  2. //
  3. // Purpose: Defines classes to support parsing tokens from a xml file
  4. #ifndef _PARSER_H
  5. #define _PARSER_H
  6. #include <stdio.h>
  7. #undef CLASS_IMPORT_EXPORT
  8. #ifdef HHCTRL // define this only when building the HHCtrl DLL
  9. #define CLASS_IMPORT_EXPORT /**/
  10. #else
  11. #ifdef HHSETUP // define this only when building the HHSetup DLL
  12. #define CLASS_IMPORT_EXPORT __declspec( dllexport )
  13. #else
  14. #define CLASS_IMPORT_EXPORT __declspec( dllimport )
  15. #endif
  16. #endif
  17. #define MAX_LINE_LEN 1024
  18. #define F_OK 0
  19. #define F_NOFILE 1
  20. #define F_READ 2
  21. #define F_WRITE 3
  22. #define F_MEMORY 4
  23. #define F_EOF 5
  24. #define F_END 6
  25. #define F_TAGMISSMATCH 7
  26. #define F_MISSINGENDTAG 8
  27. #define F_NOTFOUND 9
  28. #define F_NOPARENT 10
  29. #define F_NULL 11
  30. #define F_NOTITLE 12
  31. #define F_LOCATION 13
  32. #define F_REFERENCED 14
  33. #define F_DUPLICATE 15
  34. #define F_DELETE 16
  35. #define F_CLOSE 17
  36. #define F_EXISTCHECK 19
  37. class CParseXML {
  38. private: // data
  39. CHAR m_cCurToken[MAX_LINE_LEN];
  40. CHAR m_cCurWord[MAX_LINE_LEN];
  41. CHAR m_cCurBuffer[MAX_LINE_LEN];
  42. FILE *m_fh;
  43. CHAR * m_pCurrentIndex;
  44. DWORD m_dwError;
  45. private: // functions
  46. DWORD Read();
  47. DWORD SetError(DWORD dw) { m_dwError = dw; return m_dwError; }
  48. public:
  49. CParseXML() {
  50. m_fh = NULL;
  51. m_cCurBuffer[0] = '\0';
  52. m_pCurrentIndex = NULL;
  53. m_dwError = F_OK;
  54. }
  55. ~CParseXML() {
  56. End();
  57. }
  58. CHAR * GetFirstWord(CHAR *);
  59. CHAR * GetValue(CHAR *);
  60. DWORD Start(const CHAR *szFile);
  61. void End();
  62. CHAR *GetToken();
  63. DWORD GetError() { return m_dwError; }
  64. };
  65. // class to support a FIFO queue of strings
  66. typedef struct fifo {
  67. CHAR *string;
  68. fifo *prev;
  69. } FIFO;
  70. class CLASS_IMPORT_EXPORT CFIFOString {
  71. private:
  72. FIFO *m_fifoTail;
  73. public:
  74. CFIFOString() { m_fifoTail = NULL; }
  75. ~CFIFOString();
  76. void RemoveAll();
  77. DWORD AddTail(CHAR *sz);
  78. DWORD GetTail(CHAR **sz);
  79. };
  80. #endif