MCPcopy Create free account
hub / github.com/apache/httpd / dav_dbm_open_direct

Function dav_dbm_open_direct

modules/dav/fs/dbm.c:132–181  ·  view source on GitHub ↗

dav_dbm_open_direct: Opens a *dbm database specified by path. * ro = boolean read-only flag. */

Source from the content-addressed store, hash-verified

130 * ro = boolean read-only flag.
131 */
132dav_error * dav_dbm_open_direct(apr_pool_t *p, const char *pathname, int ro,
133 dav_db **pdb)
134{
135#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
136 const apr_dbm_driver_t *driver;
137 const apu_err_t *err;
138#endif
139 apr_dbm_t *file = NULL;
140 apr_status_t status;
141
142 *pdb = NULL;
143
144#if APU_MAJOR_VERSION > 1 || (APU_MAJOR_VERSION == 1 && APU_MINOR_VERSION >= 7)
145 if ((status = apr_dbm_get_driver(&driver, NULL, &err, p)) != APR_SUCCESS) {
146 ap_log_error(APLOG_MARK, APLOG_ERR, status, ap_server_conf, APLOGNO(10289)
147 "mod_dav_fs: The DBM library '%s' could not be loaded: %s",
148 err->reason, err->msg);
149 return dav_new_error(p, HTTP_INTERNAL_SERVER_ERROR, 1, status,
150 "Could not load library for database.");
151 }
152 if ((status = apr_dbm_open2(&file, driver, pathname,
153 ro ? APR_DBM_READONLY : APR_DBM_RWCREATE,
154 APR_OS_DEFAULT, p))
155 != APR_SUCCESS && !ro) {
156 return dav_fs_dbm_error(NULL, p, status);
157 }
158#else
159 if ((status = apr_dbm_open(&file, pathname,
160 ro ? APR_DBM_READONLY : APR_DBM_RWCREATE,
161 APR_OS_DEFAULT, p))
162 != APR_SUCCESS
163 && !ro) {
164 /* ### do something with 'status' */
165
166 /* we can't continue if we couldn't open the file
167 and we need to write */
168 return dav_fs_dbm_error(NULL, p, status);
169 }
170#endif
171
172 /* may be NULL if we tried to open a non-existent db as read-only */
173 if (file != NULL) {
174 /* we have an open database... return it */
175 *pdb = apr_pcalloc(p, sizeof(**pdb));
176 (*pdb)->pool = p;
177 (*pdb)->file = file;
178 }
179
180 return NULL;
181}
182
183static dav_error * dav_dbm_open(apr_pool_t * p, const dav_resource *resource,
184 int ro, dav_db **pdb)

Callers 2

dav_dbm_openFunction · 0.85

Calls 3

dav_new_errorFunction · 0.85
dav_fs_dbm_errorFunction · 0.85
ap_log_errorFunction · 0.50

Tested by

no test coverage detected