} configfile_t;
/* Open a configfile_t as FILE, return open configfile_t struct pointer */
-API_EXPORT(configfile_t *) ap_pcfg_openfile(ap_context_t *p, const char *name);
+API_EXPORT(ap_status_t) ap_pcfg_openfile(configfile_t **, ap_context_t *p, const char *name);
/* Allocate a configfile_t handle with user defined functions and params */
API_EXPORT(configfile_t *) ap_pcfg_open_custom(ap_context_t *p, const char *descr,
configfile_t *f;
char l[MAX_STRING_LEN];
const char *rpw, *w;
+ ap_status_t status;
- if (!(f = ap_pcfg_openfile(r->pool, auth_pwfile))) {
- ap_log_rerror(APLOG_MARK, APLOG_ERR, errno, r,
+ if ((status = ap_pcfg_openfile(&f, r->pool, auth_pwfile)) != APR_SUCCESS) {
+ ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r,
"Could not open password file: %s", auth_pwfile);
return NULL;
}
ap_context_t *sp;
char l[MAX_STRING_LEN];
const char *group_name, *ll, *w;
+ ap_status_t status;
- if (!(f = ap_pcfg_openfile(p, grpfile))) {
+ if ((status = ap_pcfg_openfile(&f, p, grpfile)) != APR_SUCCESS) {
/*add? aplog_error(APLOG_MARK, APLOG_ERR, NULL,
"Could not open group file: %s", grpfile);*/
return NULL;
char l[MAX_STRING_LEN];
int x;
const char *types_confname = ap_get_module_config(s->module_config, &mime_module);
+ ap_status_t status;
if (!types_confname)
types_confname = TYPES_CONFIG_FILE;
types_confname = ap_server_root_relative(p, types_confname);
- if (!(f = ap_pcfg_openfile(p, types_confname))) {
- ap_log_error(APLOG_MARK, APLOG_ERR, errno, s,
+ if ((status = ap_pcfg_openfile(&f, p, types_confname)) != APR_SUCCESS) {
+ ap_log_error(APLOG_MARK, APLOG_ERR, status, s,
"could not open mime types log file %s.", types_confname);
exit(1);
}
char *mapdflt;
char *closest = NULL;
double closest_yet = -1;
+ ap_status_t status;
double testpoint[2];
double pointarray[MAXVERTS + 1][2];
return DECLINED;
}
- imap = ap_pcfg_openfile(r->pool, r->filename);
+ status = ap_pcfg_openfile(&imap, r->pool, r->filename);
- if (!imap) {
+ if (status != APR_SUCCESS) {
return NOT_FOUND;
}
parms.server = s;
parms.override = (RSRC_CONF | OR_ALL) & ~(OR_AUTHCFG | OR_LIMIT);
- if (!(parms.config_file = ap_pcfg_openfile(p,fname))) {
- perror("fopen");
+ if (ap_pcfg_openfile(&parms.config_file, p, fname) != APR_SUCCESS) {
+ /* ZZZ use ap_strerror() once it exists to print an error message */
fprintf(stderr, "%s: could not open document config file %s\n",
ap_server_argv0, fname);
exit(1);
const struct htaccess_result *cache;
struct htaccess_result *new;
void *dc = NULL;
+ ap_status_t status;
/* firstly, search cache */
for (cache = r->htaccess; cache != NULL; cache = cache->next)
while (access_name[0]) {
filename = ap_make_full_path(r->pool, d,
ap_getword_conf(r->pool, &access_name));
+ status = ap_pcfg_openfile(&f, r->pool, filename);
- if ((f = ap_pcfg_openfile(r->pool, filename)) != NULL) {
+ if (status == APR_SUCCESS) {
dc = ap_create_per_dir_config(r->pool);
*result = dc;
break;
}
- else if (errno != ENOENT && errno != ENOTDIR) {
+ else if (status != APR_ENOENT && status != APR_ENOTDIR) {
ap_log_rerror(APLOG_MARK, APLOG_CRIT, errno, r,
"%s pcfg_openfile: unable to check htaccess file, "
"ensure it is readable",
}
/* Open a configfile_t as FILE, return open configfile_t struct pointer */
-API_EXPORT(configfile_t *) ap_pcfg_openfile(ap_context_t *p, const char *name)
+API_EXPORT(ap_status_t) ap_pcfg_openfile(configfile_t **ret_cfg, ap_context_t *p, const char *name)
{
configfile_t *new_cfg;
ap_file_t *file;
- int saved_errno;
ap_status_t stat;
ap_filetype_e type;
if (name == NULL) {
ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, 0, NULL,
"Internal error: pcfg_openfile() called with NULL filename");
- return NULL;
+ return APR_EBADF;
}
if (!ap_os_is_filename_valid(name)) {
ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, 0, NULL,
"Access to config file %s denied: not a valid filename",
name);
- errno = EACCES;
- return NULL;
+ return APR_EACCES;
}
-
+
stat = ap_open(&file, name, APR_READ | APR_BUFFERED, APR_OS_DEFAULT, p);
#ifdef DEBUG
- saved_errno = errno;
ap_log_error(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, NULL,
"Opening config file %s (%s)",
name, (stat != APR_SUCCESS) ? strerror(errno) : "successful");
- errno = saved_errno;
#endif
if (stat != APR_SUCCESS)
- return NULL;
+ return stat;
- if (ap_get_filetype(&type, file) == APR_SUCCESS &&
- type != APR_REG &&
+ stat = ap_get_filetype(&type, file);
+ if (stat != APR_SUCCESS)
+ return stat;
+
+ if (type != APR_REG &&
#if defined(WIN32) || defined(OS2)
!(strcasecmp(name, "nul") == 0 ||
(strlen(name) >= 4 &&
#else
strcmp(name, "/dev/null") != 0) {
#endif /* WIN32 || OS2 */
- saved_errno = errno;
ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, 0, NULL,
"Access to file %s denied by server: not a regular file",
name);
ap_close(file);
- errno = saved_errno;
- return NULL;
+ return APR_EBADF;
}
new_cfg = ap_palloc(p, sizeof(*new_cfg));
new_cfg->getstr = (void *(*)(void *, size_t, void *)) cfg_getstr;
new_cfg->close = (int (*)(void *)) cfg_close;
new_cfg->line_number = 0;
- return new_cfg;
+ *ret_cfg = new_cfg;
+ return APR_SUCCESS;
}