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 |
* Originally developed by Aaron Bannert and Justin Erenkrantz, eBuilt. |
17 |
*/ |
18 |
|
19 |
#ifndef __flood_config_h |
20 |
#define __flood_config_h |
21 |
|
22 |
#include <apr_file_io.h> |
23 |
#include <apr_pools.h> |
24 |
#include <apr_xml.h> |
25 |
|
26 |
/** |
27 |
* The profile_init function (see below) reads a config_t object and |
28 |
* constructs the profile_t that will be used for this test profile. |
29 |
* XXX: For now this is simply the product of the apr XML parsing routines. |
30 |
*/ |
31 |
typedef struct { |
32 |
apr_xml_doc *doc; |
33 |
apr_pool_t *pool; |
34 |
#if APR_HAS_THREADS |
35 |
apr_thread_mutex_t *mutex; |
36 |
#endif |
37 |
} config_t; |
38 |
|
39 |
/** |
40 |
* Parse the configuration from the given input file descriptor, |
41 |
* and return a config_t object. All memory allocated for the config_t |
42 |
* is taken from the given pool. |
43 |
*/ |
44 |
config_t *parse_config(apr_file_t *in, apr_pool_t *pool); |
45 |
|
46 |
/** |
47 |
* Count the number of children of the given element that have |
48 |
* the name "name" and return it. |
49 |
*/ |
50 |
int count_xml_elem_child(struct apr_xml_elem *elem, const char *name); |
51 |
|
52 |
/** |
53 |
* Simply returns the root of the parsed XML document. |
54 |
*/ |
55 |
apr_status_t retrieve_root_xml_elem(struct apr_xml_elem **elem, |
56 |
const config_t *config); |
57 |
|
58 |
/** |
59 |
* Search for the first child of the given top_elem that has |
60 |
* the given name. Return APR_SUCCESS and set elem to the found |
61 |
* element if successful, or APR_EGENERAL otherwise. |
62 |
*/ |
63 |
apr_status_t retrieve_xml_elem_child(struct apr_xml_elem **elem, |
64 |
const struct apr_xml_elem *top_elem, |
65 |
const char *name); |
66 |
|
67 |
/** |
68 |
* Searches the configuration (starting at 'top_elem') for a particular node |
69 |
* at the given path with a <name> of 'name'. If found |
70 |
* the node is returned in the 'elem' parameter, and the function |
71 |
* returns APR_SUCCESS. Otherwise APR_EGENERAL is returned. |
72 |
*/ |
73 |
apr_status_t retrieve_xml_elem_with_childmatch(struct apr_xml_elem **elem, |
74 |
struct apr_xml_elem *top_elem, |
75 |
char *path, |
76 |
const char *child_name, |
77 |
const char *child_value); |
78 |
|
79 |
#endif /* __flood_config_h */ |