select(_a, _b, _c, _d, _e)
#endif
-#ifdef USE_TPF_ACCEPT
-#define ap_accept(_fd, _sa, _ln) tpf_accept(_fd, _sa, _ln)
-#else
-#define ap_accept(_fd, _sa, _ln) accept(_fd, _sa, _ln)
-#endif
-
#ifdef NEED_SIGNAL_INTERRUPT
#define ap_check_signals() tpf_process_signals()
#else
#ifndef AP_LISTEN_H
#define AP_LISTEN_H
+#include "apr_network_io.h"
+
typedef struct ap_listen_rec ap_listen_rec;
struct ap_listen_rec {
ap_listen_rec *next;
- struct sockaddr_in local_addr; /* local IP address and port */
-/* TODO: replace the fd with APR stuff */
- int fd;
+ ap_socket_t *sd;
/* more stuff here, like which protocol is bound to the port */
};
#ifndef NO_RELIABLE_PIPED_LOGS
char *program;
int pid;
- int fds[2];
+ ap_file_t fds[2];
#else
- FILE *write_f;
+ ap_file_t *write_f;
#endif
} piped_log;
#define ap_piped_log_write_fd(pl) ((pl)->fds[1])
#else
#define ap_piped_log_read_fd(pl) (-1)
-#define ap_piped_log_write_fd(pl) (fileno((pl)->write_f))
+#define ap_piped_log_write_fd(pl) ((pl)->write_f)
#endif
#ifdef __cplusplus
#define APACHE_HTTP_PROTOCOL_H
#include "ap_hooks.h"
+#include "apr_portable.h"
#ifdef __cplusplus
extern "C" {
* (Ditto the send_header stuff).
*/
-API_EXPORT(long) ap_send_fd(APRFile fd, request_rec *r);
-API_EXPORT(long) ap_send_fd_length(APRFile fd, request_rec *r, long length);
+API_EXPORT(long) ap_send_fd(int fd, request_rec *r);
+API_EXPORT(long) ap_send_fd_length(int fd, request_rec *r, long length);
API_EXPORT(long) ap_send_fb(BUFF *f, request_rec *r);
API_EXPORT(long) ap_send_fb_length(BUFF *f, request_rec *r, long length);
/* Log files --- note that transfer log is now in the modules... */
char *error_fname;
- FILE *error_log;
+ ap_file_t *error_log;
int loglevel;
/* Module-specific configuration for server, and defaults... */
API_EXPORT(char *) ap_md5_binary(ap_context_t *a, const unsigned char *buf, int len);
API_EXPORT(char *) ap_md5contextTo64(ap_context_t *p, AP_MD5_CTX * context);
#ifdef CHARSET_EBCDIC
-API_EXPORT(char *) ap_md5digest(ap_context_t *p, FILE *infile, int convert);
+API_EXPORT(char *) ap_md5digest(ap_context_t *p, int infile, int convert);
#else
-API_EXPORT(char *) ap_md5digest(ap_context_t *p, APRFile infile);
+API_EXPORT(char *) ap_md5digest(ap_context_t *p, int infile);
#endif /* CHARSET_EBCDIC */
#ifdef __cplusplus
static int asis_handler(request_rec *r)
{
- FILE *f;
+ ap_file_t *f;
const char *location;
+ FILE *thefile; /* XXX leave these alone until we convert */
+ int thefd; /* everything to use apr_file_t's. */
r->allowed |= (1 << M_GET);
if (r->method_number != M_GET)
return NOT_FOUND;
}
- f = ap_pfopen(r->pool, r->filename, "r");
-
- if (f == NULL) {
+ if (ap_open(r->pool, r->filename, APR_READ | APR_BUFFERED,
+ APR_OS_DEFAULT, &f) != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
"file permissions deny server access: %s", r->filename);
return FORBIDDEN;
}
- ap_scan_script_header_err(r, f, NULL);
+ ap_get_os_file(f, &thefd);
+ thefile = fdopen(thefd, "r");
+
+ ap_scan_script_header_err(r, thefile, NULL);
location = ap_table_get(r->headers_out, "Location");
if (location && location[0] == '/' &&
((r->status == HTTP_OK) || ap_is_HTTP_REDIRECT(r->status))) {
- ap_pfclose(r->pool, f);
+ ap_close(f);
/* Internal redirect -- fake-up a pseudo-request */
r->status = HTTP_OK;
ap_send_http_header(r);
if (!r->header_only) {
- fseek(f, 0, SEEK_CUR);
- ap_send_fd(fileno(f), r);
+ ap_off_t zero = 0;
+ ap_seek(f, APR_CUR, &zero);
+ ap_send_fd(thefd, r);
}
- ap_pfclose(r->pool, f);
+ ap_close(f);
return OK;
}
/*
* emit a plain text file
*/
-static void do_emit_plain(request_rec *r, FILE *f)
+static void do_emit_plain(request_rec *r, ap_file_t *f)
{
char buf[IOBUFSIZE + 1];
int i, n, c, ch;
+ ap_status_t stat;
ap_rputs("<PRE>\n", r);
- while (!feof(f)) {
+ while (!ap_eof(f)) {
do {
- n = fread(buf, sizeof(char), IOBUFSIZE, f);
+ n = sizeof(char) * IOBUFSIZE;
+ stat = ap_read(f, buf, &n);
}
- while (n == -1 && ferror(f) && errno == EINTR);
+ while (stat != APR_SUCCESS && stat == EINTR);
if (n == -1 || n == 0) {
break;
}
static void emit_head(request_rec *r, char *header_fname, int suppress_amble,
char *title)
{
- FILE *f;
+ ap_file_t *f;
request_rec *rr = NULL;
int emit_amble = 1;
int emit_H1 = 1;
* the file's contents, any HTML header it had won't end up
* where it belongs.
*/
- if ((f = ap_pfopen(r->pool, rr->filename, "r")) != 0) {
+ if (ap_open(r->pool, rr->filename, APR_READ | APR_BUFFERED,
+ APR_OS_DEFAULT, &f) == APR_SUCCESS) {
emit_preamble(r, title);
emit_amble = 0;
do_emit_plain(r, f);
- ap_pfclose(r->pool, f);
+ ap_close(f);
emit_H1 = 0;
}
}
*/
static void emit_tail(request_rec *r, char *readme_fname, int suppress_amble)
{
- FILE *f;
+ ap_file_t *f;
request_rec *rr = NULL;
int suppress_post = 0;
int suppress_sig = 0;
/*
* If we can open the file, suppress the signature.
*/
- if ((f = ap_pfopen(r->pool, rr->filename, "r")) != 0) {
+ if (ap_open(r->pool, rr->filename, APR_READ | APR_BUFFERED,
+ APR_OS_DEFAULT, &f) == APR_SUCCESS) {
do_emit_plain(r, f);
- ap_pfclose(r->pool, f);
+ ap_close(f);
suppress_sig = 1;
}
}
static char *find_title(request_rec *r)
{
char titlebuf[MAX_STRING_LEN], *find = "<TITLE>";
- FILE *thefile = NULL;
+ ap_file_t *thefile = NULL;
int x, y, n, p;
if (r->status != HTTP_OK) {
"text/html")
|| !strcmp(r->content_type, INCLUDES_MAGIC_TYPE))
&& !r->content_encoding) {
- if (!(thefile = ap_pfopen(r->pool, r->filename, "r"))) {
+ if (ap_open(r->pool, r->filename, APR_READ | APR_BUFFERED,
+ APR_OS_DEFAULT, &thefile) != APR_SUCCESS) {
return NULL;
}
- n = fread(titlebuf, sizeof(char), MAX_STRING_LEN - 1, thefile);
+ n = sizeof(char) * (MAX_STRING_LEN - 1);
+ ap_read(thefile, titlebuf, &n);
if (n <= 0) {
- ap_pfclose(r->pool, thefile);
+ ap_close(thefile);
return NULL;
}
titlebuf[n] = '\0';
}
}
}
- ap_pfclose(r->pool, thefile);
+ ap_close(thefile);
return ap_pstrdup(r->pool, &titlebuf[x]);
}
}
p = 0;
}
}
- ap_pfclose(r->pool, thefile);
+ ap_close(thefile);
}
return NULL;
}
char *title_endp;
char *name = r->filename;
- DIR *d;
- struct DIR_TYPE *dstruct;
+ ap_dir_t *d;
int num_ent = 0, x;
struct ent *head, *p;
struct ent **ar = NULL;
char keyid;
char direction;
- if (!(d = ap_popendir(r->pool, name))) {
+ if (ap_opendir(r->pool, name, &d) != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
"Can't open directory for index: %s", r->filename);
return HTTP_FORBIDDEN;
ap_send_http_header(r);
if (r->header_only) {
- ap_pclosedir(r->pool, d);
+ ap_closedir(d);
return 0;
}
* linked list and then arrayificate them so qsort can use them.
*/
head = NULL;
- while ((dstruct = readdir(d))) {
- p = make_autoindex_entry(dstruct->d_name, autoindex_opts,
+ while (ap_readdir(d)) {
+ char *d_name;
+ ap_get_dir_filename(d, &d_name);
+ p = make_autoindex_entry(d_name, autoindex_opts,
autoindex_conf, r, keyid, direction);
if (p != NULL) {
p->next = head;
}
output_directories(ar, num_ent, autoindex_conf, r, autoindex_opts, keyid,
direction);
- ap_pclosedir(r->pool, d);
+ ap_closedir(d);
if (autoindex_opts & FANCY_INDEXING) {
ap_rputs("<HR>\n", r);
static int default_handler(request_rec *r)
{
core_dir_config *d =
- (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module);
+ (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module);
int rangestatus, errstatus;
- APRFile fd; /* Abstract out File descriptors. */
+ ap_file_t *fd = NULL;
+ int fd_os;
#ifdef USE_MMAP_FILES
caddr_t mm;
#endif
return METHOD_NOT_ALLOWED;
}
-#if defined(OS2) || defined(WIN32)
- /* Need binary mode for OS/2 */
- fd = ap_popenf(r->pool, r->filename, O_RDONLY | O_BINARY, 0);
-#else
- fd = ap_popenf(r->pool, r->filename, O_RDONLY, 0);
-#endif
-
- if (fd == -1) {
+ if (ap_open (r->pool, r->filename, APR_READ | APR_BINARY, 0, &fd) != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
"file permissions deny server access: %s", r->filename);
return FORBIDDEN;
}
+ else
+ ap_get_os_file (fd, &fd_os);
ap_update_mtime(r, r->finfo.st_mtime);
ap_set_last_modified(r);
ap_table_setn(r->headers_out, "Accept-Ranges", "bytes");
if (((errstatus = ap_meets_conditions(r)) != OK)
|| (errstatus = ap_set_content_length(r, r->finfo.st_size))) {
- ap_pclosef(r->pool, fd);
+ ap_close(fd);
return errstatus;
}
/* we need to protect ourselves in case we die while we've got the
* file mmapped */
mm = mmap(NULL, r->finfo.st_size, PROT_READ, MAP_PRIVATE,
- fd, 0);
+ fd_os, 0);
if (mm == (caddr_t)-1) {
ap_log_rerror(APLOG_MARK, APLOG_CRIT, r,
"default_handler: mmap failed: %s", r->filename);
convert_flag = ap_checkconv(r);
if (d->content_md5 & 1) {
ap_table_setn(r->headers_out, "Content-MD5",
- ap_md5digest(r->pool, fd, convert_flag));
+ ap_md5digest(r->pool, fd_os, convert_flag));
}
#else
if (d->content_md5 & 1) {
ap_table_setn(r->headers_out, "Content-MD5",
- ap_md5digest(r->pool, fd));
+ ap_md5digest(r->pool, fd_os));
}
#endif /* CHARSET_EBCDIC */
if (!r->header_only) {
if (!rangestatus) {
- ap_send_fd(fd, r);
+ ap_send_fd(fd_os, r);
}
else {
- long offset, length;
+ long length;
+ ap_off_t offset;
+
while (ap_each_byterange(r, &offset, &length)) {
- /* ZZZ change to AP func */
- if (lseek(fd, offset, SEEK_SET) == -1) {
+ if (ap_seek(fd, APR_SET, &offset) != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_ERR, r->server,
"error byteserving file: %s", r->filename);
- ap_pclosef(r->pool, fd);
+ ap_close(fd);
return HTTP_INTERNAL_SERVER_ERROR;
}
- ap_send_fd_length(fd, r, length);
+ ap_send_fd_length(fd_os, r, length);
}
}
}
}
#endif
- ap_pclosef(r->pool, fd);
+ ap_close(fd);
return OK;
}
/*
* Send the body of a response to the client.
*/
-API_EXPORT(long) ap_send_fd(APRFile fd, request_rec *r)
+API_EXPORT(long) ap_send_fd(int fd, request_rec *r)
{
return ap_send_fd_length(fd, r, -1);
}
-API_EXPORT(long) ap_send_fd_length(APRFile fd, request_rec *r, long length)
+API_EXPORT(long) ap_send_fd_length(int fd, request_rec *r, long length)
{
char buf[IOBUFSIZE];
long total_bytes_sent = 0;
module MODULE_VAR_EXPORT config_log_module;
-static int xfer_flags = (O_WRONLY | O_APPEND | O_CREAT);
+static int xfer_flags = (APR_WRITE | APR_APPEND | APR_CREATE);
#if defined(OS2) || defined(WIN32)
/* OS/2 dosen't support users and groups */
static mode_t xfer_mode = (S_IREAD | S_IWRITE);
#else
-static mode_t xfer_mode = (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+static mode_t xfer_mode = (APR_UREAD | APR_UWRITE | APR_GREAD | APR_WREAD);
#endif
/* POSIX.1 defines PIPE_BUF as the maximum number of bytes that is
* be NULL, which means this module does no logging for this
* request. format might be NULL, in which case the default_format
* from the multi_log_state should be used, or if that is NULL as
- * well, use the CLF. log_fd is -1 before the log file is opened and
+ * well, use the CLF. log_fd is NULL before the log file is opened and
* set to a valid fd after it is opened.
*/
char *fname;
char *format_string;
ap_array_header_t *format;
- int log_fd;
+ ap_file_t *log_fd;
char *condition_var;
#ifdef BUFFERED_LOGS
int outcnt;
#ifdef BUFFERED_LOGS
static void flush_log(config_log_state *cls)
{
- if (cls->outcnt && cls->log_fd != -1) {
- write(cls->log_fd, cls->outbuf, cls->outcnt);
+ if (cls->outcnt && cls->log_fd != NULL) {
+ ap_write(cls->log_fd, cls->outbuf, cls->outcnt);
cls->outcnt = 0;
}
}
memcpy(s, strs[i], strl[i]);
s += strl[i];
}
- write(cls->log_fd, str, len);
+ ap_write(cls->log_fd, str, len);
}
else {
for (i = 0, s = &cls->outbuf[cls->outcnt]; i < format->nelts; ++i) {
s += strl[i];
}
- write(cls->log_fd, str, len);
+ ap_write(cls->log_fd, str, &len);
#endif
return OK;
else {
cls->format = parse_log_string(cmd->pool, fmt, &err_string);
}
- cls->log_fd = -1;
+ cls->log_fd = NULL;
return err_string;
}
config_log_state *cls,
ap_array_header_t *default_format)
{
- if (cls->log_fd > 0) {
+ if (cls->log_fd != NULL) {
return cls; /* virtual config shared w/main server */
}
}
else {
const char *fname = ap_server_root_relative(p, cls->fname);
- if ((cls->log_fd = ap_popenf(p, fname, xfer_flags, xfer_mode)) < 0) {
+ if (ap_open(p, fname, xfer_flags, xfer_mode, &cls->log_fd) != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_ERR, s,
"could not open transfer log file %s.", fname);
exit(1);
header_eof, header_seen, header_sep
};
-static enum header_state get_header_line(char *buffer, int len, FILE *map)
+static enum header_state get_header_line(char *buffer, int len, ap_file_t *map)
{
char *buf_end = buffer + len;
char *cp;
- int c;
+ char c;
/* Get a noncommented line */
do {
- if (fgets(buffer, MAX_STRING_LEN, map) == NULL) {
+ if (ap_gets(map, buffer, MAX_STRING_LEN) != APR_SUCCESS) {
return header_eof;
}
} while (buffer[0] == '#');
cp += strlen(cp);
- while ((c = getc(map)) != EOF) {
+ while (ap_getc(map, &c) != APR_EOF) {
if (c == '#') {
/* Comment line */
- while ((c = getc(map)) != EOF && c != '\n') {
+ while (ap_getc(map, &c) != EOF && c != '\n') {
continue;
}
}
*/
while (c != EOF && c != '\n' && ap_isspace(c)) {
- c = getc(map);
+ ap_getc(map, &c);
}
- ungetc(c, map);
+ ap_ungetc(map, c);
if (c == '\n') {
return header_seen; /* Blank line */
/* Continuation */
- while (cp < buf_end - 2 && (c = getc(map)) != EOF && c != '\n') {
+ while (cp < buf_end - 2 && (ap_getc(map, &c)) != EOF && c != '\n') {
*cp++ = c;
}
/* Line beginning with something other than whitespace */
- ungetc(c, map);
+ ap_ungetc(map, c);
return header_seen;
}
}
static int read_type_map(negotiation_state *neg, request_rec *rr)
{
request_rec *r = neg->r;
- FILE *map;
+ ap_file_t *map;
char buffer[MAX_STRING_LEN];
enum header_state hstate;
struct var_rec mime_info;
/* We are not using multiviews */
neg->count_multiviews_variants = 0;
- map = ap_pfopen(neg->pool, rr->filename, "r");
- if (map == NULL) {
+ if (ap_open(neg->pool, rr->filename, APR_READ | APR_BUFFERED,
+ APR_OS_DEFAULT, &map) != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
"cannot access type map file: %s", rr->filename);
return HTTP_FORBIDDEN;
}
} while (hstate != header_eof);
- ap_pfclose(neg->pool, map);
+ ap_close(map);
set_vlist_validator(r, rr);
char *filp;
int prefix_len;
- DIR *dirp;
- struct DIR_TYPE *dir_entry;
+ ap_dir_t *dirp;
struct var_rec mime_info;
struct accept_rec accept_info;
void *new_var;
++filp;
prefix_len = strlen(filp);
- dirp = ap_popendir(neg->pool, neg->dir_name);
-
- if (dirp == NULL) {
+ if (ap_opendir(neg->pool, neg->dir_name, &dirp) != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
"cannot read directory for multi: %s", neg->dir_name);
return HTTP_FORBIDDEN;
}
- while ((dir_entry = readdir(dirp))) {
+ while (ap_readdir(dirp) == APR_SUCCESS) {
request_rec *sub_req;
+ char *d_name;
+ ap_get_dir_filename(dirp, &d_name);
/* Do we have a match? */
- if (strncmp(dir_entry->d_name, filp, prefix_len)) {
+ if (strncmp(d_name, filp, prefix_len)) {
continue;
}
- if (dir_entry->d_name[prefix_len] != '.') {
+ if (d_name[prefix_len] != '.') {
continue;
}
* which we'll be slapping default_type on later).
*/
- sub_req = ap_sub_req_lookup_file(dir_entry->d_name, r);
+ sub_req = ap_sub_req_lookup_file(d_name, r);
/* If it has a handler, we'll pretend it's a CGI script,
* since that's a good indication of the sort of thing it
((sub_req->handler) &&
!strcmp(sub_req->handler, "type-map"))) {
- ap_pclosedir(neg->pool, dirp);
+ ap_closedir(dirp);
neg->avail_vars->nelts = 0;
if (sub_req->status != HTTP_OK) {
return sub_req->status;
/* Have reasonable variant --- gather notes. */
mime_info.sub_req = sub_req;
- mime_info.file_name = ap_pstrdup(neg->pool, dir_entry->d_name);
+ mime_info.file_name = ap_pstrdup(neg->pool, d_name);
if (sub_req->content_encoding) {
mime_info.content_encoding = sub_req->content_encoding;
}
clean_var_rec(&mime_info);
}
- ap_pclosedir(neg->pool, dirp);
+ ap_closedir(dirp);
set_vlist_validator(r, r);
#define CORE_PRIVATE
+#include "apr_portable.h"
#include "httpd.h"
#include "http_config.h"
#include "http_core.h"
static server_rec *init_server_config(ap_context_t *p)
{
+ int errfile = STDERR_FILENO;
server_rec *s = (server_rec *) ap_pcalloc(p, sizeof(server_rec));
s->port = 0;
s->server_admin = DEFAULT_ADMIN;
s->server_hostname = NULL;
s->error_fname = DEFAULT_ERRORLOG;
- s->error_log = stderr;
+ ap_put_os_file(p, &s->error_log, &errfile);
s->loglevel = DEFAULT_LOGLEVEL;
s->srm_confname = RESOURCE_CONFIG_FILE;
s->access_confname = ACCESS_CONFIG_FILE;
*
*/
+#include "apr_network_io.h"
#include "httpd.h"
#include "http_config.h"
#include "ap_listen.h"
static int send_buffer_size;
/* TODO: make_sock is just begging and screaming for APR abstraction */
-static int make_sock(const struct sockaddr_in *server)
+static ap_status_t make_sock(ap_context_t *p, ap_listen_rec *server)
{
- int s;
+ ap_socket_t *s = server->sd;
int one = 1;
char addr[512];
+ ap_status_t stat;
- if (server->sin_addr.s_addr != htonl(INADDR_ANY))
- ap_snprintf(addr, sizeof(addr), "address %s port %d",
- inet_ntoa(server->sin_addr), ntohs(server->sin_port));
- else
- ap_snprintf(addr, sizeof(addr), "port %d", ntohs(server->sin_port));
-
-#ifdef WIN32
- s = WSASocket(AF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, 0, WSA_FLAG_OVERLAPPED);
- if (s == INVALID_SOCKET) {
- ap_log_error(APLOG_MARK, APLOG_CRIT, NULL,
- "make_sock: failed to get a socket for %s", addr);
- return -1;
- }
-#else
- if ((s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) {
- ap_log_error(APLOG_MARK, APLOG_CRIT, NULL,
- "make_sock: failed to get a socket for %s", addr);
- return -1;
- }
-#endif
-
-#ifdef SO_REUSEADDR
- if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *) &one, sizeof(int)) < 0) {
+ stat = ap_setsocketopt(s, APR_SO_REUSEADDR, one);
+ if (stat != APR_SUCCESS && stat != APR_ENOTIMPL) {
ap_log_error(APLOG_MARK, APLOG_CRIT, NULL,
"make_sock: for %s, setsockopt: (SO_REUSEADDR)", addr);
- close(s);
- return -1;
+ ap_close_socket(s);
+ return stat;
}
-#endif
- one = 1;
-#ifdef SO_KEEPALIVE
- if (setsockopt(s, SOL_SOCKET, SO_KEEPALIVE, (char *) &one, sizeof(int)) < 0) {
+
+ stat = ap_setsocketopt(s, APR_SO_KEEPALIVE, one);
+ if (stat != APR_SUCCESS && stat != APR_ENOTIMPL) {
ap_log_error(APLOG_MARK, APLOG_CRIT, NULL,
"make_sock: for %s, setsockopt: (SO_KEEPALIVE)", addr);
- close(s);
- return -1;
+ ap_close_socket(s);
+ return stat;
}
-#endif
/*
* To send data over high bandwidth-delay connections at full
*
* If no size is specified, use the kernel default.
*/
-#ifdef SO_SNDBUF
if (send_buffer_size) {
- if (setsockopt(s, SOL_SOCKET, SO_SNDBUF,
- (char *) &send_buffer_size, sizeof(int)) < 0) {
- ap_log_error(APLOG_MARK, APLOG_WARNING, NULL,
+ stat = ap_setsocketopt(s, SO_SNDBUF, send_buffer_size);
+ if (stat != APR_SUCCESS && stat != APR_ENOTIMPL) {
+ ap_log_error(APLOG_MARK, APLOG_WARNING, NULL,
"make_sock: failed to set SendBufferSize for %s, "
"using default", addr);
/* not a fatal error */
}
}
-#endif
- if (bind(s, (struct sockaddr *) server, sizeof(struct sockaddr_in)) == -1) {
+ if ((stat = ap_bind(s)) != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_CRIT, NULL,
"make_sock: could not bind to %s", addr);
- close(s);
- return -1;
+ ap_close_socket(s);
+ return stat;
}
- if (listen(s, ap_listenbacklog) == -1) {
+ if ((stat = ap_listen(s, ap_listenbacklog)) != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_ERR, NULL,
"make_sock: unable to listen for connections on %s", addr);
- close(s);
- return -1;
+ ap_close_socket(s);
+ return stat;
}
- return s;
+ server->sd = s;
+ return APR_SUCCESS;
}
ap_listen_rec *lr;
for (lr = ap_listeners; lr; lr = lr->next) {
- close(lr->fd);
+ ap_close_socket(lr->sd);
}
return APR_SUCCESS;
}
-static void alloc_listener(struct sockaddr_in *local_addr)
+static void alloc_listener(char *addr, unsigned int port)
{
ap_listen_rec **walk;
ap_listen_rec *new;
+ char *oldaddr;
+ unsigned int oldport;
/* see if we've got an old listener for this address:port */
for (walk = &old_listeners; *walk; walk = &(*walk)->next) {
- if (!memcmp(&(*walk)->local_addr, local_addr, sizeof(local_addr))) {
+ ap_getport((*walk)->sd, &oldport);
+ ap_getipaddr((*walk)->sd, &oldaddr);
+ if (!strcmp(oldaddr, addr) && port == oldport) {
/* re-use existing record */
new = *walk;
*walk = new->next;
/* this has to survive restarts */
new = malloc(sizeof(ap_listen_rec));
- new->local_addr = *local_addr;
- new->fd = -1;
+ if (ap_create_tcp_socket(NULL, &new->sd) != APR_SUCCESS) {
+ ap_log_error(APLOG_MARK, APLOG_CRIT, NULL,
+ "make_sock: failed to get a socket for %s", addr);
+ return;
+ }
+ ap_setport(new->sd, port);
+ ap_setipaddr(new->sd, addr);
new->next = ap_listeners;
ap_listeners = new;
}
ap_listen_rec *lr;
ap_listen_rec *next;
int num_open;
- struct sockaddr_in local_addr;
-
+ ap_status_t stat;
/* allocate a default listener if necessary */
if (ap_listeners == NULL) {
- local_addr.sin_family = AF_INET;
- local_addr.sin_addr.s_addr = htonl(INADDR_ANY); /* XXX */
- local_addr.sin_port = htons(port ? port : DEFAULT_HTTP_PORT);
- alloc_listener(&local_addr);
+ alloc_listener(APR_ANYADDR, port ? port : DEFAULT_HTTP_PORT);
}
num_open = 0;
for (lr = ap_listeners; lr; lr = lr->next) {
- if (lr->fd < 0) {
- lr->fd = make_sock(&lr->local_addr);
- }
- if (lr->fd >= 0) {
+ stat = make_sock(pconf, lr);
+ if (stat == APR_SUCCESS) {
++num_open;
}
}
/* close the old listeners */
for (lr = old_listeners; lr; lr = next) {
- close(lr->fd);
+ ap_close_socket(lr->sd);
next = lr->next;
- free(lr);
+/* free(lr);*/
}
old_listeners = NULL;
{
char *ports;
unsigned short port;
- struct sockaddr_in local_addr;
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
if (err != NULL) {
ports = ips;
}
- local_addr.sin_family = AF_INET;
- if (ports == ips) { /* no address */
- local_addr.sin_addr.s_addr = htonl(INADDR_ANY);
- }
- else {
- local_addr.sin_addr.s_addr = ap_get_virthost_addr(ips, NULL);
- }
port = atoi(ports);
if (!port) {
return "Port must be numeric";
}
- local_addr.sin_port = htons(port);
- alloc_listener(&local_addr);
+ if (ports == ips) { /* no address */
+ alloc_listener(APR_ANYADDR, port);
+ }
+ else {
+ ips[(ports - ips) - 1] = '\0';
+ alloc_listener(ips, port);
+ }
return NULL;
}
#define CORE_PRIVATE
#include "apr_lib.h"
+#include "apr_portable.h"
#include "httpd.h"
#include "http_config.h"
#include "http_core.h"
if (*s->error_fname == '|') {
FILE *dummy;
+ int dummyno;
#ifdef TPF
TPF_FORK_CHILD cld;
cld.filename = s->error_fname+1;
exit(1);
}
- s->error_log = dummy;
+ dummyno = fileno(dummy);
+ ap_put_os_file(p, &s->error_log, &dummyno);
}
#ifdef HAVE_SYSLOG
else {
fname = ap_server_root_relative(p, s->error_fname);
/* Change to AP funcs. */
- if (!(s->error_log = ap_pfopen(p, fname, "a"))) {
+ if (ap_open(p, fname, APR_BUFFERED | APR_APPEND | APR_READ | APR_WRITE,
+ APR_OS_DEFAULT, &s->error_log) != APR_SUCCESS) {
perror("fopen");
fprintf(stderr, "%s: could not open error log file %s.\n",
ap_server_argv0, fname);
{
server_rec *virt, *q;
int replace_stderr;
+ int errfile;
open_error_log(s_main, p);
if (s_main->error_log) {
/* replace stderr with this new log */
fflush(stderr);
- if (dup2(fileno(s_main->error_log), STDERR_FILENO) == -1) {
+ ap_get_os_file(s_main->error_log, &errfile);
+ if (dup2(errfile, STDERR_FILENO) == -1) {
ap_log_error(APLOG_MARK, APLOG_CRIT, s_main,
"unable to replace stderr with error_log");
} else {
}
API_EXPORT(void) ap_error_log2stderr(server_rec *s) {
+ int errfile;
+
+ ap_get_os_file(s->error_log, &errfile);
if ( s->error_log != NULL
- && fileno(s->error_log) != STDERR_FILENO)
- dup2(fileno(s->error_log), STDERR_FILENO);
+ && errfile != STDERR_FILENO)
+ dup2(errfile, STDERR_FILENO);
}
static void log_error_core(const char *file, int line, int level,
size_t len;
/* change to AP errno funcs. */
int save_errno = errno;
- FILE *logf;
+ ap_file_t *logf = NULL;
+ int errfileno = STDERR_FILENO;
if (s == NULL) {
/*
if (((level & APLOG_LEVELMASK) != APLOG_NOTICE) &&
((level & APLOG_LEVELMASK) > DEFAULT_LOGLEVEL))
return;
- logf = stderr;
+ ap_put_os_file(NULL, &logf, &errfileno);
}
else if (s->error_log) {
/*
if (logf) {
/* ZZZ let's just use AP funcs to Write to the error log. If failure,
can we output a message to the console??? */
- fputs(errstr, logf);
- fputc('\n', logf);
- fflush(logf);
+ ap_puts(logf, errstr);
+ ap_putc(logf, '\n');
+ ap_flush(logf);
}
#ifdef HAVE_SYSLOG
else {
* that may screw up scripts written to do something
* based on the last modification time of the pid file.
*/
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, NULL,
- ap_psprintf(p,
- "pid file %s overwritten -- Unclean shutdown of previous Apache run?",
- fname)
- );
+ ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, NULL,
+ ap_psprintf(p,
+ "pid file %s overwritten -- Unclean shutdown of previous Apache run?",
+ fname)
+ );
}
if(!(pid_file = fopen(fname, "w"))) {
kill(pl->pid, SIGTERM);
}
ap_unregister_other_child(pl);
- close(pl->fds[0]);
- close(pl->fds[1]);
+ ap_close(pl->fds[0]);
+ ap_close(pl->fds[1]);
}
{
piped_log *pl = data;
- close(pl->fds[0]);
- close(pl->fds[1]);
+ ap_close(pl->fds[0]);
+ ap_close(pl->fds[1]);
}
pl->p = p;
pl->program = ap_pstrdup(p, program);
pl->pid = -1;
- if (pipe(pl->fds) == -1) {
+ if (ap_create_pipe(p, &pl->fds[0], &pl->fds[1]) != APR_SUCCESS) {
int save_errno = errno;
errno = save_errno;
return NULL;
if (piped_log_spawn(pl) == -1) {
int save_errno = errno;
ap_kill_cleanup(p, pl, piped_log_cleanup);
- close(pl->fds[0]);
- close(pl->fds[1]);
+ ap_close(pl->fds[0]);
+ ap_close(pl->fds[1]);
errno = save_errno;
return NULL;
}
{
piped_log *pl;
FILE *dummy;
+ int dummyno;
#ifdef TPF
TPF_FORK_CHILD cld;
cld.filename = (char *)program;
}
pl = ap_palloc(p, sizeof (*pl));
pl->p = p;
- pl->write_f = dummy;
+ dummyno = fileno(dummy);
+ ap_put_os_file(p, &pl->write_f, &dummyno);
return pl;
}
API_EXPORT(void) ap_close_piped_log(piped_log *pl)
{
- ap_pfclose(pl->p, pl->write_f);
+ ap_close(pl->write_f);
}
#endif
#define CORE_PRIVATE
+#include "apr_portable.h"
#include "httpd.h"
#include "http_main.h"
#include "http_log.h"
{
ap_listen_rec *lr;
int num_listeners = 0;
-
if (ap_listen_open(pconf, s->port)) {
return 0;
}
int thread_slot = ti->tid;
ap_context_t *tpool = ti->tpool;
struct sockaddr sa_client;
- int csd = -1;
+ ap_socket_t *csd = NULL;
ap_context_t *ptrans; /* Pool for per-transaction stuff */
- int sd = -1;
+ ap_socket_t *sd = NULL;
int srv;
int curr_pollfd, last_pollfd = 0;
- size_t len = sizeof(struct sockaddr);
+ int thesock;
free(ti);
}
if (num_listenfds == 1) {
- sd = ap_listeners->fd;
+ sd = ap_listeners->sd;
goto got_fd;
}
else {
/* XXX: Should we check for POLLERR? */
if (listenfds[curr_pollfd].revents & POLLIN) {
last_pollfd = curr_pollfd;
- sd = listenfds[curr_pollfd].fd;
+ ap_put_os_sock(tpool, &sd, &listenfds[curr_pollfd].fd);
goto got_fd;
}
} while (curr_pollfd != last_pollfd);
}
got_fd:
if (!workers_may_exit) {
- csd = ap_accept(sd, &sa_client, &len);
+ ap_accept(sd, &csd);
SAFE_ACCEPT(accept_mutex_off(0));
SAFE_ACCEPT(intra_mutex_off(0));
}
SAFE_ACCEPT(intra_mutex_off(0));
break;
}
- process_socket(ptrans, &sa_client, csd, process_slot, thread_slot);
+ ap_get_os_sock(csd, &thesock);
+ process_socket(ptrans, &sa_client, thesock, process_slot, thread_slot);
ap_clear_pool(ptrans);
requests_this_child--;
}
listenfds[0].events = POLLIN;
listenfds[0].revents = 0;
for (lr = ap_listeners, i = 1; i <= num_listenfds; lr = lr->next, ++i) {
- listenfds[i].fd = lr->fd;
+ ap_get_os_sock(lr->sd, &listenfds[i].fd);
listenfds[i].events = POLLIN; /* should we add POLLPRI ?*/
listenfds[i].revents = 0;
}
"pipe: (pipe_of_death)");
exit(1);
}
+/* XXXXXX Removed because these functions don't exist anymore. When
+ These pipes are changed to apr_types, these functions won't be needed
+ anyway.
ap_note_cleanups_for_fd(pconf, pipe_of_death[0]);
ap_note_cleanups_for_fd(pconf, pipe_of_death[1]);
+*/
+
if (fcntl(pipe_of_death[0], F_SETFD, O_NONBLOCK) == -1) {
ap_log_error(APLOG_MARK, APLOG_ERR,
(const server_rec*) server_conf,
}
set_signals();
-
/* Don't thrash... */
if (max_spare_threads < min_spare_threads + ap_threads_per_child)
max_spare_threads = min_spare_threads + ap_threads_per_child;
#define CORE_PRIVATE
+#include "apr_portable.h"
#include "httpd.h"
#include "mpm_default.h"
#include "http_main.h"
/* *Non*-shared http_main globals... */
static server_rec *server_conf;
-static int sd;
+static ap_socket_t *sd;
static fd_set listenfds;
static int listenmaxfd;
*/
static void accept_mutex_init(ap_context_t *p)
{
-
+ ap_file_t *tempfile;
lock_it.l_whence = SEEK_SET; /* from current point */
lock_it.l_start = 0; /* -"- */
lock_it.l_len = 0; /* until end of file */
unlock_it.l_pid = 0; /* pid not actually interesting */
expand_lock_fname(p);
- lock_fd = ap_popenf(p, ap_lock_fname, O_CREAT | O_WRONLY | O_EXCL, 0644);
+ ap_open(p, ap_lock_fname, APR_CREATE | APR_WRITE | APR_EXCL,
+ APR_UREAD | APR_UWRITE | APR_GREAD | APR_WREAD, &tempfile);
+ ap_get_os_file(tempfile, &lock_fd);
if (lock_fd == -1) {
perror("open");
fprintf(stderr, "Cannot open lock file: %s\n", ap_lock_fname);
*/
static int srv;
-static int csd;
+static ap_socket_t *csd;
static int requests_this_child;
static fd_set main_fds;
ap_context_t *ptrans;
conn_rec *current_conn;
ap_iol *iol;
+ ap_status_t stat;
+ int sockdes;
my_pid = getpid();
- csd = -1;
+ csd = NULL;
my_child_num = child_num_arg;
requests_this_child = 0;
last_lr = NULL;
}
first_lr=lr;
do {
- if (FD_ISSET(lr->fd, &main_fds))
+ ap_get_os_sock(lr->sd, &sockdes);
+ if (FD_ISSET(sockdes, &main_fds))
goto got_listener;
lr = lr->next;
if (!lr)
continue;
got_listener:
last_lr = lr;
- sd = lr->fd;
+ sd = lr->sd;
}
else {
/* only one socket, just pretend we did the other stuff */
- sd = ap_listeners->fd;
+ sd = ap_listeners->sd;
}
/* if we accept() something we don't want to die, so we have to
clean_child_exit(0);
}
clen = sizeof(sa_client);
- csd = ap_accept(sd, &sa_client, &clen);
- if (csd >= 0 || errno != EINTR)
+ stat = ap_accept(sd, &csd);
+ if (stat == APR_SUCCESS || stat != APR_EINTR)
break;
}
- if (csd >= 0)
+ if (stat == APR_SUCCESS)
break; /* We have a socket ready for reading */
else {
* socket options, file descriptors, and read/write buffers.
*/
+ ap_get_os_sock(csd, &sockdes);
+
clen = sizeof(sa_server);
- if (getsockname(csd, &sa_server, &clen) < 0) {
+ if (getsockname(sockdes, &sa_server, &clen) < 0) {
ap_log_error(APLOG_MARK, APLOG_ERR, server_conf, "getsockname");
- close(csd);
+ ap_close_socket(csd);
continue;
}
- sock_disable_nagle(csd);
+ sock_disable_nagle(sockdes);
- iol = unix_attach_socket(csd);
+ iol = unix_attach_socket(sockdes);
if (iol == NULL) {
if (errno == EBADF) {
ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, NULL,
"filedescriptor (%u) larger than FD_SETSIZE (%u) "
"found, you probably need to rebuild Apache with a "
- "larger FD_SETSIZE", csd, FD_SETSIZE);
+ "larger FD_SETSIZE", sockdes, FD_SETSIZE);
}
else {
ap_log_error(APLOG_MARK, APLOG_WARNING, NULL,
"error attaching to socket");
}
- close(csd);
+ ap_close_socket(csd);
continue;
}
static int setup_listeners(ap_context_t *p, server_rec *s)
{
ap_listen_rec *lr;
+ int sockdes;
if (ap_listen_open(p, s->port)) {
ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ALERT, s,
listenmaxfd = -1;
FD_ZERO(&listenfds);
for (lr = ap_listeners; lr; lr = lr->next) {
- FD_SET(lr->fd, &listenfds);
- if (lr->fd > listenmaxfd) {
- listenmaxfd = lr->fd;
+ ap_get_os_sock(lr->sd, &sockdes);
+ FD_SET(sockdes, &listenfds);
+ if (sockdes > listenmaxfd) {
+ listenmaxfd = sockdes;
}
}
return 0;
pconf = _pconf;
server_conf = s;
-
+
ap_log_pid(pconf, ap_pid_fname);
if (setup_listeners(pconf, s)) {
#include "http_log.h" /* for aplog_error */
#include "rfc1413.h"
#include "http_main.h" /* set_callback_and_alarm */
+#include "apr_network_io.h"
/* Local stuff. */
/* Semi-well-known port */
/* bind_connect - bind both ends of a socket */
/* Ambarish fix this. Very broken */
-static int get_rfc1413(int sock, const struct sockaddr_in *our_sin,
- const struct sockaddr_in *rmt_sin,
+static int get_rfc1413(ap_socket_t *sock, const char *local_ip,
+ const char *rmt_ip,
char user[RFC1413_USERLEN+1], server_rec *srv)
{
- struct sockaddr_in rmt_query_sin, our_query_sin;
unsigned int rmt_port, our_port;
+ unsigned int sav_rmt_port, sav_our_port;
int i;
char *cp;
char buffer[RFC1413_MAXDATA + 1];
* addresses from the query socket.
*/
- our_query_sin = *our_sin;
- our_query_sin.sin_port = htons(ANY_PORT);
- rmt_query_sin = *rmt_sin;
- rmt_query_sin.sin_port = htons(RFC1413_PORT);
+ ap_setport(sock, ANY_PORT);
+ ap_setipaddr(sock, local_ip);
- if (bind(sock, (struct sockaddr *) &our_query_sin,
- sizeof(struct sockaddr_in)) < 0) {
+ if (ap_bind(sock) != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_CRIT, srv,
"bind: rfc1413: Error binding to local port");
return -1;
}
+ ap_getport(sock, &sav_our_port);
/*
* errors from connect usually imply the remote machine doesn't support
* the service
*/
- if (connect(sock, (struct sockaddr *) &rmt_query_sin,
- sizeof(struct sockaddr_in)) < 0)
- return -1;
+ ap_setport(sock, RFC1413_PORT);
+ ap_setipaddr(sock, rmt_ip);
+
+ if (ap_connect(sock, NULL) != APR_SUCCESS)
+ return -1;
+ ap_getport(sock, &sav_rmt_port);
/* send the data */
- buflen = ap_snprintf(buffer, sizeof(buffer), "%u,%u\r\n", ntohs(rmt_sin->sin_port),
- ntohs(our_sin->sin_port));
+ buflen = ap_snprintf(buffer, sizeof(buffer), "%u,%u\r\n", sav_rmt_port,
+ sav_our_port);
/* send query to server. Handle short write. */
#ifdef CHARSET_EBCDIC
#endif
i = 0;
while(i < strlen(buffer)) {
- int j;
- j = write(sock, buffer+i, (strlen(buffer+i)));
- if (j < 0 && errno != EINTR) {
+ int j = strlen(buffer + i);
+ ap_status_t stat;
+ stat = ap_send(sock, buffer+i, &j);
+ if (stat != APR_SUCCESS && stat != APR_EINTR) {
ap_log_error(APLOG_MARK, APLOG_CRIT, srv,
"write: rfc1413: error sending request");
return -1;
* this allows it to work on both ASCII and EBCDIC machines.
*/
while((cp = strchr(buffer, '\012')) == NULL && i < sizeof(buffer) - 1) {
- int j;
- j = read(sock, buffer+i, (sizeof(buffer) - 1) - i);
- if (j < 0 && errno != EINTR) {
+ int j = sizeof(buffer) - 1 - i;
+ ap_status_t stat;
+ stat = ap_recv(sock, buffer+i, &j);
+ if (stat != APR_SUCCESS && stat != APR_EINTR) {
ap_log_error(APLOG_MARK, APLOG_CRIT, srv,
"read: rfc1413: error reading response");
return -1;
ascii2ebcdic(&buffer, &buffer, (size_t)i);
#endif
if (sscanf(buffer, "%u , %u : USERID :%*[^:]:%512s", &rmt_port, &our_port,
- user) != 3 || ntohs(rmt_sin->sin_port) != rmt_port
- || ntohs(our_sin->sin_port) != our_port)
+ user) != 3 || sav_rmt_port != rmt_port
+ || sav_our_port != our_port)
return -1;
/*
{
static char user[RFC1413_USERLEN + 1]; /* XXX */
static char *result;
- static int sock;
+ static ap_socket_t *sock;
result = FROM_UNKNOWN;
- sock = ap_psocket(conn->pool, AF_INET, SOCK_STREAM, IPPROTO_TCP);
- if (sock < 0) {
+ if (ap_create_tcp_socket(conn->pool, &sock) != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_CRIT, srv,
"socket: rfc1413: error creating socket");
conn->remote_logname = result;
*/
if (ap_setjmp(timebuf) == 0) {
- if (get_rfc1413(sock, &conn->local_addr, &conn->remote_addr, user, srv) >= 0)
+ if (get_rfc1413(sock, conn->local_ip, conn->remote_ip, user, srv) >= 0)
result = user;
}
- ap_pclosesocket(conn->pool, sock);
+ ap_close_socket(sock);
conn->remote_logname = result;
return conn->remote_logname;
return (cfp->close == NULL) ? 0 : cfp->close(cfp->param);
}
-/* Common structure that holds the file and ap_context_t for ap_pcfg_openfile */
-typedef struct {
- ap_context_t *pool;
- FILE *file;
-} poolfile_t;
-
-static int cfg_close(void *param)
+static ap_status_t cfg_close(void *param)
{
- poolfile_t *cfp = (poolfile_t *) param;
- return (ap_pfclose(cfp->pool, cfp->file));
+ ap_file_t *cfp = (ap_file_t *) param;
+ return (ap_close(cfp));
}
static int cfg_getch(void *param)
{
- poolfile_t *cfp = (poolfile_t *) param;
- return (fgetc(cfp->file));
+ char ch;
+ ap_file_t *cfp = (ap_file_t *) param;
+ if (ap_getc(cfp, &ch) == APR_SUCCESS)
+ return ch;
+ return (int)EOF;
}
static void *cfg_getstr(void *buf, size_t bufsiz, void *param)
{
- poolfile_t *cfp = (poolfile_t *) param;
- return (fgets(buf, bufsiz, cfp->file));
+ ap_file_t *cfp = (ap_file_t *) param;
+ if (ap_gets(cfp, buf, bufsiz) == APR_SUCCESS)
+ return buf;
+ return NULL;
}
/* 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)
{
configfile_t *new_cfg;
- poolfile_t *new_pfile;
- FILE *file;
- struct stat stbuf;
+ 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, NULL,
return NULL;
}
- /* ZZZ bopenf and use AP defines for flags. */
- file = ap_pfopen(p, name, "r");
+ stat = ap_open(p, name, APR_READ | APR_BUFFERED, APR_OS_DEFAULT, &file);
#ifdef DEBUG
saved_errno = errno;
ap_log_error(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, NULL,
"Opening config file %s (%s)",
- name, (file == NULL) ? strerror(errno) : "successful");
+ name, (stat != APR_SUCCESS) ? strerror(errno) : "successful");
errno = saved_errno;
#endif
- if (file == NULL)
+ if (stat != APR_SUCCESS)
return NULL;
- if (fstat(fileno(file), &stbuf) == 0 &&
- !S_ISREG(stbuf.st_mode) &&
+ if (ap_get_filetype(file, &type) == APR_SUCCESS &&
+ type == APR_REG &&
#if defined(WIN32) || defined(OS2)
!(strcasecmp(name, "nul") == 0 ||
(strlen(name) >= 4 &&
strcasecmp(name + strlen(name) - 4, "/nul") == 0))) {
#else
- strcmp(name, "/dev/null") != 0) {
+ strcmp(name, "/dev/null") == 0) {
#endif /* WIN32 || OS2 */
saved_errno = errno;
ap_log_error(APLOG_MARK, APLOG_ERR | APLOG_NOERRNO, NULL,
"Access to file %s denied by server: not a regular file",
name);
- ap_pfclose(p, file);
+ ap_close(file);
errno = saved_errno;
return NULL;
}
new_cfg = ap_palloc(p, sizeof(*new_cfg));
- new_pfile = ap_palloc(p, sizeof(*new_pfile));
- new_pfile->file = file;
- new_pfile->pool = p;
- new_cfg->param = new_pfile;
+ new_cfg->param = file;
new_cfg->name = ap_pstrdup(p, name);
new_cfg->getch = (int (*)(void *)) cfg_getch;
new_cfg->getstr = (void *(*)(void *, size_t, void *)) cfg_getstr;
/* md5.c --Module Interface to MD5. */
/* Jeff Hostetler, Spyglass, Inc., 1994. */
+#include "apr_portable.h"
#include "httpd.h"
#include "util_md5.h"
#ifdef CHARSET_EBCDIC
-API_EXPORT(char *) ap_md5digest(ap_context_t *p, APRFile infile, int convert)
+API_EXPORT(char *) ap_md5digest(ap_context_t *p, int infile, int convert)
{
AP_MD5_CTX context;
unsigned char buf[1000];
#else
-API_EXPORT(char *) ap_md5digest(ap_context_t *p, APRFile infile)
+API_EXPORT(char *) ap_md5digest(ap_context_t *p, int infile)
{
AP_MD5_CTX context;
unsigned char buf[1000];
char **env, int shellcmd)
{
int pid = 0;
+ int errfileno = STDERR_FILENO;
#if !defined(WIN32) && !defined(OS2)
/* the fd on r->server->error_log is closed, but we need somewhere to
* since that is better than allowing errors to go unnoticed. Don't do
* this on Win32, though, since we haven't fork()'d.
*/
- r->server->error_log = stderr;
+ ap_put_os_file(r->pool, &r->server->error_log, &errfileno);
#endif
/* TODO: all that RLimit stuff should become part of the spawning API,