1 /**
2  * This file is part of the mingw-w64 runtime package.
3  * No warranty is given; refer to the file DISCLAIMER within this package.
4  */
5 
6 #ifndef _PARSER_H
7 #define _PARSER_H
8 
9 #include <winapifamily.h>
10 
11 #if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
12 #include <stdio.h>
13 
14 #undef CLASS_IMPORT_EXPORT
15 #ifdef HHCTRL
16 #define CLASS_IMPORT_EXPORT
17 #elif defined (HHSETUP)
18 #define CLASS_IMPORT_EXPORT __declspec (dllexport)
19 #else
20 #define CLASS_IMPORT_EXPORT __declspec (dllimport)
21 #endif
22 
23 #define PARSER_API_INLINE
24 #define MAX_LINE_LEN 1024
25 
26 #define F_OK 0
27 #define F_NOFILE 1
28 #define F_READ 2
29 #define F_WRITE 3
30 #define F_MEMORY 4
31 #define F_EOF 5
32 #define F_END 6
33 #define F_TAGMISSMATCH 7
34 #define F_MISSINGENDTAG 8
35 #define F_NOTFOUND 9
36 #define F_NOPARENT 10
37 #define F_NULL 11
38 #define F_NOTITLE 12
39 #define F_LOCATION 13
40 #define F_REFERENCED 14
41 #define F_DUPLICATE 15
42 #define F_DELETE 16
43 #define F_CLOSE 17
44 #define F_EXISTCHECK 19
45 
46 class CParseXML {
47 private:
48   CHAR m_cCurToken[MAX_LINE_LEN];
49   CHAR m_cCurWord[MAX_LINE_LEN];
50   CHAR m_cCurBuffer[MAX_LINE_LEN];
51   FILE *m_fh;
52   CHAR *m_pCurrentIndex;
53   DWORD m_dwError;
54 private:
55   DWORD Read ();
SetError(DWORD dw)56   DWORD SetError (DWORD dw) { m_dwError = dw; return m_dwError; }
57 public:
CParseXML()58   CParseXML () {
59     m_fh = NULL;
60     m_cCurBuffer[0] = '\0';
61     m_pCurrentIndex = NULL;
62     m_dwError = F_OK;
63   }
~CParseXML()64   ~CParseXML () {
65     End ();
66   }
67   CHAR *GetFirstWord (CHAR *);
68   CHAR *GetValue (CHAR *);
69   DWORD Start (const CHAR *szFile);
70   void End ();
71   CHAR *GetToken ();
GetError()72   DWORD GetError () { return m_dwError; }
73 };
74 
75 typedef struct fifo {
76   CHAR *string;
77   fifo *prev;
78 } FIFO;
79 
80 class CLASS_IMPORT_EXPORT CFIFOString {
81 private:
82   FIFO *m_fifoTail;
83 public:
CFIFOString()84   CFIFOString () { m_fifoTail = NULL; }
85   ~CFIFOString ();
86   void RemoveAll ();
87   DWORD AddTail (CHAR *sz);
88   DWORD GetTail (PZPSTR sz);
89 };
90 #endif
91 
92 #endif
93