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.

315 lines
7.3 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. nodefac.h
  5. Abstract:
  6. This module defines the CDavnodefactory class, which implements the
  7. NodeFactory API, used to parse XML. It also exports the wrapper functions
  8. that the C code uses to parse XML data. We need wrapper functions around the
  9. C++ API.
  10. Author:
  11. Rohan Kumar [RohanK] 14-Sept-1999
  12. Revision History:
  13. --*/
  14. #ifndef _NODE_FACTORY_
  15. #define _NODE_FACTORY_
  16. #include <stdio.h>
  17. #include <windows.h>
  18. #ifdef __cplusplus
  19. #include <objbase.h>
  20. #include "xmlparser.h"
  21. #if DBG
  22. #define XmlDavDbgPrint(_x_) DbgPrint _x_
  23. #else
  24. #define XmlDavDbgPrint(_x_)
  25. #endif
  26. typedef enum _CREATE_NODE_ATTRIBUTES {
  27. CreateNode_isHidden = 0,
  28. CreateNode_isCollection,
  29. CreateNode_ContentLength,
  30. CreateNode_CreationTime,
  31. CreateNode_DisplayName,
  32. CreateNode_LastModifiedTime,
  33. CreateNode_Status,
  34. CreateNode_Win32FileAttributes,
  35. CreateNode_Win32CreationTime,
  36. CreateNode_Win32LastAccessTime,
  37. CreateNode_Win32LastModifiedTime,
  38. CreateNode_ResourceType,
  39. CreateNode_AvailableSpace,
  40. CreateNode_TotalSpace,
  41. CreateNode_Owner,
  42. CreateNode_Timeout,
  43. CreateNode_LockToken,
  44. CreateNode_Max
  45. } CREATE_NODE_ATTRIBUTES;
  46. //
  47. // IMPORTANT!!! The next two typedefs have been copied from standard files.
  48. // This was done because including the standard header files was causing many
  49. // compilation errors. This should be changed at some point.
  50. //
  51. typedef short CSHORT;
  52. typedef struct _TIME_FIELDS {
  53. CSHORT Year; // range [1601...]
  54. CSHORT Month; // range [1..12]
  55. CSHORT Day; // range [1..31]
  56. CSHORT Hour; // range [0..23]
  57. CSHORT Minute; // range [0..59]
  58. CSHORT Second; // range [0..59]
  59. CSHORT Milliseconds;// range [0..999]
  60. CSHORT Weekday; // range [0..6] == [Sunday..Saturday]
  61. } TIME_FIELDS, *PTIME_FIELDS;
  62. //
  63. // Copied from a standard header file. Must be fixed.
  64. //
  65. #define InsertTailList(ListHead, Entry) { \
  66. PLIST_ENTRY _EX_Blink; \
  67. PLIST_ENTRY _EX_ListHead; \
  68. _EX_ListHead = (ListHead); \
  69. _EX_Blink = _EX_ListHead->Blink; \
  70. (Entry)->Flink = _EX_ListHead; \
  71. (Entry)->Blink = _EX_Blink; \
  72. _EX_Blink->Flink = (Entry); \
  73. _EX_ListHead->Blink = (Entry); \
  74. }
  75. #define RemoveEntryList(Entry) { \
  76. PLIST_ENTRY _EX_Blink; \
  77. PLIST_ENTRY _EX_Flink; \
  78. _EX_Flink = (Entry)->Flink; \
  79. _EX_Blink = (Entry)->Blink; \
  80. _EX_Blink->Flink = _EX_Flink; \
  81. _EX_Flink->Blink = _EX_Blink; \
  82. }
  83. //
  84. // The CDavNodeFactory class which implements the NodeFactory API for parsing
  85. // the XML responses from the DAV server.
  86. //
  87. class CDavNodeFactory : public IXMLNodeFactory {
  88. public:
  89. ULONG m_ulRefCount;
  90. PDAV_FILE_ATTRIBUTES m_DavFileAttributes;
  91. //
  92. // These are used in the CreateNode function to parse the XML responses.
  93. //
  94. BOOL m_FoundEntry, m_CreateNewEntry;
  95. ULONG m_FileIndex;
  96. CREATE_NODE_ATTRIBUTES m_CreateNodeAttribute;
  97. PDAV_FILE_ATTRIBUTES m_DFAToUse;
  98. PDAV_FILE_ATTRIBUTES m_CollectionDFA;
  99. DWORD m_MinDisplayNameLength;
  100. CDavNodeFactory() : m_ulRefCount(0), m_DavFileAttributes(NULL),
  101. m_FoundEntry(FALSE), m_FileIndex(0), m_DFAToUse(NULL),
  102. m_CollectionDFA(NULL), m_MinDisplayNameLength((DWORD)-1),
  103. m_CreateNewEntry(FALSE),
  104. m_CreateNodeAttribute(CreateNode_Max)
  105. {}
  106. //
  107. // IUnknown interface methods.
  108. //
  109. virtual STDMETHODIMP_(ULONG)
  110. AddRef(
  111. VOID
  112. );
  113. virtual STDMETHODIMP_(ULONG)
  114. Release(
  115. VOID
  116. );
  117. virtual STDMETHODIMP
  118. QueryInterface(
  119. REFIID riid,
  120. LPVOID *ppvObject
  121. );
  122. //
  123. // IXMLNodeFactory interface methods.
  124. //
  125. virtual HRESULT STDMETHODCALLTYPE
  126. NotifyEvent(
  127. IXMLNodeSource __RPC_FAR *pSource,
  128. XML_NODEFACTORY_EVENT iEvt
  129. );
  130. virtual HRESULT STDMETHODCALLTYPE
  131. BeginChildren(
  132. IXMLNodeSource __RPC_FAR * pSource,
  133. XML_NODE_INFO __RPC_FAR * pNodeInfo
  134. );
  135. virtual HRESULT STDMETHODCALLTYPE
  136. EndChildren(
  137. IXMLNodeSource __RPC_FAR * pSource,
  138. BOOL fEmptyNode,
  139. XML_NODE_INFO __RPC_FAR * pNodeInfo
  140. );
  141. virtual HRESULT STDMETHODCALLTYPE
  142. Error(
  143. IXMLNodeSource __RPC_FAR *pSource,
  144. HRESULT hrErrorCode,
  145. USHORT cNumRecs,
  146. XML_NODE_INFO __RPC_FAR *__RPC_FAR *apNodeInfo
  147. );
  148. virtual HRESULT STDMETHODCALLTYPE
  149. CreateNode(
  150. IN IXMLNodeSource __RPC_FAR *pSource,
  151. IN PVOID pNodeParent,
  152. IN USHORT cNumRecs,
  153. IN XML_NODE_INFO __RPC_FAR **aNodeInfo
  154. );
  155. };
  156. extern "C" {
  157. ULONG
  158. DavPushData(
  159. IN PCHAR DataBuff,
  160. IN OUT PVOID *Context1,
  161. IN OUT PVOID *Context2,
  162. IN ULONG NumOfBytes,
  163. IN BOOL isLast
  164. );
  165. ULONG
  166. DavParseData(
  167. PDAV_FILE_ATTRIBUTES DavFileAttributes,
  168. PVOID Context1,
  169. PVOID Conttext2,
  170. ULONG *NumOfFileEntries
  171. );
  172. ULONG
  173. DavParseDataEx(
  174. IN OUT PDAV_FILE_ATTRIBUTES DavFileAttributes,
  175. IN PVOID Context1,
  176. IN PVOID Context2,
  177. OUT ULONG *NumOfFileEntries,
  178. OUT DAV_FILE_ATTRIBUTES ** pCollectionDFA
  179. );
  180. VOID
  181. DavFinalizeFileAttributesList(
  182. PDAV_FILE_ATTRIBUTES DavFileAttributes,
  183. BOOL fFreeHeadDFA
  184. );
  185. VOID
  186. DavCloseContext(
  187. PVOID Context1,
  188. PVOID Context2
  189. );
  190. //
  191. // IMPORTANT!!! The next prototype has been copied from a standard ".h" file.
  192. // This was done because including the standard header file was causing many
  193. // compilation errors. This should be changed at some point.
  194. //
  195. NTSYSAPI
  196. BOOLEAN
  197. NTAPI
  198. RtlTimeFieldsToTime (
  199. PTIME_FIELDS TimeFields,
  200. PLARGE_INTEGER Time
  201. );
  202. ULONG
  203. DbgPrint(
  204. PSTR Format,
  205. ...
  206. );
  207. }
  208. ULONG
  209. DavParsedateTimetzTimeString(
  210. PWCHAR TimeString,
  211. PLARGE_INTEGER lpft
  212. );
  213. ULONG
  214. DavParseRfc1123TimeString(
  215. PWCHAR TimeString,
  216. PDAV_FILE_ATTRIBUTES DavFileAttributes,
  217. CREATE_NODE_ATTRIBUTES CreateNodeAttribute
  218. );
  219. #else
  220. //
  221. // These calls are wrapper routines used by the C code to parse XML using the
  222. // NodeFactory C++ API that we are implementing.
  223. //
  224. ULONG
  225. DavPushData(
  226. IN PCHAR DataBuff,
  227. IN OUT PVOID *Context1,
  228. IN OUT PVOID *Context2,
  229. IN ULONG NumOfBytes,
  230. IN BOOL isLast
  231. );
  232. ULONG
  233. DavParseData(
  234. PDAV_FILE_ATTRIBUTES DavFileAttributes,
  235. PVOID Context1,
  236. PVOID Conttext2,
  237. ULONG *NumOfFileEntries
  238. );
  239. ULONG
  240. DavParseDataEx(
  241. IN OUT PDAV_FILE_ATTRIBUTES DavFileAttributes,
  242. IN PVOID Context1,
  243. IN PVOID Context2,
  244. OUT ULONG *NumOfFileEntries,
  245. OUT DAV_FILE_ATTRIBUTES ** pCollectionDFA
  246. );
  247. VOID
  248. DavFinalizeFileAttributesList(
  249. PDAV_FILE_ATTRIBUTES DavFileAttributes,
  250. BOOL fFreeHeadDFA
  251. );
  252. VOID
  253. DavCloseContext(
  254. PVOID Context1,
  255. PVOID Context2
  256. );
  257. #endif // __cplusplus
  258. #endif // _NODE_FACTORY_