util_cfgtree.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /* Licensed to the Apache Software Foundation (ASF) under one or more
  2. * contributor license agreements. See the NOTICE file distributed with
  3. * this work for additional information regarding copyright ownership.
  4. * The ASF licenses this file to You under the Apache License, Version 2.0
  5. * (the "License"); you may not use this file except in compliance with
  6. * the License. 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. /**
  17. * @file util_cfgtree.h
  18. * @brief Config Tree Package
  19. *
  20. * @defgroup APACHE_CORE_CONFIG_TREE Config Tree Package
  21. * @ingroup APACHE_CORE_CONFIG
  22. * @{
  23. */
  24. #ifndef AP_CONFTREE_H
  25. #define AP_CONFTREE_H
  26. #include "ap_config.h"
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. typedef struct ap_directive_t ap_directive_t;
  31. /**
  32. * @brief Structure used to build the config tree.
  33. *
  34. * The config tree only stores
  35. * the directives that will be active in the running server. Directives
  36. * that contain other directions, such as <Directory ...> cause a sub-level
  37. * to be created, where the included directives are stored. The closing
  38. * directive (</Directory>) is not stored in the tree.
  39. */
  40. struct ap_directive_t {
  41. /** The current directive */
  42. const char *directive;
  43. /** The arguments for the current directive, stored as a space
  44. * separated list */
  45. const char *args;
  46. /** The next directive node in the tree */
  47. struct ap_directive_t *next;
  48. /** The first child node of this directive */
  49. struct ap_directive_t *first_child;
  50. /** The parent node of this directive */
  51. struct ap_directive_t *parent;
  52. /** directive's module can store add'l data here */
  53. void *data;
  54. /* ### these may go away in the future, but are needed for now */
  55. /** The name of the file this directive was found in */
  56. const char *filename;
  57. /** The line number the directive was on */
  58. int line_num;
  59. /** A short-cut towards the last directive node in the tree.
  60. * The value may not always be up-to-date but it always points to
  61. * somewhere in the tree, nearer to the tail.
  62. * This value is only set in the first node
  63. */
  64. struct ap_directive_t *last;
  65. };
  66. /**
  67. * The root of the configuration tree
  68. */
  69. AP_DECLARE_DATA extern ap_directive_t *ap_conftree;
  70. /**
  71. * Add a node to the configuration tree.
  72. * @param parent The current parent node. If the added node is a first_child,
  73. then this is changed to the current node
  74. * @param current The current node
  75. * @param toadd The node to add to the tree
  76. * @param child Is the node to add a child node
  77. * @return the added node
  78. */
  79. ap_directive_t *ap_add_node(ap_directive_t **parent, ap_directive_t *current,
  80. ap_directive_t *toadd, int child);
  81. #ifdef __cplusplus
  82. }
  83. #endif
  84. #endif
  85. /** @} */