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.

195 lines
3.5 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. qryparse.hxx
  5. Abstract:
  6. Author:
  7. Felix Wong [t-FelixW] 05-Nov-1996
  8. ++*/
  9. #ifndef _QRYPARSE_HXX
  10. #define _QRYPARSE_HXX
  11. #define BAIL_ON_FAILURE(hr) \
  12. if (FAILED(hr)) { \
  13. goto error; \
  14. }\
  15. #define MAXVAL 1000
  16. #define QUERYNODE_INITIAL 2
  17. #define QUERYNODE_INC 5
  18. #define ATTRNODE_INITIAL 2
  19. #define ATTRNODE_INC 2
  20. enum snodetypes {
  21. SNODE_SZ,
  22. SNODE_NODE,
  23. SNODE_FILTER,
  24. SNODE_NULL
  25. };
  26. enum query_symbols {
  27. QUERY_EQUAL,
  28. QUERY_NOT,
  29. QUERY_APPROX,
  30. QUERY_OR,
  31. QUERY_AND,
  32. QUERY_PRESENT,
  33. QUERY_STRING,
  34. QUERY_LE,
  35. QUERY_GE,
  36. QUERY_UNKNOWN
  37. };
  38. enum search_scope {
  39. NDS_SCOPE_BASE,
  40. NDS_SCOPE_ONELEVEL,
  41. NDS_SCOPE_SUBTREE
  42. };
  43. typedef struct _AttrNode {
  44. LPWSTR szName;
  45. DWORD dwType;
  46. BOOL fBinary;
  47. } AttrNode;
  48. class CQueryNode;
  49. class CStack;
  50. class CSyntaxNode;
  51. class CAttrList;
  52. class CQueryNode
  53. {
  54. public:
  55. CQueryNode();
  56. ~CQueryNode();
  57. HRESULT GenerateNDSTree(
  58. CAttrList *pAttrList,
  59. LPQUERY_NODE *ppNDSSearchTree
  60. );
  61. HRESULT SetToString(LPWSTR szValue);
  62. static HRESULT MapQueryToNDSType(
  63. DWORD dwType,
  64. DWORD *pdwNDSType
  65. );
  66. HRESULT AddChild(CQueryNode *pChild);
  67. DWORD _dwType;
  68. private:
  69. LPWSTR _szValue;
  70. CQueryNode **_rgQueryNode;
  71. DWORD _dwQueryNode;
  72. DWORD _dwQueryNodeMax;
  73. };
  74. class CStack
  75. {
  76. public:
  77. CStack();
  78. ~CStack();
  79. HRESULT Push(CSyntaxNode*);
  80. HRESULT Pop(CSyntaxNode**);
  81. HRESULT Pop();
  82. HRESULT Current(CSyntaxNode**);
  83. void Dump();
  84. private:
  85. DWORD _dwStackIndex;
  86. CSyntaxNode* _Stack[MAXVAL];
  87. };
  88. // Helper functions
  89. HRESULT MakeNode(
  90. DWORD dwType,
  91. CQueryNode *pLQueryNode,
  92. CQueryNode *pRQueryNode,
  93. CQueryNode **ppQueryNodeReturn
  94. );
  95. HRESULT MakeLeaf(
  96. LPWSTR szValue,
  97. CQueryNode **ppQuerynNodeReturn
  98. );
  99. HRESULT Parse(
  100. LPWSTR szQuery,
  101. CQueryNode **ppNode,
  102. CAttrList **ppAttrList
  103. );
  104. class CSyntaxNode
  105. {
  106. public:
  107. CSyntaxNode();
  108. ~CSyntaxNode();
  109. void SetNode(CQueryNode *pNode);
  110. void SetNode(LPWSTR szValue);
  111. void SetNode(DWORD dwFilterType);
  112. DWORD _dwToken;
  113. DWORD _dwState;
  114. DWORD _dwType;
  115. union {
  116. CQueryNode *_pNode; // Put in after reduction
  117. LPWSTR _szValue; // dwToken == ATTRTYPE|ATTRVAL
  118. DWORD _dwFilterType; // reduction of FT
  119. };
  120. };
  121. class CAttrList
  122. {
  123. public:
  124. CAttrList();
  125. ~CAttrList();
  126. HRESULT Add(LPWSTR szName);
  127. HRESULT SetupType(LPWSTR szConnection);
  128. HRESULT GetType(LPWSTR szName, DWORD *pdwType);
  129. private:
  130. DWORD _dwAttrMax;
  131. DWORD _dwAttrCur;
  132. AttrNode* _rgAttr;
  133. };
  134. HRESULT
  135. AdsNdsGenerateParseTree(
  136. LPWSTR pszCommandText,
  137. LPWSTR pszConnection,
  138. LPQUERY_NODE *ppQueryNode
  139. );
  140. /*
  141. ADsNdsGenerateParseTree
  142. Generate an NDS search tree used as inputs to NDS search
  143. functions from the search filter
  144. Arguments: pszCommandText - Command text for the search
  145. ppQueryNode - the generated NDS search tree
  146. Returns: HRESULT
  147. S_OK NO ERROR
  148. E_OUTOFMEMORY no memory
  149. */
  150. #endif