1.\" $NetBSD: libbozohttpd.3,v 1.7 2024/02/04 05:43:05 mrg Exp $ 2.\" 3.\" $eterna: libbozohttpd.3,v 1.2 2010/05/10 02:48:23 mrg Exp $ 4.\" 5.\" Copyright (c) 2009, 2021 The NetBSD Foundation, Inc. 6.\" All rights reserved. 7.\" 8.\" This manual page is derived from software contributed to The 9.\" NetBSD Foundation by Alistair Crooks (agc@NetBSD.org) 10.\" 11.\" Redistribution and use in source and binary forms, with or without 12.\" modification, are permitted provided that the following conditions 13.\" are met: 14.\" 1. Redistributions of source code must retain the above copyright 15.\" notice, this list of conditions and the following disclaimer. 16.\" 2. Redistributions in binary form must reproduce the above copyright 17.\" notice, this list of conditions and the following disclaimer in the 18.\" documentation and/or other materials provided with the distribution. 19.\" 20.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 21.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 24.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30.\" POSSIBILITY OF SUCH DAMAGE. 31.\" 32.Dd February 11, 2021 33.Dt LIBBOZOHTTPD 3 34.Os 35.Sh NAME 36.Nm libbozohttpd 37.Nd embedded web server library 38.Sh LIBRARY 39.Lb libbozohttpd 40.Sh SYNOPSIS 41.In bozohttpd.h 42.Ft int 43.Fo bozo_set_pref 44.Fa "bozohttpd_t *httpd" "bozoprefs_t *prefs" "char *name" "char *value" 45.Fc 46.Ft char * 47.Fo bozo_get_pref 48.Fa "bozoprefs_t *prefs" "char *name" 49.Fc 50.Ft int 51.Fo bozo_set_defaults 52.Fa "bozohttpd_t *httpd" "bozoprefs_t *prefs" 53.Fc 54.Ft void 55.Fo bozo_setup 56.Fa "bozohttpd_t *httpd" "bozoprefs_t *prefs" "const char *vhost" "char *slash" 57.Fc 58.Ft bozo_httpreq_t * 59.Fo bozo_read_request 60.Fa "bozohttpd_t *httpd" 61.Fc 62.Ft void 63.Fo bozo_process_request 64.Fa "bozo_httpreq_t *" 65.Fc 66.Ft void 67.Fo bozo_clean_request 68.Fa "bozo_httpreq_t *" 69.Fc 70.Ft void 71.Fo bozo_cleanup 72.Fa "bozohttpd_t *httpd" "bozoprefs_t *prefs" 73.Fc 74.Sh DESCRIPTION 75.Nm 76is a library interface to the 77.Xr bozohttpd 8 78web server. 79The 80.Nm 81library can be used to embed a webserver 82in your applications. 83.Pp 84Normal operation sees the 85.Nm 86process be initialised using the 87.Fn bozo_set_defaults 88function, which will set up the default port 89and other internal settings, allocating 90any necessary space as needed. 91The 92.Fn bozo_set_defaults 93function returns 1 on sucess, 0 on failure. 94.Pp 95The 96.Fn bozo_setup 97function is used to specify the virtual host name 98for the web server. 99A NULL host name will mean that 100.Nm 101will use the local value for the host name, 102as returned by 103.Xr gethostname 3 . 104This virtual hostname should be a fully qualified domain name. 105The final argument to 106.Fn bozo_setup 107is the name of the directory to serve as the root 108directory of the web server tree. 109.Pp 110Once the server has been set up, it serves 111requests by using the 112.Fn bozo_read_request 113function, which returns a pointer to a request structure, 114and 115.Fn bozo_process_request , 116which deals with the request, and answers the client. 117The request space is de-allocated 118using the 119.Fn bozo_clean_request 120function. 121.Pp 122Preferences are set 123using the function 124.Fn bozo_set_pref 125function 126and queried using the two 127.Fn bozo_get_pref 128function. 129This is the main interface for selecting options, and for 130setting preferences. 131The memory allocated by 132.Fn bozo_setup 133for both the httpd structure and the preferences will be freed. 134.Sh SEE ALSO 135.Xr gethostname 3 , 136.Xr ssl 3 , 137.Xr services 5 , 138.Xr httpd 8 139.Sh HISTORY 140The 141.Nm 142library first appeared in 143.Nx 6.0 . 144.Sh AUTHORS 145.An Matthew R. Green Aq Mt mrg@eterna23.net 146.An Alistair Crooks Aq Mt agc@NetBSD.org 147wrote this high-level interface. 148.Pp 149This manual page was written by 150.An Alistair Crooks . 151