UniMRCP  1.7.0
apt_dir_layout.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008-2015 Arsen Chaloyan
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 
17 #ifndef APT_DIR_LAYOUT_H
18 #define APT_DIR_LAYOUT_H
19 
20 /**
21  * @file apt_dir_layout.h
22  * @brief Directories Layout
23  */
24 
25 #include "apt.h"
26 
28 
29 /*
30  * This define allows user applications to support both the old interface,
31  * where members of apt_dir_layout_t structure were accessible to the
32  * application, and the new opaque interface, where OPAQUE_DIR_LAYOUT
33  * is defined.
34  */
35 #define OPAQUE_DIR_LAYOUT
36 
37 /** Directories layout declaration */
39 
40 /** Enumeration of directories the layout is composed of */
41 typedef enum {
42  APT_LAYOUT_CONF_DIR, /**< configuration directory */
43  APT_LAYOUT_PLUGIN_DIR, /**< plugin directory */
44  APT_LAYOUT_LOG_DIR, /**< log directory */
45  APT_LAYOUT_DATA_DIR, /**< data directory */
46  APT_LAYOUT_VAR_DIR, /**< var directory */
47 
48  APT_LAYOUT_DIR_COUNT, /**< number of directories in the default layout */
49 
50  APT_LAYOUT_EXT_DIR = APT_LAYOUT_DIR_COUNT
52 
53 /**
54  * Create the default directories layout based on the specified root directory.
55  * @param root_dir_path the path to the root directory
56  * @param pool the memory pool to use
57  */
58 APT_DECLARE(apt_dir_layout_t*) apt_default_dir_layout_create(const char *root_dir_path, apr_pool_t *pool);
59 
60 /**
61  * Create a custom directories layout based on the specified individual directories.
62  * @param conf_dir_path the path to the config dir
63  * @param plugin_dir_path the path to the plugin dir
64  * @param log_dir_path the path to the log dir
65  * @param data_dir_path the path to the data dir
66  * @param var_dir_path the path to the var dir
67  * @param pool the memory pool to use
68  */
70  const char *conf_dir_path,
71  const char *plugin_dir_path,
72  const char *log_dir_path,
73  const char *data_dir_path,
74  const char *var_dir_path,
75  apr_pool_t *pool);
76 
77 /**
78  * Create a bare directories layout.
79  * @param pool the memory pool to use
80  */
82 
83 /**
84  * Create an extended bare directories layout.
85  * @param count the number of directories in the layout
86  * @param pool the memory pool to use
87  */
88 APT_DECLARE(apt_dir_layout_t*) apt_dir_layout_create_ext(apr_size_t count, apr_pool_t *pool);
89 
90 /**
91  * Load directories layout from the specified configuration file.
92  * @param dir_layout the directory layout
93  * @param config_file the path to the configuration file
94  * @param pool the memory pool to use
95  */
96 APT_DECLARE(apt_bool_t) apt_dir_layout_load(apt_dir_layout_t *dir_layout, const char *config_file, apr_pool_t *pool);
97 
98 /**
99  * Load directories layout from the specified configuration file using the provided labels.
100  * @param dir_layout the directory layout
101  * @param config_file the path to the configuration file
102  * @param labels the array of directory labels (configuration entries)
103  * @param count the number of labels (normally equals the number of directories in the layout)
104  * @param pool the memory pool to use
105  */
106 APT_DECLARE(apt_bool_t) apt_dir_layout_load_ext(apt_dir_layout_t *dir_layout, const char *config_file, const char **labels, apr_size_t count, apr_pool_t *pool);
107 
108 /**
109  * Set the path to the individual directory in the layout.
110  * @param dir_layout the directory layout
111  * @param dir_entry_id the directory id (apt_dir_entry_id)
112  * @param path the directory path
113  * @param pool the memory pool to use
114  */
115 APT_DECLARE(apt_bool_t) apt_dir_layout_path_set(apt_dir_layout_t *dir_layout, apr_size_t dir_entry_id, const char *path, apr_pool_t *pool);
116 
117 /**
118  * Get the path to the individual directory in the layout.
119  * @param dir_layout the directory layout
120  * @param dir_entry_id the directory id (apt_dir_entry_id)
121  */
122 APT_DECLARE(const char*) apt_dir_layout_path_get(const apt_dir_layout_t *dir_layout, apr_size_t dir_entry_id);
123 
124 /**
125  * Compose a file path relative to the specified directory in the layout.
126  * @param dir_layout the directory layout
127  * @param dir_entry_id the directory id (apt_dir_entry_id)
128  * @param file_name the file name to append to the directory path
129  * @param pool the memory pool to use
130  */
131 APT_DECLARE(char*) apt_dir_layout_path_compose(const apt_dir_layout_t *dir_layout, apr_size_t dir_entry_id, const char *file_name, apr_pool_t *pool);
132 
133 
134 /**
135  * Compose a file path relative to config dir.
136  * @param dir_layout the directory layout
137  * @param file_name the file name
138  * @param pool the memory pool to use
139  */
140 APT_DECLARE(char*) apt_confdir_filepath_get(const apt_dir_layout_t *dir_layout, const char *file_name, apr_pool_t *pool);
141 
142 /**
143  * Compose a file path relative to data dir.
144  * @param dir_layout the directory layout
145  * @param file_name the file name
146  * @param pool the memory pool to use
147  */
148 APT_DECLARE(char*) apt_datadir_filepath_get(const apt_dir_layout_t *dir_layout, const char *file_name, apr_pool_t *pool);
149 
150 /**
151  * Compose a file path relative to var dir.
152  * @param dir_layout the directory layout
153  * @param file_name the file name
154  * @param pool the memory pool to use
155  */
156 APT_DECLARE(char*) apt_vardir_filepath_get(const apt_dir_layout_t *dir_layout, const char *file_name, apr_pool_t *pool);
157 
158 
160 
161 #endif /* APT_DIR_LAYOUT_H */
apt_dir_layout_t * apt_custom_dir_layout_create(const char *conf_dir_path, const char *plugin_dir_path, const char *log_dir_path, const char *data_dir_path, const char *var_dir_path, apr_pool_t *pool)
struct apt_dir_layout_t apt_dir_layout_t
Definition: apt_dir_layout.h:38
apt_bool_t apt_dir_layout_path_set(apt_dir_layout_t *dir_layout, apr_size_t dir_entry_id, const char *path, apr_pool_t *pool)
#define APT_END_EXTERN_C
Definition: apt.h:38
apt_dir_layout_t * apt_default_dir_layout_create(const char *root_dir_path, apr_pool_t *pool)
int apt_bool_t
Definition: apt.h:57
Definition: apt_dir_layout.h:42
const char * apt_dir_layout_path_get(const apt_dir_layout_t *dir_layout, apr_size_t dir_entry_id)
char * apt_datadir_filepath_get(const apt_dir_layout_t *dir_layout, const char *file_name, apr_pool_t *pool)
Definition: apt_dir_layout.h:44
Definition: apt_dir_layout.h:48
#define APT_BEGIN_EXTERN_C
Definition: apt.h:36
apt_dir_layout_t * apt_dir_layout_create(apr_pool_t *pool)
Definition: apt_dir_layout.h:43
#define APT_DECLARE(type)
Definition: apt.h:53
APR Toolkit Definitions.
apt_bool_t apt_dir_layout_load_ext(apt_dir_layout_t *dir_layout, const char *config_file, const char **labels, apr_size_t count, apr_pool_t *pool)
char * apt_confdir_filepath_get(const apt_dir_layout_t *dir_layout, const char *file_name, apr_pool_t *pool)
apt_dir_entry_id
Definition: apt_dir_layout.h:41
char * apt_vardir_filepath_get(const apt_dir_layout_t *dir_layout, const char *file_name, apr_pool_t *pool)
char * apt_dir_layout_path_compose(const apt_dir_layout_t *dir_layout, apr_size_t dir_entry_id, const char *file_name, apr_pool_t *pool)
Definition: apt_dir_layout.h:46
apt_bool_t apt_dir_layout_load(apt_dir_layout_t *dir_layout, const char *config_file, apr_pool_t *pool)
apt_dir_layout_t * apt_dir_layout_create_ext(apr_size_t count, apr_pool_t *pool)
Definition: apt_dir_layout.h:45