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.

171 lines
4.2 KiB

  1. /*
  2. * X E M I T . H
  3. *
  4. * XML emitting
  5. *
  6. * Copyright 1986-1997 Microsoft Corporation, All Rights Reserved
  7. */
  8. #ifndef _XEMIT_H_
  9. #define _XEMIT_H_
  10. #include <ex\xemit.h>
  11. #include <cvroot.h>
  12. #include <davimpl.h>
  13. // CXMLEmitter helper functions ----------------------------------------------
  14. //
  15. SCODE ScGetPropNode (
  16. /* [in] */ CEmitterNode& enItem,
  17. /* [in] */ ULONG hsc,
  18. /* [out] */ CEmitterNode& enPropStat,
  19. /* [out] */ CEmitterNode& enProp);
  20. // CXNode helper functions ---------------------------------------------------
  21. //
  22. SCODE ScSetEscapedValue (CXNode* pxn, LPCWSTR pwszValue, UINT cch, BOOL fHandleStoraePathEscaping);
  23. SCODE ScEmitRawStoragePathValue (CXNode* pxn, LPCWSTR pcwsz, UINT cch);
  24. // This wrapper is used to output the HREF props in XML. It assumes that the HREF properties are in
  25. // the impl's storage path escaped form and calls into the impl defined storage path unescaping
  26. // routine before doing the http-uri-escape call.
  27. //
  28. // $WARNING: pwszValue is assumed to the in the storage path escaped form (as in Exchange store escaped
  29. // $WARNING: form). If not use the above helper to emit the property. Note that this makes a difference
  30. // $WARNING: only for DAVEx. HTTPEXT and EXPROX have do-nothing storage path escape/unescape callouts.
  31. //
  32. inline SCODE ScSetEscapedValue (CXNode* pxn, LPCWSTR pwszValue)
  33. {
  34. return ScSetEscapedValue (pxn, pwszValue, static_cast<UINT>(wcslen(pwszValue)), TRUE);
  35. }
  36. // CEmitterNode helper functions ---------------------------------------------
  37. //
  38. SCODE __fastcall ScAddStatus (CEmitterNode* pen, ULONG hsc);
  39. SCODE __fastcall ScAddError (CEmitterNode* pen, LPCWSTR pwszErrMsg);
  40. // class CStatusCache ------------------------------------------------------
  41. //
  42. class CStatusCache
  43. {
  44. class CHsc
  45. {
  46. public:
  47. ULONG m_hsc;
  48. CHsc(ULONG hsc) : m_hsc(hsc)
  49. {
  50. }
  51. // operators for use with the hash cache
  52. //
  53. int hash( const int rhs ) const
  54. {
  55. return (m_hsc % rhs);
  56. }
  57. bool isequal( const CHsc& rhs ) const
  58. {
  59. return (m_hsc == rhs.m_hsc);
  60. }
  61. };
  62. class CPropNameArray
  63. {
  64. private:
  65. StringBuffer<CHAR> m_sb;
  66. // Ref' counting.
  67. //
  68. // !!! Please note that this is NON-THREADSAFE !!!
  69. //
  70. LONG m_cRef;
  71. // non-implemented
  72. //
  73. CPropNameArray(const CPropNameArray& p);
  74. CPropNameArray& operator=(const CPropNameArray& p);
  75. public:
  76. CPropNameArray() :
  77. m_cRef(1)
  78. {
  79. }
  80. VOID AddRef() { m_cRef++; }
  81. VOID Release() { if (0 == --m_cRef) delete this; }
  82. // Accessors
  83. //
  84. UINT CProps () { return m_sb.CbSize() / sizeof (LPCWSTR); }
  85. LPCWSTR PwszProp (UINT iProp)
  86. {
  87. // Use C-style cast, reinterpret_cast cannot convert LPCSTR to LPCWSTR *
  88. //
  89. return *((LPCWSTR *)(m_sb.PContents() + iProp * sizeof(LPCWSTR)));
  90. }
  91. SCODE ScAddPropName (LPCWSTR pwszProp)
  92. {
  93. UINT cb = sizeof (LPCWSTR);
  94. // Store the pointer in the string buffer
  95. //
  96. UINT cbAppend = m_sb.Append (cb, reinterpret_cast<LPSTR>(&pwszProp));
  97. return (cb == cbAppend) ? S_OK : E_OUTOFMEMORY;
  98. }
  99. };
  100. typedef CCache<CHsc, auto_ref_ptr<CPropNameArray> > CPropNameCache;
  101. CPropNameCache m_cache;
  102. ChainedStringBuffer<WCHAR> m_csbPropNames;
  103. class EmitStatusNodeOp : public CPropNameCache::IOp
  104. {
  105. CEmitterNode& m_enParent;
  106. // NOT IMPLEMENTED
  107. //
  108. EmitStatusNodeOp( const EmitStatusNodeOp& );
  109. EmitStatusNodeOp& operator=( const EmitStatusNodeOp& );
  110. public:
  111. EmitStatusNodeOp (CEmitterNode& enParent) :
  112. m_enParent(enParent)
  113. {
  114. }
  115. BOOL operator()( const CHsc& key,
  116. const auto_ref_ptr<CPropNameArray>& pna );
  117. };
  118. // non-implemented
  119. //
  120. CStatusCache(const CStatusCache& p);
  121. CStatusCache& operator=(const CStatusCache& p);
  122. public:
  123. CStatusCache()
  124. {
  125. }
  126. SCODE ScInit () { return m_cache.FInit() ? S_OK : E_OUTOFMEMORY ; }
  127. BOOL FEmpty () { return m_cache.CItems() == 0; }
  128. SCODE ScAddErrorStatus (ULONG hsc, LPCWSTR pwszProp);
  129. SCODE ScEmitErrorStatus (CEmitterNode& enParent);
  130. };
  131. // CEmitterNode construction helpers -----------------------------------------
  132. //
  133. SCODE ScEmitFromVariant (
  134. /* [in] */ CXMLEmitter& emitter,
  135. /* [in] */ CEmitterNode& enParent,
  136. /* [in] */ LPCWSTR pwszTag,
  137. /* [in] */ PROPVARIANT& var);
  138. #endif // _XEMIT_H_