xref: /minix3/external/bsd/bind/dist/lib/isc/include/isc/httpd.h (revision 00b67f09dd46474d133c95011a48590a8e8f94c7)
1 /*	$NetBSD: httpd.h,v 1.5 2014/12/10 04:38:00 christos Exp $	*/
2 
3 /*
4  * Copyright (C) 2006-2008, 2014  Internet Systems Consortium, Inc. ("ISC")
5  *
6  * Permission to use, copy, modify, and/or distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
11  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
12  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
13  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
14  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
15  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 /* Id: httpd.h,v 1.9 2008/08/08 05:06:49 marka Exp  */
20 
21 #ifndef ISC_HTTPD_H
22 #define ISC_HTTPD_H 1
23 
24 /*! \file */
25 
26 #include <isc/event.h>
27 #include <isc/eventclass.h>
28 #include <isc/types.h>
29 #include <isc/mutex.h>
30 #include <isc/task.h>
31 #include <isc/time.h>
32 
33 /*%
34  * HTTP urls.  These are the URLs we manage, and the function to call to
35  * provide the data for it.  We pass in the base url (so the same function
36  * can handle multiple requests), and a structure to fill in to return a
37  * result to the client.  We also pass in a pointer to be filled in for
38  * the data cleanup function.
39  */
40 struct isc_httpdurl {
41 	char			       *url;
42 	isc_httpdaction_t	       *action;
43 	void			       *action_arg;
44 	isc_boolean_t			isstatic;
45 	isc_time_t			loadtime;
46 	ISC_LINK(isc_httpdurl_t)	link;
47 };
48 
49 #define HTTPD_EVENTCLASS		ISC_EVENTCLASS(4300)
50 #define HTTPD_SHUTDOWN			(HTTPD_EVENTCLASS + 0x0001)
51 
52 #define ISC_HTTPDMGR_FLAGSHUTTINGDOWN	0x00000001
53 
54 /*
55  * Create a new http daemon which will send, once every time period,
56  * a http-like header followed by HTTP data.
57  */
58 isc_result_t
59 isc_httpdmgr_create(isc_mem_t *mctx, isc_socket_t *sock, isc_task_t *task,
60 		    isc_httpdclientok_t *client_ok,
61 		    isc_httpdondestroy_t *ondestory, void *cb_arg,
62 		    isc_timermgr_t *tmgr, isc_httpdmgr_t **httpdp);
63 
64 void
65 isc_httpdmgr_shutdown(isc_httpdmgr_t **httpdp);
66 
67 isc_result_t
68 isc_httpdmgr_addurl(isc_httpdmgr_t *httpdmgr, const char *url,
69 		    isc_httpdaction_t *func, void *arg);
70 
71 isc_result_t
72 isc_httpdmgr_addurl2(isc_httpdmgr_t *httpdmgr, const char *url,
73 		     isc_boolean_t isstatic,
74 		     isc_httpdaction_t *func, void *arg);
75 
76 isc_result_t
77 isc_httpd_response(isc_httpd_t *httpd);
78 
79 isc_result_t
80 isc_httpd_addheader(isc_httpd_t *httpd, const char *name,
81 		    const char *val);
82 
83 isc_result_t
84 isc_httpd_addheaderuint(isc_httpd_t *httpd, const char *name, int val);
85 
86 isc_result_t isc_httpd_endheaders(isc_httpd_t *httpd);
87 
88 #endif /* ISC_HTTPD_H */
89