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