bjh 99/11/02 07:15:11
Modified: src/include httpd.h src/main http_config.c util.c src/modules/standard mod_auth.c mod_imap.c mod_mime.c Log: De-errno ap_pcfg_openfile(). Revision Changes Path 1.12 +1 -1 apache-2.0/src/include/httpd.h Index: httpd.h =================================================================== RCS file: /home/cvs/apache-2.0/src/include/httpd.h,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- httpd.h 1999/10/07 18:13:11 1.11 +++ httpd.h 1999/11/02 15:15:04 1.12 @@ -1004,7 +1004,7 @@ } 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, 1.16 +6 -4 apache-2.0/src/main/http_config.c Index: http_config.c =================================================================== RCS file: /home/cvs/apache-2.0/src/main/http_config.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- http_config.c 1999/10/20 12:49:54 1.15 +++ http_config.c 1999/11/02 15:15:06 1.16 @@ -1040,8 +1040,8 @@ 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); @@ -1070,6 +1070,7 @@ 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) @@ -1091,8 +1092,9 @@ 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); @@ -1110,7 +1112,7 @@ *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", 1.16 +13 -15 apache-2.0/src/main/util.c Index: util.c =================================================================== RCS file: /home/cvs/apache-2.0/src/main/util.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- util.c 1999/10/20 12:49:56 1.15 +++ util.c 1999/11/02 15:15:07 1.16 @@ -855,41 +855,40 @@ } /* 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 stat; + + stat = ap_get_filetype(&type, file); if (stat != APR_SUCCESS) - return NULL; + return stat; - if (ap_get_filetype(&type, file) == APR_SUCCESS && - type != APR_REG && + if (type != APR_REG && #if defined(WIN32) || defined(OS2) !(strcasecmp(name, "nul") == 0 || (strlen(name) >= 4 && @@ -897,13 +896,11 @@ #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)); @@ -913,7 +910,8 @@ 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; } 1.10 +5 -3 apache-2.0/src/modules/standard/mod_auth.c Index: mod_auth.c =================================================================== RCS file: /home/cvs/apache-2.0/src/modules/standard/mod_auth.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- mod_auth.c 1999/10/20 12:50:07 1.9 +++ mod_auth.c 1999/11/02 15:15:08 1.10 @@ -122,9 +122,10 @@ 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; } @@ -150,8 +151,9 @@ 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; 1.7 +3 -2 apache-2.0/src/modules/standard/mod_imap.c Index: mod_imap.c =================================================================== RCS file: /home/cvs/apache-2.0/src/modules/standard/mod_imap.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- mod_imap.c 1999/10/20 12:50:07 1.6 +++ mod_imap.c 1999/11/02 15:15:08 1.7 @@ -603,6 +603,7 @@ char *mapdflt; char *closest = NULL; double closest_yet = -1; + ap_status_t status; double testpoint[2]; double pointarray[MAXVERTS + 1][2]; @@ -624,9 +625,9 @@ 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; } 1.5 +3 -2 apache-2.0/src/modules/standard/mod_mime.c Index: mod_mime.c =================================================================== RCS file: /home/cvs/apache-2.0/src/modules/standard/mod_mime.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- mod_mime.c 1999/10/20 12:50:08 1.4 +++ mod_mime.c 1999/11/02 15:15:08 1.5 @@ -245,14 +245,15 @@ 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); }