Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/libexec/httpd import bozohttpd 20100509. it has these changes:



details:   https://anonhg.NetBSD.org/src/rev/5195ef674734
branches:  trunk
changeset: 754716:5195ef674734
user:      mrg <mrg%NetBSD.org@localhost>
date:      Mon May 10 03:30:04 2010 +0000

description:
import bozohttpd 20100509.  it has these changes:
o  major rework and clean up of internal interfaces.  move the main
   program into main.c, the remaining parts are useable as library.
   add bindings for lua.  by Alistair G. Crooks <agc%netbsd.org@localhost>
o  fix http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=566325


special thanks to al for the majority of these changes.

diffstat:

 libexec/httpd/libbozohttpd/Makefile       |   36 +++
 libexec/httpd/libbozohttpd/libbozohttpd.3 |  143 ++++++++++++
 libexec/httpd/libbozohttpd/shlib_version  |    2 +
 libexec/httpd/lua/Makefile                |   39 +++
 libexec/httpd/lua/bozo.lua                |  162 ++++++++++++++
 libexec/httpd/lua/glue.c                  |  276 ++++++++++++++++++++++++
 libexec/httpd/lua/optparse.lua            |  123 ++++++++++
 libexec/httpd/lua/shlib_version           |    2 +
 libexec/httpd/main.c                      |  340 ++++++++++++++++++++++++++++++
 9 files changed, 1123 insertions(+), 0 deletions(-)

diffs (truncated from 1159 to 300 lines):

