Merge from vendor branch LESS:
[dragonfly.git] / contrib / bind-9.3 / lib / bind / include / isc / ctl.h
1 #ifndef ISC_CTL_H
2 #define ISC_CTL_H
3
4 /*
5  * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
6  * Copyright (c) 1998,1999 by Internet Software Consortium.
7  *
8  * Permission to use, copy, modify, and distribute this software for any
9  * purpose with or without fee is hereby granted, provided that the above
10  * copyright notice and this permission notice appear in all copies.
11  *
12  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
13  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14  * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
15  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
18  * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19  */
20
21 /*
22  * $Id: ctl.h,v 1.1.2.2.4.1 2004/03/09 08:33:30 marka Exp $
23  */
24
25 #include <sys/types.h>
26 #include <sys/socket.h>
27
28 #include <isc/eventlib.h>
29
30 /* Macros. */
31
32 #define CTL_MORE        0x0001  /* More will be / should be sent. */
33 #define CTL_EXIT        0x0002  /* Close connection after this. */
34 #define CTL_DATA        0x0004  /* Go into / this is DATA mode. */
35
36 /* Types. */
37
38 struct ctl_cctx;
39 struct ctl_sctx;
40 struct ctl_sess;
41 struct ctl_verb;
42
43 enum ctl_severity { ctl_debug, ctl_warning, ctl_error };
44
45 typedef void (*ctl_logfunc)(enum ctl_severity, const char *, ...);
46
47 typedef void (*ctl_verbfunc)(struct ctl_sctx *, struct ctl_sess *,
48                              const struct ctl_verb *, const char *,
49                              u_int, const void *, void *);
50
51 typedef void (*ctl_srvrdone)(struct ctl_sctx *, struct ctl_sess *, void *);
52
53 typedef void (*ctl_clntdone)(struct ctl_cctx *, void *, const char *, u_int);
54
55 struct ctl_verb {
56         const char *    name;
57         ctl_verbfunc    func;
58         const char *    help;
59 };
60
61 /* General symbols. */
62
63 #define ctl_logger      __ctl_logger
64
65 #ifdef __GNUC__
66 void                    ctl_logger(enum ctl_severity, const char *, ...)
67                                 __attribute__((__format__(__printf__, 2, 3)));
68 #else
69 void                    ctl_logger(enum ctl_severity, const char *, ...);
70 #endif
71
72 /* Client symbols. */
73
74 #define ctl_client      __ctl_client
75 #define ctl_endclient   __ctl_endclient
76 #define ctl_command     __ctl_command
77
78 struct ctl_cctx *       ctl_client(evContext, const struct sockaddr *, size_t,
79                                    const struct sockaddr *, size_t,
80                                    ctl_clntdone, void *,
81                                    u_int, ctl_logfunc);
82 void                    ctl_endclient(struct ctl_cctx *);
83 int                     ctl_command(struct ctl_cctx *, const char *, size_t,
84                                     ctl_clntdone, void *);
85
86 /* Server symbols. */
87
88 #define ctl_server      __ctl_server
89 #define ctl_endserver   __ctl_endserver
90 #define ctl_response    __ctl_response
91 #define ctl_sendhelp    __ctl_sendhelp
92 #define ctl_getcsctx    __ctl_getcsctx
93 #define ctl_setcsctx    __ctl_setcsctx
94
95 struct ctl_sctx *       ctl_server(evContext, const struct sockaddr *, size_t,
96                                    const struct ctl_verb *,
97                                    u_int, u_int,
98                                    u_int, int, int,
99                                    ctl_logfunc, void *);
100 void                    ctl_endserver(struct ctl_sctx *);
101 void                    ctl_response(struct ctl_sess *, u_int,
102                                      const char *, u_int, const void *,
103                                      ctl_srvrdone, void *,
104                                      const char *, size_t);
105 void                    ctl_sendhelp(struct ctl_sess *, u_int);
106 void *                  ctl_getcsctx(struct ctl_sess *);
107 void *                  ctl_setcsctx(struct ctl_sess *, void *);
108
109 #endif /*ISC_CTL_H*/