trie_search.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright 2011 Google Inc.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. *
  16. * Functions to search the registry tables. These should not
  17. * need to be invoked directly.
  18. */
  19. #ifndef DOMAIN_REGISTRY_PRIVATE_TRIE_SEARCH_H_
  20. #define DOMAIN_REGISTRY_PRIVATE_TRIE_SEARCH_H_
  21. #include <stdlib.h>
  22. #include "registry_types.h"
  23. #include "trie_node.h"
  24. /*
  25. * Find a TrieNode under the given parent node with the specified
  26. * name. If parent is NULL then the search is performed at the root
  27. * TrieNode.
  28. */
  29. const struct TrieNode* FindRegistryNode(const char* component,
  30. const struct TrieNode* parent);
  31. /*
  32. * Find a leaf TrieNode under the given parent node with the specified
  33. * name. If parent does not have all leaf children (i.e. if
  34. * HasLeafChildren(parent) returns zero), will assert and return
  35. * NULL. If parent is NULL then the search is performed at the root
  36. * TrieNode.
  37. */
  38. const char* FindRegistryLeafNode(const char* component,
  39. const struct TrieNode* parent);
  40. /* Get the hostname part for the given string table offset. */
  41. const char* GetHostnamePart(size_t offset);
  42. /* Does the given node have all leaf children? */
  43. int HasLeafChildren(const struct TrieNode* node);
  44. /*
  45. * Initialize the registry tables. Called at system startup by
  46. * InitializeDomainRegistry().
  47. */
  48. void SetRegistryTables(const char* string_table,
  49. const struct TrieNode* node_table,
  50. size_t num_root_children,
  51. const REGISTRY_U16* leaf_node_table,
  52. size_t leaf_node_table_offset);
  53. #endif /* DOMAIN_REGISTRY_PRIVATE_TRIE_SEARCH_H_ */