ln -s .$(LUCI_INSTALLDIR) host/luci
run: host
+ libs/sgi-webuci/host/buildconfig.sh `pwd`/host > host/etc/boa/boa.conf
./host/usr/bin/boa -c ./host/etc/boa -d
hostclean: clean
endif
-MAKE_FLAGS += MODULES="$(PKG_SELECTED_MODULES)" LUA_TARGET="$(LUA_TARGET)" \
-CFLAGS="$(TARGET_CFLAGS) -I$(STAGING_DIR)/usr/include" LDFLAGS="$(TARGET_LDFLAGS)" \
-CFOPTS='$(TARGET_CONFIGURE_OPTS)'
+MAKE_FLAGS += MODULES="$(PKG_SELECTED_MODULES)" LUA_TARGET="$(LUA_TARGET)" CFLAGS="$(TARGET_CFLAGS) -I$(STAGING_DIR)/usr/include" LDFLAGS="$(TARGET_LDFLAGS)"
$(eval $(call BuildPackage,luci-core))
include ../../build/gccconfig.mk
include ../../build/module.mk
-BOA_VERSION = 0.94.14rc21
+BOA_VERSION = 0.94.13
BOA_SITE = http://www.boa.org
BOA_DIR = boa-$(BOA_VERSION)
BOA_FILE = $(BOA_DIR).tar.gz
touch $@
$(BOA_DIR)/.configured: $(BOA_DIR)/.patched
- (cd $(BOA_DIR); ./configure --disable-debug --disable-gunzip $(CFOPTS))
+ (cd $(BOA_DIR)/src; ./configure --disable-debug)
touch $@
boa-compile: $(BOA_DIR)/.configured
+++ /dev/null
-Index: boa-0.94.14rc21/examples/boa.conf
-===================================================================
---- boa-0.94.14rc21.orig/examples/boa.conf 2007-08-08 20:00:58.000000000 -0400
-+++ boa-0.94.14rc21/examples/boa.conf 2007-08-08 20:01:15.000000000 -0400
-@@ -232,7 +232,7 @@
- # Aliases: Aliases one path to another.
- # Example: Alias /path1/bar /path2/foo
-
--Alias /doc /usr/doc
-+Alias /doc /usr/share/doc
-
- # ScriptAlias: Maps a virtual path to a directory for serving scripts
- # Example: ScriptAlias /htbin/ /www/htbin/
+++ /dev/null
-Index: boa-0.94.14rc21/src/pipe.c
-===================================================================
---- boa-0.94.14rc21.orig/src/pipe.c 2007-08-08 20:03:29.000000000 -0400
-+++ boa-0.94.14rc21/src/pipe.c 2007-08-08 20:03:45.000000000 -0400
-@@ -215,7 +215,9 @@
- }
- req->ranges->start = sendfile_offset;
- if (bytes_written < 0) {
-- if (errno == EWOULDBLOCK || errno == EAGAIN) {
-+ if (errno == ENOSYS) {
-+ return io_shuffle(req);
-+ } else if (errno == EWOULDBLOCK || errno == EAGAIN) {
- return -1; /* request blocked at the pipe level, but keep going */
- } else if (errno == EINTR) {
- goto retrysendfile;
+++ /dev/null
-Index: boa-0.94.14rc21/Makefile.in
-===================================================================
---- boa-0.94.14rc21.orig/Makefile.in 2007-08-08 20:04:19.000000000 -0400
-+++ boa-0.94.14rc21/Makefile.in 2007-08-08 20:04:35.000000000 -0400
-@@ -20,7 +20,7 @@
-
- mrclean: clean
- -(cd src && $(MAKE) $(MFLAGS) mrclean)
-- -(cd docs && $(MAKE)$(MFLAGS) mrclean)
-+ -(cd docs && $(MAKE) $(MFLAGS) mrclean)
- rm -f config.status config.cache config.h config.log
- rm -f Makefile *~
-
+++ /dev/null
-Index: boa-0.94.14rc21/src/util.c
-===================================================================
---- boa-0.94.14rc21.orig/src/util.c 2007-08-08 20:05:06.000000000 -0400
-+++ boa-0.94.14rc21/src/util.c 2007-08-08 20:05:14.000000000 -0400
-@@ -410,11 +410,6 @@
- uri_old++;
- if ((c = *uri_old++) && (d = *uri_old++)) {
- *uri = HEX_TO_DECIMAL(c, d);
-- if (*uri < 32 || *uri > 126) {
-- /* control chars in URI */
-- *uri = '\0';
-- return 0;
-- }
- } else {
- *uri = '\0';
- return 0;
+++ /dev/null
-diff --git a/src/buffer.c b/src/buffer.c
-index 99f3e7c..6720e21 100644
---- a/src/buffer.c
-+++ b/src/buffer.c
-@@ -77,6 +77,7 @@ int req_write_escape_http(request * req, const char *msg)
- char c, *dest;
- const char *inp;
-
-+ int skip = 0;
- int left;
- inp = msg;
- dest = req->buffer + req->buffer_end;
-@@ -84,7 +85,12 @@ int req_write_escape_http(request * req, const char *msg)
- * in the middle of a transfer of up to 3 bytes */
- left = BUFFER_SIZE - req->buffer_end;
- while ((c = *inp++) && left >= 3) {
-- if (needs_escape((unsigned int) c)) {
-+ /* Lower the skip character count. */
-+ if (skip) skip--;
-+ /* If we have a '%', we skip the two follow characters. */
-+ if (c == '%') skip = 2;
-+
-+ if (!skip && needs_escape((unsigned int) c)) {
- *dest++ = '%';
- *dest++ = INT_TO_HEX((c >> 4) & 0xf);
- *dest++ = INT_TO_HEX(c & 0xf);
-Index: boa-0.94.14rc21/src/util.c
-===================================================================
---- boa-0.94.14rc21.orig/src/util.c 2005-02-22 15:11:29.000000000 +0100
-+++ boa-0.94.14rc21/src/util.c 2008-06-11 08:45:10.000000000 +0200
-@@ -151,14 +151,9 @@
+diff -urN boa-0.94.13/src/util.c boa/src/util.c
+--- boa-0.94.13/src/util.c 2002-07-08 01:22:18.000000000 +0200
++++ boa/src/util.c 2008-04-25 21:56:20.000000000 +0200
+@@ -95,14 +95,9 @@
static char buf[30];
int time_offset;
p = buf + 29;
*p-- = '\0';
*p-- = ' ';
+
-Index: boa-0.94.14rc21/src/list.h
+Index: boa-0.94.13/src/list.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ boa-0.94.14rc21/src/list.h 2008-06-11 10:25:04.000000000 +0200
++++ boa-0.94.13/src/list.h 2008-05-27 19:28:21.000000000 +0200
@@ -0,0 +1,601 @@
+#ifndef _LINUX_LIST_H
+#define _LINUX_LIST_H
+ pos = n)
+
+#endif
-Index: boa-0.94.14rc21/src/plugin.c
+Index: boa-0.94.13/src/plugin.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ boa-0.94.14rc21/src/plugin.c 2008-06-11 10:25:04.000000000 +0200
-@@ -0,0 +1,198 @@
++++ boa-0.94.13/src/plugin.c 2008-05-27 19:28:21.000000000 +0200
+@@ -0,0 +1,189 @@
+/*
+ * Simple plugin API for boa
+ * Copyright (C) 2008 John Crispin <blogic@openwrt.org>
+ break;
+ }
+ ctx.server_addr = req->local_ip_addr;
-+ switch (req->http_version) {
-+ case HTTP09:
-+ ctx.server_proto = "HTTP/0.9";
-+ break;
-+ case HTTP10:
-+ ctx.server_proto = "HTTP/1.0";
-+ break;
-+ case HTTP11:
-+ ctx.server_proto = "HTTP/1.1";
-+ break;
-+ }
++ ctx.server_proto = req->http_version;
+ ctx.query_string = req->query_string;
+ ctx.remote_addr = req->remote_ip_addr;
+ ctx.remote_port = req->remote_port;
+
+ switch(child_pid) {
+ case -1:
-+ log_error_doc(req);
++ log_error_time();
+ perror("fork");
+ send_r_error(req);
+ return 0;
+
+ case 0:
+ if (dup2(req->fd, STDOUT_FILENO) == -1) {
-+ log_error_doc(req);
++ log_error_time();
+ perror("dup2 - fd");
+ _exit(1);
+ }
+ if (set_block_fd(req->fd) == -1) {
-+ log_error_doc(req);
++ log_error_time();
+ perror("cgi-fcntl");
+ _exit(1);
+ }
+ close(req->post_data_fd);
+ set_block_fd(STDIN_FILENO);
+ }
++ close_access_log();
+
+ if (cgi_log_fd)
+ dup2(cgi_log_fd, STDERR_FILENO);
+}
+
+
-Index: boa-0.94.14rc21/src/request.c
+Index: boa-0.94.13/src/request.c
===================================================================
---- boa-0.94.14rc21.orig/src/request.c 2005-02-22 15:11:29.000000000 +0100
-+++ boa-0.94.14rc21/src/request.c 2008-06-11 10:25:04.000000000 +0200
-@@ -59,6 +59,7 @@
+--- boa-0.94.13.orig/src/request.c 2002-07-24 05:03:59.000000000 +0200
++++ boa-0.94.13/src/request.c 2008-05-27 19:28:21.000000000 +0200
+@@ -50,6 +50,7 @@
dequeue(&request_free, request_free); /* dequeue the head */
} else {
req = (request *) malloc(sizeof (request));
if (!req) {
log_error_time();
perror("malloc for new request");
-@@ -793,6 +794,8 @@
+@@ -603,6 +604,8 @@
int process_header_end(request * req)
{
+ int ret;
+
if (!req->logline) {
- log_error_doc(req);
- fputs("No logline in process_header_end\n", stderr);
-@@ -855,19 +858,35 @@
+ send_r_error(req);
+ return 0;
+@@ -630,11 +633,26 @@
}
if (req->method == M_POST) {
- req->post_data_fd = create_temporary_file(1, NULL, 0);
-+ if (!req->plugin) {
-+ req->post_data_fd = create_temporary_file(1, NULL, 0);
-+ } else {
-+ int fd[2];
-+ if (pipe(&fd[0]) != -1) {
-+ req->post_data_fd = fd[1];
-+ req->read_data_fd = fd[0];
-+ set_nonblock_fd(req->post_data_fd);
-+ }
-+ }
- if (req->post_data_fd == 0) {
- /* errors already logged */
- send_r_error(req);
- return 0;
- }
-- if (fcntl(req->post_data_fd, F_SETFD, 1) == -1) {
-- boa_perror(req, "unable to set close-on-exec for req->post_data_fd!");
-- close(req->post_data_fd);
-- req->post_data_fd = 0;
-- return 0;
-+ if (!req->plugin) {
-+ if (fcntl(req->post_data_fd, F_SETFD, 1) == -1) {
-+ boa_perror(req, "unable to set close-on-exec for req->post_data_fd!");
-+ close(req->post_data_fd);
-+ req->post_data_fd = 0;
-+ return 0;
-+ }
-+ return(1); /* success */
- }
-- return 1; /* success */
+- if (req->post_data_fd == 0)
+- return(0);
+- return(1); /* success */
+- }
++ if (!req->plugin) {
++ req->post_data_fd = create_temporary_file(1, NULL, 0);
++ } else {
++ int fd[2];
++ if (pipe(&fd[0]) != -1) {
++ req->post_data_fd = fd[1];
++ req->read_data_fd = fd[0];
++ set_nonblock_fd(req->post_data_fd);
++ }
++ }
++ if (req->post_data_fd == 0) {
++ return(0);
++ }
++ if (!req->plugin)
++ return(1); /* success */
+ }
+
-+ ret = plugin_handle(req);
-+ if (ret) {
-+ return ret;
- }
++ ret = plugin_handle(req);
++ if (ret)
++ return ret;
- if (req->cgi_type) {
-Index: boa-0.94.14rc21/src/Makefile.in
+ if (req->is_cgi) {
+ return init_cgi(req);
+Index: boa-0.94.13/src/Makefile.in
===================================================================
---- boa-0.94.14rc21.orig/src/Makefile.in 2005-02-22 04:02:40.000000000 +0100
-+++ boa-0.94.14rc21/src/Makefile.in 2008-06-11 10:25:04.000000000 +0200
-@@ -15,7 +15,7 @@
+--- boa-0.94.13.orig/src/Makefile.in 2002-03-24 23:20:19.000000000 +0100
++++ boa-0.94.13/src/Makefile.in 2008-05-27 19:28:21.000000000 +0200
+@@ -20,7 +20,7 @@
srcdir = @srcdir@
VPATH = @srcdir@:@srcdir@/../extras
LDFLAGS = @LDFLAGS@
-LIBS = @LIBS@
+LIBS = @LIBS@ -ldl
- CFLAGS = @CFLAGS@
- CPPFLAGS = @CPPFLAGS@ -I@srcdir@ -I.
- @ifGNUmake@DEPEND = .depend
-@@ -26,6 +26,7 @@
+ CFLAGS = @CFLAGS@ -I.
+
+ # Change these if necessary
+@@ -32,7 +32,8 @@
+
SOURCES = alias.c boa.c buffer.c cgi.c cgi_header.c config.c escape.c \
- get.c hash.c ip.c log.c mmap_cache.c pipe.c queue.c range.c \
- read.c request.c response.c signals.c util.c sublog.c \
-+ plugin.c \
- @ASYNCIO_SOURCE@ @ACCESSCONTROL_SOURCE@
+ get.c hash.c ip.c log.c mmap_cache.c pipe.c queue.c read.c \
+- request.c response.c select.c signals.c util.c sublog.c
++ request.c response.c select.c signals.c util.c sublog.c \
++ plugin.c
+
+ OBJS = y.tab.o lex.yy.o $(SOURCES:.c=.o) timestamp.o @STRUTIL@
- OBJS = $(SOURCES:.c=.o) timestamp.o @STRUTIL@
-Index: boa-0.94.14rc21/src/boa.h
+Index: boa-0.94.13/src/boa.h
===================================================================
---- boa-0.94.14rc21.orig/src/boa.h 2005-02-22 15:11:29.000000000 +0100
-+++ boa-0.94.14rc21/src/boa.h 2008-06-11 10:25:04.000000000 +0200
-@@ -38,6 +38,7 @@
+--- boa-0.94.13.orig/src/boa.h 2002-07-26 05:03:44.000000000 +0200
++++ boa-0.94.13/src/boa.h 2008-05-27 19:28:21.000000000 +0200
+@@ -37,6 +37,7 @@
#include <fcntl.h>
#include <limits.h> /* OPEN_MAX */
#include <setjmp.h>
+#include <stdbool.h>
+ #include <netdb.h>
#include <netinet/in.h>
-
-@@ -49,6 +50,7 @@
+@@ -50,6 +51,7 @@
#include "compat.h" /* oh what fun is porting */
#include "defines.h"
#include "globals.h"
+#include "boa-plugin.h"
/* alias */
- void add_alias(const char *fakename, const char *realname, enum ALIAS type);
-@@ -225,5 +227,10 @@
- void range_pool_push(Range * r);
- int ranges_fixup(request * req);
- int range_parse(request * req, const char *str);
--
-+
+ void add_alias(char *fakename, char *realname, int script);
+@@ -192,4 +194,9 @@
+ /* select */
+ void select_loop(int server_s);
+
+/* plugins */
+int plugin_init(char *path);
+int plugin_handle(request * req);
+struct httpd_plugin *plugin_lookup(request *req);
+
#endif
-Index: boa-0.94.14rc21/src/config.c
+Index: boa-0.94.13/src/config.c
===================================================================
---- boa-0.94.14rc21.orig/src/config.c 2005-02-22 15:11:29.000000000 +0100
-+++ boa-0.94.14rc21/src/config.c 2008-06-11 10:25:04.000000000 +0200
-@@ -64,6 +64,7 @@
+--- boa-0.94.13.orig/src/config.c 2002-07-26 05:04:29.000000000 +0200
++++ boa-0.94.13/src/config.c 2008-05-27 19:28:21.000000000 +0200
+@@ -61,6 +61,7 @@
char *error_log_name;
char *access_log_name;
char *cgi_log_name;
int use_localtime;
-@@ -165,6 +166,7 @@
- {"CGINice", S2A, c_set_int, &cgi_nice},
- #endif
- {"CGIEnv", S2A, c_add_cgi_env, NULL},
+@@ -116,6 +117,7 @@
+ {"SinglePostLimit", S1A, c_set_int, &single_post_limit},
+ {"CGIPath", S1A, c_set_string, &cgi_path},
+ {"MaxConnections", S1A, c_set_int, &max_connections},
+ {"PluginRoot", S1A, c_set_string, &plugin_root},
};
- static void c_add_cgi_env(char *v1, char *v2, void *t)
-@@ -544,6 +546,22 @@
- single_post_limit);
- exit(EXIT_FAILURE);
+ static void c_set_user(char *v1, char *v2, void *t)
+@@ -323,6 +325,22 @@
+ free(dirmaker);
+ dirmaker = temp;
}
+ if (plugin_root) {
+ char *plugin_path = plugin_root;
+ next++;
+ }
+
-+ plugin_init(plugin_path);
++ plugin_init(normalize_path(plugin_path));
+ plugin_path = next;
+ } while (plugin_path);
+ free(plugin_root);
+ }
- if (vhost_root && virtualhost) {
- fprintf(stderr, "Both VHostRoot and VirtualHost were enabled, and "
-Index: boa-0.94.14rc21/src/alias.c
+ #if 0
+ if (mime_types) {
+Index: boa-0.94.13/src/alias.c
===================================================================
---- boa-0.94.14rc21.orig/src/alias.c 2005-02-22 15:11:29.000000000 +0100
-+++ boa-0.94.14rc21/src/alias.c 2008-06-11 10:25:04.000000000 +0200
-@@ -246,6 +246,7 @@
-
+--- boa-0.94.13.orig/src/alias.c 2002-07-28 04:46:52.000000000 +0200
++++ boa-0.94.13/src/alias.c 2008-05-27 19:28:21.000000000 +0200
+@@ -213,6 +213,7 @@
uri_len = strlen(req->request_uri);
+
current = find_alias(req->request_uri, uri_len);
+ req->plugin = !!plugin_lookup(req);
if (current) {
+
if (current->type == SCRIPTALIAS) /* Script */
- return init_script_alias(req, current, uri_len);
-@@ -263,7 +264,7 @@
- uri_len - current->fake_len + 1);
+@@ -237,7 +238,7 @@
+ }
if (current->type == REDIRECT) { /* Redirect */
- if (req->method == M_POST) { /* POST to non-script */
+ if ((req->method == M_POST) && !req->plugin) { /* POST to non-script */
/* it's not a cgi, but we try to POST??? */
- log_error_doc(req);
- fputs("POST to non-script is disallowed.\n", stderr);
-@@ -432,7 +433,7 @@
+ send_r_bad_request(req);
+ return 0; /* not a script alias, therefore begin filling in data */
+@@ -361,7 +362,7 @@
else
- req->cgi_type = CGI;
+ req->is_cgi = CGI;
return 1;
- } else if (req->method == M_POST) { /* POST to non-script */
+ } else if ((req->method == M_POST) && !req->plugin) { /* POST to non-script */
/* it's not a cgi, but we try to POST??? */
- log_error_doc(req);
- fputs("POST to non-script disallowed.\n", stderr);
-Index: boa-0.94.14rc21/src/globals.h
+ send_r_bad_request(req);
+ return 0;
+Index: boa-0.94.13/src/globals.h
===================================================================
---- boa-0.94.14rc21.orig/src/globals.h 2005-02-22 15:11:29.000000000 +0100
-+++ boa-0.94.14rc21/src/globals.h 2008-06-11 10:25:04.000000000 +0200
-@@ -158,6 +158,7 @@
- char *host; /* what we end up using for 'host', no matter the contents of header_host */
+--- boa-0.94.13.orig/src/globals.h 2002-07-24 05:03:59.000000000 +0200
++++ boa-0.94.13/src/globals.h 2008-05-27 19:28:21.000000000 +0200
+@@ -47,6 +47,7 @@
+ struct request { /* pending requests */
+ int fd; /* client's socket fd */
+ int status; /* see #defines.h */
++ bool plugin;
+ time_t time_last; /* time of last succ. op. */
+ char *pathname; /* pathname of requested file */
+ int simple; /* simple request? */
+@@ -92,6 +93,7 @@
+ char *header_referer;
int post_data_fd; /* fd for post data tmpfile */
+ int read_data_fd; /* fd for post data input (plugin) */
char *path_info; /* env variable */
char *path_translated; /* env variable */
-@@ -193,6 +194,8 @@
- char accept[MAX_ACCEPT_LENGTH]; /* Accept: fields */
- #endif
-
-+ bool plugin;
-+
- struct request *next; /* next */
- struct request *prev; /* previous */
- };
-Index: boa-0.94.14rc21/src/read.c
+Index: boa-0.94.13/src/read.c
===================================================================
---- boa-0.94.14rc21.orig/src/read.c 2005-02-23 16:41:55.000000000 +0100
-+++ boa-0.94.14rc21/src/read.c 2008-06-11 10:25:04.000000000 +0200
-@@ -375,8 +375,11 @@
+--- boa-0.94.13.orig/src/read.c 2002-03-18 02:53:48.000000000 +0100
++++ boa-0.94.13/src/read.c 2008-05-27 19:28:21.000000000 +0200
+@@ -338,8 +338,11 @@
if (bytes_to_write == 0) { /* nothing left in buffer to write */
req->header_line = req->header_end = req->buffer;
/* if here, we can safely assume that there is more to read */
req->status = BODY_READ;
return 1;
-Index: boa-0.94.14rc21/src/boa-plugin.h
+Index: boa-0.94.13/src/boa-plugin.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ boa-0.94.14rc21/src/boa-plugin.h 2008-06-11 10:25:04.000000000 +0200
++++ boa-0.94.13/src/boa-plugin.h 2008-05-27 19:28:21.000000000 +0200
@@ -0,0 +1,67 @@
+#ifndef _HTTPD_PLUGIN_H__
+#define _HTTPD_PLUGIN_H__
MimeTypes /etc/mime.types
DefaultType text/plain
ServerName localhost
-CGIPath /bin:/usr/bin:/usr/local/bin
+CGIPath /bin:/usr/bin
AddType application/x-httpd-cgi cgi
AddType application/x-httpd-cgi sh
+++ /dev/null
-Index: boa-0.94.14rc21/src/boa.h
-===================================================================
---- boa-0.94.14rc21.orig/src/boa.h 2007-11-03 00:51:46.000000000 -0400
-+++ boa-0.94.14rc21/src/boa.h 2007-11-03 01:05:20.000000000 -0400
-@@ -25,7 +25,9 @@
- #ifndef _BOA_H
- #define _BOA_H
-
-+/* Important, include before anything else */
- #include "config.h"
-+
- #include <errno.h>
- #include <stdlib.h> /* malloc, free, etc. */
- #include <stdio.h> /* stdin, stdout, stderr */
-@@ -165,7 +167,7 @@
- void clean_pathname(char *pathname);
- char *get_commonlog_time(void);
- void rfc822_time_buf(char *buf, time_t s);
--char *simple_itoa(unsigned int i);
-+char *simple_itoa(uint64_t i);
- int boa_atoi(const char *s);
- int month2int(const char *month);
- int modified_since(time_t * mtime, const char *if_modified_since);
-Index: boa-0.94.14rc21/src/buffer.c
-===================================================================
---- boa-0.94.14rc21.orig/src/buffer.c 2007-11-03 00:51:46.000000000 -0400
-+++ boa-0.94.14rc21/src/buffer.c 2007-11-03 01:05:20.000000000 -0400
-@@ -212,7 +212,7 @@
- return -2;
-
- if (bytes_to_write) {
-- int bytes_written;
-+ off_t bytes_written;
-
- bytes_written = write(req->fd, req->buffer + req->buffer_start,
- bytes_to_write);
-Index: boa-0.94.14rc21/src/config.h.in
-===================================================================
---- boa-0.94.14rc21.orig/src/config.h.in 2007-11-03 00:51:46.000000000 -0400
-+++ boa-0.94.14rc21/src/config.h.in 2007-11-03 01:08:36.000000000 -0400
-@@ -205,3 +205,16 @@
-
- /* Define to `int' if <sys/types.h> doesn't define. */
- #undef uid_t
-+
-+/* Those enable the LFS ready structures in the system headers */
-+#define _FILE_OFFSET_BITS 64 /* glibc style */
-+#define _LARGEFILE_SOURCE 1 /* To make ftello() visible (HP-UX 10.20). */
-+#define _LARGE_FILES 1 /* Large file defined on AIX-style hosts. */
-+
-+#define _LARGEFILE64_SOURCE /* tell kernel headers to provide the O_LARGEFILE value */
-+
-+#if __WORDSIZE == 64
-+#define PRINTF_OFF_T_ARG "%ld"
-+#elif __WORDSIZE == 32
-+#define PRINTF_OFF_T_ARG "%lld"
-+#endif
-Index: boa-0.94.14rc21/src/get.c
-===================================================================
---- boa-0.94.14rc21.orig/src/get.c 2007-11-03 00:51:46.000000000 -0400
-+++ boa-0.94.14rc21/src/get.c 2007-11-03 01:08:20.000000000 -0400
-@@ -25,6 +25,10 @@
- #include "boa.h"
- #include "access.h"
-
-+#include <sys/types.h>
-+#include <sys/stat.h>
-+#include <fcntl.h>
-+
- #define STR(s) __STR(s)
- #define __STR(s) #s
-
-@@ -52,9 +56,9 @@
- {
- int data_fd, saved_errno;
- struct stat statbuf;
-- volatile unsigned int bytes_free;
-+ volatile off_t bytes_free;
-
-- data_fd = open(req->pathname, O_RDONLY);
-+ data_fd = open(req->pathname, O_RDONLY|O_LARGEFILE);
- saved_errno = errno; /* might not get used */
-
- #ifdef GUNZIP
-@@ -76,7 +80,7 @@
- memcpy(gzip_pathname, req->pathname, len);
- memcpy(gzip_pathname + len, ".gz", 3);
- gzip_pathname[len + 3] = '\0';
-- data_fd = open(gzip_pathname, O_RDONLY);
-+ data_fd = open(gzip_pathname, O_RDONLY|O_LARGEFILE);
- if (data_fd != -1) {
- close(data_fd);
-
-@@ -430,8 +434,8 @@
-
- int process_get(request * req)
- {
-- int bytes_written;
-- volatile unsigned int bytes_to_write;
-+ off_t bytes_written;
-+ volatile off_t bytes_to_write;
-
- if (req->method == M_HEAD) {
- return complete_response(req);
-@@ -531,7 +535,7 @@
- memcpy(pathname_with_index, req->pathname, l1); /* doesn't copy NUL */
- memcpy(pathname_with_index + l1, directory_index, l2 + 1); /* does */
-
-- data_fd = open(pathname_with_index, O_RDONLY);
-+ data_fd = open(pathname_with_index, O_RDONLY|O_LARGEFILE);
-
- if (data_fd != -1) { /* user's index file */
- /* We have to assume that directory_index will fit, because
-@@ -555,7 +559,7 @@
- * try index.html.gz
- */
- strcat(pathname_with_index, ".gz");
-- data_fd = open(pathname_with_index, O_RDONLY);
-+ data_fd = open(pathname_with_index, O_RDONLY|O_LARGEFILE);
- if (data_fd != -1) { /* user's index file */
- close(data_fd);
-
-@@ -624,9 +628,9 @@
- * include the NUL when calculating if the size is enough
- */
- snprintf(pathname_with_index, sizeof(pathname_with_index),
-- "%s/dir.%d.%ld", cachedir,
-+ "%s/dir.%d." PRINTF_OFF_T_ARG, cachedir,
- (int) statbuf->st_dev, statbuf->st_ino);
-- data_fd = open(pathname_with_index, O_RDONLY);
-+ data_fd = open(pathname_with_index, O_RDONLY|O_LARGEFILE);
-
- if (data_fd != -1) { /* index cache */
-
-@@ -642,7 +646,7 @@
- if (index_directory(req, pathname_with_index) == -1)
- return -1;
-
-- data_fd = open(pathname_with_index, O_RDONLY); /* Last chance */
-+ data_fd = open(pathname_with_index, O_RDONLY|O_LARGEFILE); /* Last chance */
- if (data_fd != -1) {
- strcpy(req->request_uri, directory_index); /* for mimetype */
- fstat(data_fd, statbuf);
-@@ -671,7 +675,7 @@
- DIR *request_dir;
- FILE *fdstream;
- struct dirent *dirbuf;
-- int bytes = 0;
-+ off_t bytes = 0;
- char *escname = NULL;
-
- if (chdir(req->pathname) == -1) {
-Index: boa-0.94.14rc21/src/globals.h
-===================================================================
---- boa-0.94.14rc21.orig/src/globals.h 2007-11-03 00:51:46.000000000 -0400
-+++ boa-0.94.14rc21/src/globals.h 2007-11-03 01:05:20.000000000 -0400
-@@ -130,9 +130,9 @@
- int numranges;
-
- int data_fd; /* fd of data */
-- unsigned long filesize; /* filesize */
-- unsigned long filepos; /* position in file */
-- unsigned long bytes_written; /* total bytes written (sans header) */
-+ off_t filesize; /* filesize */
-+ off_t filepos; /* position in file */
-+ size_t bytes_written; /* total bytes written (sans header) */
- char *data_mem; /* mmapped/malloced char array */
-
- char *logline; /* line to log file */
-Index: boa-0.94.14rc21/src/index_dir.c
-===================================================================
---- boa-0.94.14rc21.orig/src/index_dir.c 2007-11-03 00:51:46.000000000 -0400
-+++ boa-0.94.14rc21/src/index_dir.c 2007-11-03 01:08:11.000000000 -0400
-@@ -19,6 +19,7 @@
-
- /* $Id: index_dir.c,v 1.32.2.7 2005/02/22 03:00:24 jnelson Exp $*/
-
-+#include "config.h"
- #include <stdio.h>
- #include <sys/stat.h>
- #include <limits.h> /* for PATH_MAX */
-@@ -266,10 +267,12 @@
- printf("<tr>"
- "<td width=\"40%%\"><a href=\"%s/\">%s/</a></td>"
- "<td align=right>%s</td>"
-- "<td align=right>%ld bytes</td>"
-+ "<td align=right>"
-+ PRINTF_OFF_T_ARG
-+ " bytes</td>"
- "</tr>\n",
- escaped_filename, html_filename,
-- ctime(&statbuf.st_mtime), (long) statbuf.st_size);
-+ ctime(&statbuf.st_mtime), (off_t) statbuf.st_size);
- }
-
- printf
-@@ -312,10 +315,12 @@
- "<td width=\"40%%\"><a href=\"%s\">%s</a> "
- "<a href=\"%s.gz\">(.gz)</a></td>"
- "<td align=right>%s</td>"
-- "<td align=right>%ld bytes</td>"
-+ "<td align=right>"
-+ PRINTF_OFF_T_ARG
-+ "bytes</td>"
- "</tr>\n",
- escaped_filename, html_filename, http_filename,
-- ctime(&statbuf.st_mtime), (long) statbuf.st_size);
-+ ctime(&statbuf.st_mtime), (off_t) statbuf.st_size);
- } else {
- #endif
- if (html_escape_string(http_filename, escaped_filename,
-@@ -326,10 +331,12 @@
- printf("<tr>"
- "<td width=\"40%%\"><a href=\"%s\">%s</a></td>"
- "<td align=right>%s</td>"
-- "<td align=right>%ld bytes</td>"
-+ "<td align=right>"
-+ PRINTF_OFF_T_ARG
-+ "bytes</td>"
- "</tr>\n",
- escaped_filename, html_filename,
-- ctime(&statbuf.st_mtime), (long) statbuf.st_size);
-+ ctime(&statbuf.st_mtime), (off_t) statbuf.st_size);
- #ifdef GUNZIP
- }
- #endif
-Index: boa-0.94.14rc21/src/log.c
-===================================================================
---- boa-0.94.14rc21.orig/src/log.c 2007-11-03 00:51:46.000000000 -0400
-+++ boa-0.94.14rc21/src/log.c 2007-11-03 01:05:20.000000000 -0400
-@@ -146,7 +146,7 @@
- } else if (vhost_root) {
- printf("%s ", (req->host ? req->host : "(null)"));
- }
-- printf("%s - - %s\"%s\" %d %ld \"%s\" \"%s\"\n",
-+ printf("%s - - %s\"%s\" %d %zu \"%s\" \"%s\"\n",
- req->remote_ip_addr,
- get_commonlog_time(),
- req->logline ? req->logline : "-",
-Index: boa-0.94.14rc21/src/mmap_cache.c
-===================================================================
---- boa-0.94.14rc21.orig/src/mmap_cache.c 2007-11-03 00:51:46.000000000 -0400
-+++ boa-0.94.14rc21/src/mmap_cache.c 2007-11-03 01:05:20.000000000 -0400
-@@ -140,7 +140,7 @@
- int data_fd;
- struct stat statbuf;
- struct mmap_entry *e;
-- data_fd = open(fname, O_RDONLY);
-+ data_fd = open(fname, O_RDONLY|O_LARGEFILE);
- if (data_fd == -1) {
- perror(fname);
- return NULL;
-Index: boa-0.94.14rc21/src/pipe.c
-===================================================================
---- boa-0.94.14rc21.orig/src/pipe.c 2007-11-03 01:05:20.000000000 -0400
-+++ boa-0.94.14rc21/src/pipe.c 2007-11-03 01:05:20.000000000 -0400
-@@ -37,8 +37,8 @@
-
- int read_from_pipe(request * req)
- {
-- int bytes_read; /* signed */
-- unsigned int bytes_to_read; /* unsigned */
-+ off_t bytes_read; /* signed */
-+ off_t bytes_to_read; /* unsigned */ /* XXX really? */
-
- bytes_to_read = BUFFER_SIZE - (req->header_end - req->buffer - 1);
-
-@@ -128,8 +128,8 @@
-
- int write_from_pipe(request * req)
- {
-- int bytes_written;
-- size_t bytes_to_write = req->header_end - req->header_line;
-+ off_t bytes_written;
-+ off_t bytes_to_write = req->header_end - req->header_line;
-
- if (bytes_to_write == 0) {
- if (req->cgi_status == CGI_DONE)
-@@ -170,9 +170,9 @@
- #ifdef HAVE_SENDFILE
- int io_shuffle_sendfile(request * req)
- {
-- int bytes_written;
-- size_t bytes_to_write;
- off_t sendfile_offset;
-+ off_t bytes_written;
-+ off_t bytes_to_write;
-
- if (req->method == M_HEAD) {
- return complete_response(req);
-@@ -266,8 +266,8 @@
-
- int io_shuffle(request * req)
- {
-- int bytes_to_read;
-- int bytes_written, bytes_to_write;
-+ off_t bytes_to_read;
-+ off_t bytes_written, bytes_to_write;
-
- if (req->method == M_HEAD) {
- return complete_response(req);
-@@ -287,7 +287,7 @@
- bytes_to_read = bytes_to_write;
-
- if (bytes_to_read > 0 && req->data_fd) {
-- int bytes_read;
-+ off_t bytes_read;
- off_t temp;
-
- temp = lseek(req->data_fd, req->ranges->start, SEEK_SET);
-Index: boa-0.94.14rc21/src/range.c
-===================================================================
---- boa-0.94.14rc21.orig/src/range.c 2007-11-03 00:51:46.000000000 -0400
-+++ boa-0.94.14rc21/src/range.c 2007-11-03 01:05:20.000000000 -0400
-@@ -147,7 +147,7 @@
- * 5) start > stop && start != -1 :: invalid
- */
- DEBUG(DEBUG_RANGE) {
-- fprintf(stderr, "range.c: ranges_fixup: %lu-%lu\n", r->start, r->stop);
-+ fprintf(stderr, "range.c: ranges_fixup: %lu - %lu\n", r->start, r->stop);
- }
-
- /* no stop range specified or stop is too big.
-Index: boa-0.94.14rc21/src/read.c
-===================================================================
---- boa-0.94.14rc21.orig/src/read.c 2007-11-03 00:51:46.000000000 -0400
-+++ boa-0.94.14rc21/src/read.c 2007-11-03 01:05:20.000000000 -0400
-@@ -38,7 +38,7 @@
-
- int read_header(request * req)
- {
-- int bytes;
-+ off_t bytes;
- char *check, *buffer;
- unsigned char uc;
-
-@@ -179,7 +179,7 @@
- */
-
- if (req->content_length) {
-- int content_length;
-+ off_t content_length;
-
- content_length = boa_atoi(req->content_length);
- /* Is a content-length of 0 legal? */
-@@ -195,7 +195,7 @@
- && content_length > single_post_limit) {
- log_error_doc(req);
- fprintf(stderr,
-- "Content-Length [%d] > SinglePostLimit [%d] on POST!\n",
-+ "Content-Length [" PRINTF_OFF_T_ARG "] > SinglePostLimit [%d] on POST!\n",
- content_length, single_post_limit);
- send_r_bad_request(req);
- return 0;
-@@ -224,7 +224,7 @@
-
- if (req->status < BODY_READ) {
- /* only reached if request is split across more than one packet */
-- unsigned int buf_bytes_left;
-+ off_t buf_bytes_left;
-
- buf_bytes_left = CLIENT_STREAM_SIZE - req->client_stream_pos;
- if (buf_bytes_left < 1 || buf_bytes_left > CLIENT_STREAM_SIZE) {
-@@ -273,7 +273,7 @@
- DEBUG(DEBUG_HEADER_READ) {
- log_error_time();
- req->client_stream[req->client_stream_pos] = '\0';
-- fprintf(stderr, "%s:%d -- We read %d bytes: \"%s\"\n",
-+ fprintf(stderr, "%s:%d -- We read " PRINTF_OFF_T_ARG " bytes: \"%s\"\n",
- __FILE__, __LINE__, bytes,
- #ifdef VERY_FASCIST_LOGGING2
- req->client_stream + req->client_stream_pos - bytes
-@@ -309,8 +309,8 @@
-
- int read_body(request * req)
- {
-- int bytes_read;
-- unsigned int bytes_to_read, bytes_free;
-+ off_t bytes_read;
-+ off_t bytes_to_read, bytes_free;
-
- bytes_free = BUFFER_SIZE - (req->header_end - req->header_line);
- bytes_to_read = req->filesize - req->filepos;
-@@ -367,8 +367,8 @@
-
- int write_body(request * req)
- {
-- int bytes_written;
-- unsigned int bytes_to_write = req->header_end - req->header_line;
-+ off_t bytes_written;
-+ off_t bytes_to_write = req->header_end - req->header_line;
-
- if (req->filepos + bytes_to_write > req->filesize)
- bytes_to_write = req->filesize - req->filepos;
-@@ -402,7 +402,7 @@
- }
- DEBUG(DEBUG_HEADER_READ) {
- log_error_time();
-- fprintf(stderr, "%s:%d - wrote %d bytes of CGI body. %ld of %ld\n",
-+ fprintf(stderr, "%s:%d - wrote " PRINTF_OFF_T_ARG " bytes of CGI body. " PRINTF_OFF_T_ARG " of " PRINTF_OFF_T_ARG "\n",
- __FILE__, __LINE__,
- bytes_written, req->filepos, req->filesize);
- }
-@@ -417,7 +417,7 @@
-
- req->header_line[bytes_written] = '\0';
- fprintf(stderr,
-- "%s:%d - wrote %d bytes (%s). %lu of %lu\n",
-+ "%s:%d - wrote " PRINTF_OFF_T_ARG " bytes (%s). " PRINTF_OFF_T_ARG " of " PRINTF_OFF_T_ARG "\n",
- __FILE__, __LINE__, bytes_written,
- req->header_line, req->filepos, req->filesize);
- req->header_line[bytes_written] = c;
-Index: boa-0.94.14rc21/src/request.c
-===================================================================
---- boa-0.94.14rc21.orig/src/request.c 2007-11-03 00:51:46.000000000 -0400
-+++ boa-0.94.14rc21/src/request.c 2007-11-03 01:05:20.000000000 -0400
-@@ -259,14 +259,14 @@
-
- static void sanitize_request(request * req, int new_req)
- {
-- static unsigned int bytes_to_zero = offsetof(request, fd);
-+ static off_t bytes_to_zero = offsetof(request, fd);
-
- if (new_req) {
- req->kacount = ka_max;
- req->time_last = current_time;
- req->client_stream_pos = 0;
- } else {
-- unsigned int bytes_to_move =
-+ off_t bytes_to_move =
- req->client_stream_pos - req->parse_pos;
-
- if (bytes_to_move) {
-@@ -282,7 +282,7 @@
-
- DEBUG(DEBUG_REQUEST) {
- log_error_time();
-- fprintf(stderr, "req: %p, offset: %u\n", (void *) req,
-+ fprintf(stderr, "req: %p, offset: " PRINTF_OFF_T_ARG "\n", (void *) req,
- bytes_to_zero);
- }
-
-Index: boa-0.94.14rc21/src/util.c
-===================================================================
---- boa-0.94.14rc21.orig/src/util.c 2007-11-03 01:05:20.000000000 -0400
-+++ boa-0.94.14rc21/src/util.c 2007-11-03 01:05:20.000000000 -0400
-@@ -497,7 +497,7 @@
- memcpy(p, day_tab + t->tm_wday * 4, 4);
- }
-
--char *simple_itoa(unsigned int i)
-+char *simple_itoa(uint64_t i)
- {
- /* 21 digits plus null terminator, good for 64-bit or smaller ints
- * for bigger ints, use a bigger buffer!