__attribute__((format(printf,5,6)));
API_EXPORT(void) ap_error_log2stderr (server_rec *);
-void ap_log_pid (pool *p, char *fname);
+void ap_log_pid (pool *p, const char *fname);
/* These are for legacy code, new code should use ap_log_error,
* or ap_log_rerror.
*/
/* Code from Harald Hanche-Olsen <hanche@imf.unit.no> */
+/* ZZZ let's pass the buffer and the host entry so we don't have to allocate
+ another stack frame. */
static ap_inline void do_double_reverse (conn_rec *conn)
{
struct hostent *hptr;
conn->double_reverse = -1;
return;
}
- hptr = gethostbyname(conn->remote_host);
- if (hptr) {
+ hptr = gethostbyname(conn->remote_host); /*ZZZ change to AP func */
+ if (hptr) { /*ZZZ enumerate through host entries */
char **haddr;
for (haddr = hptr->h_addr_list; *haddr; haddr++) {
if (r->method_number == M_PUT) {
return METHOD_NOT_ALLOWED;
}
-
+ /* ZZZ can we store if the file exists or not? */
if (r->finfo.st_mode == 0 || (r->path_info && *r->path_info)) {
ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, r,
"File does not exist: %s",r->path_info ?
((r->proto_num >= HTTP_VERSION(1,1)) &&
(r->chunked = 1))) && /* THIS CODE IS CORRECT, see comment above. */
r->server->keep_alive &&
+ /* ZZZ change to APR keepalive timeout defined value */
(r->server->keep_alive_timeout > 0) &&
((r->server->keep_alive_max == 0) ||
(r->server->keep_alive_max > r->connection->keepalives)) &&
* were given a time in the future, we return the current time - the
* Last-Modified can't be in the future.
*/
+ /* ZZZ Change time call to use time AP time thread functions. */
now = (mtime < r->request_time) ? r->request_time : time(NULL);
return (mtime > now) ? now : mtime;
}
return OK;
}
+ /* ZZZ We are changing time(NULL) to AP time thread functions. */
mtime = (r->mtime != 0) ? r->mtime : time(NULL);
/* If an If-Match request-header field was given
*/
static int check_safe_file(request_rec *r)
{
+
+ /* ZZZ change to AP defines */
if (r->finfo.st_mode == 0 /* doesn't exist */
|| S_ISDIR(r->finfo.st_mode)
|| S_ISREG(r->finfo.st_mode)
* even if they returned an error.
*/
r->finfo.st_mode = 0;
+
+ /* ZZZ Let's throw some AP Errno checking in here and get rid of the
+ #defines. */
#if defined(ENOENT) && defined(ENOTDIR)
if (errno == ENOENT || errno == ENOTDIR) {
last_cp = cp;
--cp;
}
else {
-#if defined(EACCES)
+#if defined(EACCES) /* ZZZ again, AP error checking. */
if (errno != EACCES)
#endif
ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
if (test_filename[test_filename_len - 1] == '/')
--num_dirs;
- if (S_ISDIR(r->finfo.st_mode))
+ if (S_ISDIR(r->finfo.st_mode)) /* zzz use AP funcs and defines to make
+ this quicker */
++num_dirs;
/*
* S_ISDIR test. But if you accessed /symlink/index.html, for example,
* you would *not* get the 403.
*/
- if (!S_ISDIR(r->finfo.st_mode)
+ if (!S_ISDIR(r->finfo.st_mode) /* ZZZ use AP funcs and defines */
&& (res = check_symlinks(r->filename, ap_allow_options(r)))) {
ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r,
"Symbolic link not allowed: %s", r->filename);
rnew->uri = ap_make_full_path(rnew->pool, udir, new_file);
rnew->filename = ap_make_full_path(rnew->pool, fdir, new_file);
ap_parse_uri(rnew, rnew->uri); /* fill in parsed_uri values */
+
+ /* ZZZ use AP funcs to get File Info */
if (stat(rnew->filename, &rnew->finfo) < 0) {
rnew->finfo.st_mode = 0;
}
* no matter what, if it's a subdirectory, we need to re-run
* directory_walk
*/
- if (S_ISDIR(rnew->finfo.st_mode)) {
+ /* ZZZ use AP funcs and defines for this. */
+ if (S_ISDIR(rnew->finfo.st_mode)) {
res = directory_walk(rnew);
if (!res) {
res = file_walk(rnew);
if (!(strcmp(fname, ap_server_root_relative(p, RESOURCE_CONFIG_FILE))) ||
!(strcmp(fname, ap_server_root_relative(p, ACCESS_CONFIG_FILE)))) {
- if (stat(fname, &finfo) == -1)
+ if (stat(fname, &finfo) == -1) /* ZZZ can we read the file? ACCESS better here. */
return;
}
/* don't require conf/httpd.conf if we have a -C or -c switch */
if((ap_server_pre_read_config->nelts || ap_server_post_read_config->nelts) &&
!(strcmp(fname, ap_server_root_relative(p, SERVER_CONFIG_FILE)))) {
- if (stat(fname, &finfo) == -1)
+ if (stat(fname, &finfo) == -1) /* ZZZ can we read the file? ACCESS better here. */
return;
}
s->limit_req_line = DEFAULT_LIMIT_REQUEST_LINE;
s->limit_req_fieldsize = DEFAULT_LIMIT_REQUEST_FIELDSIZE;
s->limit_req_fields = DEFAULT_LIMIT_REQUEST_FIELDS;
- s->timeout = DEFAULT_TIMEOUT;
+ s->timeout = DEFAULT_TIMEOUT; /*ZZZ use AP default timeouts here*/
s->keep_alive_timeout = DEFAULT_KEEPALIVE_TIMEOUT;
s->keep_alive_max = DEFAULT_KEEPALIVE;
s->keep_alive = 1;
s->next = NULL;
s->addrs = ap_pcalloc(p, sizeof(server_addr_rec));
/* NOT virtual host; don't match any real network interface */
+ /* ZZZ Initialize the Network Address here. */
s->addrs->host_addr.s_addr = htonl(INADDR_ANY);
s->addrs->host_port = 0; /* matches any port */
s->addrs->virthost = ""; /* must be non-NULL */
static void open_error_log(server_rec *s, pool *p)
{
- char *fname;
+ const char *fname;
if (*s->error_fname == '|') {
FILE *dummy;
#endif
else {
fname = ap_server_root_relative(p, s->error_fname);
+ /* Change to AP funcs. */
if (!(s->error_log = ap_pfopen(p, fname, "a"))) {
perror("fopen");
fprintf(stderr, "%s: could not open error log file %s.\n",
{
char errstr[MAX_STRING_LEN];
size_t len;
+ /* change to AP errno funcs. */
int save_errno = errno;
FILE *logf;
&& !(level & APLOG_WIN32ERROR)
#endif
) {
+ /* ZZZ use AP funcs to set the errno and the error string. */
len += ap_snprintf(errstr + len, sizeof(errstr) - len,
"(%d)%s: ", save_errno, strerror(save_errno));
}
/* NULL if we are logging to syslog */
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);
va_end(args);
}
-void ap_log_pid(pool *p, char *fname)
+void ap_log_pid(pool *p, const char *fname)
{
FILE *pid_file;
struct stat finfo;
fname = ap_server_root_relative(p, fname);
mypid = getpid();
if (mypid != saved_pid && stat(fname, &finfo) == 0) {
- /* USR1 and HUP call this on each restart.
+ /* WINCH and HUP call this on each restart.
* Only warn on first time through for this pid.
*
* XXX: Could just write first time through too, although
API_EXPORT(void) ap_log_assert(const char *szExp, const char *szFile, int nLine)
{
+ /* Use AP funcs to output message and abort program. */
fprintf(stderr, "[%s] file %s, line %d, assertion \"%s\" failed\n",
ap_get_time(), szFile, nLine, szExp);
#ifndef WIN32
API_EXPORT(char *) ap_get_time()
{
+ /* ZZZ When we abstract out time, this whole function should change to use
+ AP funcs. */
time_t t;
char *time_string;
API_EXPORT(char *) ap_ht_time(pool *p, time_t t, const char *fmt, int gmt)
{
+ /* ZZZ this function can be replaced by calls to time formatting routines
+ in APR. */
char ts[MAX_STRING_LEN];
char tf[MAX_STRING_LEN];
struct tm *tms;
errno = EACCES;
return NULL;
}
-
+
+ /* ZZZ bopenf and use AP defines for flags. */
file = ap_pfopen(p, name, "r");
#ifdef DEBUG
saved_errno = errno;
{
struct stat finfo;
+ /* ZZZ replace with AP File Info func. */
if (stat(path, &finfo) == -1)
return 0; /* in error condition, just return no */
*/
unsigned long ap_get_virthost_addr(char *w, unsigned short *ports)
{
+ /* ZZZ Redesign for AP func changes */
struct hostent *hep;
unsigned long my_addr;
char *p;
char *server_hostname;
struct hostent *p;
-#ifdef BEOS /* BeOS returns zero as an error for gethostname */
- if (gethostname(str, sizeof(str) - 1) == 0) {
-#else
- if (gethostname(str, sizeof(str) - 1) != 0) {
-#endif /* BeOS */
+ /* ZZZ change to use AP funcs. */
+#ifdef BEOS
+ if (gethostname(str, sizeof(str) - 1) == 0)
+#else
+ if (gethostname(str, sizeof(str) - 1) != 0)
+#endif
+ {
perror("Unable to gethostname");
exit(1);
}
static const char *get_addresses(pool *p, char *w, server_addr_rec ***paddr,
unsigned port)
{
+ /* ZZZ redesign to use AP funcs and types. Will see what I can do to make it
+ similar using posix std's. */
+
struct hostent *hep;
unsigned long my_addr;
server_addr_rec *sar;
/* compile the tables and such we need to do the run-time vhost lookups */
void ap_fini_vhost_config(pool *p, server_rec *main_s)
{
+ /* ZZZ need to redesign for use with AP funcs. will look into this later.
+ */
server_addr_rec *sar;
int has_default_vhost_addr;
server_rec *s;
* names we'll match have ports associated with them
*/
const char *host = r->hostname;
+ /* ZZZ use AP func here. */
unsigned port = ntohs(r->connection->local_addr.sin_port);
server_rec *s;
server_rec *last_s;
server_rec *s;
server_rec *last_s;
name_chain *src;
+ /* use AP func here. */
unsigned port = ntohs(r->connection->local_addr.sin_port);
/*