diff -r 8762bff1ca5c -r 5195ef674734 libexec/httpd/libbozohttpd/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/libexec/httpd/libbozohttpd/Makefile       Mon May 10 03:30:04 2010 +0000
@@ -0,0 +1,36 @@
+#      $eterna: Makefile,v 1.1 2010/05/10 02:24:31 mrg Exp $
+
+.PATH: $(.CURDIR)/..
+
+# build bozohttpd library
+LIB=   bozohttpd
+COPTS+=        -I$(.CURDIR)/..
+
+COPTS+=        -DDO_HTPASSWD
+CPPFLAGS+= -DDO_HTPASSWD
+SRCS=  bozohttpd.c ssl-bozo.c auth-bozo.c cgi-bozo.c daemon-bozo.c
+SRCS+= tilde-luzah-bozo.c dir-index-bozo.c content-bozo.c
+
+LDADD= -lcrypt
+DPADD= ${LIBCRYPT}
+
+MAN=   libbozohttpd.3
+WARNS= 4
+
+INCS=  bozohttpd.h
+INCSDIR=       /usr/include
+
+.include <bsd.own.mk>
+
+.if ${MKCRYPTO} != "no"
+
+LDADD+=        -lssl -lcrypto
+DPADD+=        ${LIBSSL} ${LIBCRYPTO}
+
+.else
+
+COPTS+=        -DNO_SSL_SUPPORT
+
+.endif
+
+.include <bsd.lib.mk>
diff -r 8762bff1ca5c -r 5195ef674734 libexec/httpd/libbozohttpd/libbozohttpd.3
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/libexec/httpd/libbozohttpd/libbozohttpd.3 Mon May 10 03:30:04 2010 +0000
@@ -0,0 +1,143 @@
+.\" $NetBSD: libbozohttpd.3,v 1.1.1.1 2010/05/10 03:30:04 mrg Exp $
+.\"
+.\" $eterna: libbozohttpd.3,v 1.2 2010/05/10 02:48:23 mrg Exp $
+.\"
+.\" Copyright (c) 2009 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This manual page is derived from software contributed to The
+.\" NetBSD Foundation by Alistair Crooks (agc%NetBSD.org@localhost)
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
+.\"
+.Dd November 5, 2009
+.Dt LIBBOZOHTTPD 3
+.Os
+.Sh NAME
+.Nm libbozohttpd
+.Nd embedded web server library
+.Sh LIBRARY
+.Lb libbozohttpd
+.Sh SYNOPSIS
+.In bozohttpd.h
+.Ft int
+.Fo bozo_set_pref
+.Fa "bozoprefs_t *prefs" "char *name" "char *value"
+.Fc
+.Ft char *
+.Fo bozo_get_pref
+.Fa "bozoprefs_t *prefs" "char *name"
+.Fc
+.Ft int
+.Fo bozo_set_defaults
+.Fa "bozohttpd_t *httpd" "bozoprefs_t *prefs"
+.Fc
+.Ft void
+.Fo bozo_setup
+.Fa "bozohttpd_t *httpd" "bozoprefs_t *prefs" "const char *vhost" "char *slash"
+.Fc
+.Ft bozo_httpreq_t *
+.Fo bozo_read_request
+.Fa "bozohttpd_t *httpd"
+.Fc
+.Ft void
+.Fo bozo_process_request
+.Fa "bozo_httpreq_t *"
+.Fc
+.Ft void
+.Fo bozo_clean_request
+.Fa "bozo_httpreq_t *"
+.Fc
+.Sh DESCRIPTION
+.Nm
+is a library interface to the
+.Xr bozohttpd 8
+web server.
+The
+.Nm
+library can be used to embed a webserver
+in your applications.
+.Pp
+Normal operation sees the
+.Nm
+process be initialised using the
+.Fn bozo_set_defaults
+function, which will set up the default port
+and other internal settings, allocating
+any necessary space as needed.
+The
+.Fn bozo_set_defaults
+function returns 1 on sucess, 0 on failure.
+.Pp
+The
+.Fn bozo_setup
+function is used to specify the virtual host name
+for the web server.
+A NULL host name will mean that
+.Nm
+will use the local value for the host name,
+as returned by
+.Xr gethostname 3 .
+This virtual hostname should be a fully qualified domain name.
+The final argument to
+.Fn bozo_setup
+is the name of the directory to serve as the root
+directory of the web server tree.
+.Pp
+Once the server has been set up, it serves
+requests by using the
+.Fn bozo_read_request
+function, which returns a pointer to a request structure,
+and
+.Fn bozo_process_request ,
+which deals with the request, and answers the client.
+The request space is de-allocated
+using the
+.Fn bozo_clean_request
+function.
+.Pp
+Preferences are set
+using the function
+.Fn bozo_set_pref
+function
+and queried using the two
+.Fn bozo_get_pref
+function.
+This is the main interface for selecting options, and for
+setting preferences.
+.Sh SEE ALSO
+.Xr gethostname 3 ,
+.Xr ssl 3 ,
+.Xr services 5 ,
+.Xr httpd 8
+.Sh HISTORY
+The
+.Nm
+library first appeared in
+.Nx 6.0 .
+.Sh AUTHORS
+.An Matthew R. Green Aq mrg%eterna.com.au@localhost
+.An Alistair Crooks Aq agc%NetBSD.org@localhost
+wrote this high-level interface.
+.Pp
+This manual page was written by
+.An Alistair Crooks .
diff -r 8762bff1ca5c -r 5195ef674734 libexec/httpd/libbozohttpd/shlib_version
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/libexec/httpd/libbozohttpd/shlib_version  Mon May 10 03:30:04 2010 +0000
@@ -0,0 +1,2 @@
+major=0
+minor=0
diff -r 8762bff1ca5c -r 5195ef674734 libexec/httpd/lua/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/libexec/httpd/lua/Makefile        Mon May 10 03:30:04 2010 +0000
@@ -0,0 +1,39 @@
+#PREFIX=/Users/agcrooks
+PREFIX=/usr
+
+#LIBDIR=/usr/lib
+
+LIB=luabozohttpd
+SRCS=glue.c
+MKMAN=no
+CPPFLAGS+=-g -I${PREFIX}/pkg/include
+LDADD+= -lbozohttpd
+WARNS=4
+CLEANFILES+=   a a.sig
+
+.include <bsd.lib.mk>
+.include <bsd.own.mk>
+
+LUABOZOOBJDIR != cd ${.CURDIR} && ${PRINTOBJDIR}
+
+OPSYS!= uname -s
+
+.if ${OPSYS} == "Darwin"
+.sinclude <bsd.warns.mk>
+
+lib${LIB}.dylib:
+       libtool -dynamic -o ${.TARGET} ${OBJS} ${PREFIX}/pkg/lib/liblua.dylib /usr/lib/libc.dylib ${PREFIX}/pkg/lib/libbozohttpd.dylib
+
+t: lib${LIB}.dylib
+       cp Makefile a
+       ./bozo.lua --sign --detached a
+       ./bozo.lua --verify a.sig
+
+.else
+t:
+       cp Makefile a
+       env LD_LIBRARY_PATH=${LUABOZOOBJDIR}:/lib:/usr/lib:${PREFIX}/lib \
+               ./bozo.lua --sign --detached a
+       env LD_LIBRARY_PATH=${LUABOZOOBJDIR}:/lib:/usr/lib:${PREFIX}/lib \
+               ./bozo.lua --verify a.sig
+.endif
diff -r 8762bff1ca5c -r 5195ef674734 libexec/httpd/lua/bozo.lua
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/libexec/httpd/lua/bozo.lua        Mon May 10 03:30:04 2010 +0000
@@ -0,0 +1,162 @@
+#! /usr/bin/env lua
+
+--
+-- Copyright (c) 2009 The NetBSD Foundation, Inc.
+-- All rights reserved.
+--
+-- This code is derived from software contributed to The NetBSD Foundation
+-- by Alistair Crooks (agc%netbsd.org@localhost)
+--
+-- Redistribution and use in source and binary forms, with or without
+-- modification, are permitted provided that the following conditions
+-- are met:
+-- 1. Redistributions of source code must retain the above copyright
+--    notice, this list of conditions and the following disclaimer.
+-- 2. Redistributions in binary form must reproduce the above copyright
+--    notice, this list of conditions and the following disclaimer in the
+--    documentation and/or other materials provided with the distribution.
+--
+-- THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+-- ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+-- TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+-- PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+-- BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+-- POSSIBILITY OF SUCH DAMAGE.
+--
+
+-- command line args
+dofile "optparse.lua"
+
+opt = OptionParser{usage="%prog [options] root [vhost]", version="20091105"}                           
+
+opt.add_option{"-C", "--cgimap", action="store", dest="cgimap", help="--cgimap 's t'"}
+opt.add_option{"-H", "--hide-dots", action="store_true", dest="hidedots", help="--hide-dots"}
+opt.add_option{"-I", "--portnum", action="store", dest="portnum", help="--portnum number"}
+opt.add_option{"-M", "--dynamicmime", action="store", dest="dynmime", help="--dynamicmime 'suffix type a b'"}
+opt.add_option{"-S", "--server-software", action="store", dest="serversw", help="--server-software name"}
+opt.add_option{"-U", "--username", action="store", dest="username", help="--username name"}
+opt.add_option{"-V", "--unknown-slash", action="store_true", dest="unknown", help="--unknown-slash"}
+opt.add_option{"-X", "--dir-index", action="store_true", dest="dirindex", help="--dir-index"}
+opt.add_option{"-Z", "--ssl", action="store", dest="ssl", help="--ssl 'cert priv'"}
+opt.add_option{"-b", "--background", action="store", dest="background", help="--background count"}
+opt.add_option{"-c", "--cgibin", action="store", dest="cgibin", help="--cgibin bin"}
+opt.add_option{"-e", "--dirtyenv", action="store_true", dest="dirtyenv", help="--dirtyenv"}
+opt.add_option{"-f", "--foreground", action="store_true", dest="foreground", help="--foreground"}
+opt.add_option{"-i", "--bindaddr", action="store", dest="bindaddress", help="--bindaddr address"}
+opt.add_option{"-n", "--numeric", action="store_true", dest="numeric", help="--numeric"}
+opt.add_option{"-p", "--public-html", action="store", dest="public_html", help="--public-html dir"}
+opt.add_option{"-r", "--trusted-referal", action="store_true", dest="trustedref", help="trusted referal"}
+opt.add_option{"-s", "--logtostderr", action="store_true", dest="logstderr", help="log to stderr"}
+opt.add_option{"-t", "--chroot", action="store", dest="chroot", help="--chroot dir"}
+opt.add_option{"-u", "--enable-users", action="store_true", dest="enableusers", help="--enable-users"}
+opt.add_option{"-v", "--virtbase", action="store", dest="virtbase", help="virtual base location"}
+opt.add_option{"-x", "--index-html", action="store", dest="indexhtml", help="index.html name"}
+
+-- caller lua script



Home | Main Index | Thread Index | Old Index