1/*-
2 * Copyright (c) 2004 Pawel Jakub Dawidek <pjd@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD$
27 */
28
29#ifndef _GEOM_H_
30#define	_GEOM_H_
31#define	G_LIB_VERSION	5
32
33#define	G_FLAG_NONE	0x0000
34#define	G_FLAG_VERBOSE	0x0001
35#define	G_FLAG_LOADKLD	0x0002
36
37#define	G_TYPE_NONE	0x00
38#define	G_TYPE_BOOL	0x01
39#define	G_TYPE_STRING	0x02
40#define	G_TYPE_NUMBER	0x03
41#define	G_TYPE_MASK	0x0f
42#define	G_TYPE_DONE	0x10
43#define	G_TYPE_MULTI	0x20
44#define	G_TYPE_NUMMASK	0xff00
45#define	G_TYPE_NUMSHIFT	8
46
47#define	G_OPT_MAX	16
48#define	G_OPT_DONE(opt)		do { (opt)->go_type |= G_TYPE_DONE; } while (0)
49#define	G_OPT_ISDONE(opt)	((opt)->go_type & G_TYPE_DONE)
50#define	G_OPT_ISMULTI(opt)	((opt)->go_type & G_TYPE_MULTI)
51#define	G_OPT_TYPE(opt)		((opt)->go_type & G_TYPE_MASK)
52#define	G_OPT_NUM(opt)		(((opt)->go_type & G_TYPE_NUMMASK) >> G_TYPE_NUMSHIFT)
53#define	G_OPT_NUMINC(opt)	((opt)->go_type += (1 << G_TYPE_NUMSHIFT))
54
55#define	G_VAL_OPTIONAL	((void *)-1)
56
57#define G_OPT_SENTINEL	{ '\0', NULL, NULL, G_TYPE_NONE }
58#define G_NULL_OPTS	{ G_OPT_SENTINEL }
59#define	G_CMD_SENTINEL	{ NULL, 0, NULL, G_NULL_OPTS, NULL }
60
61struct g_option {
62	char		 go_char;
63	const char	*go_name;
64	const void	*go_val;
65	unsigned	 go_type;
66};
67
68struct g_command {
69	const char	*gc_name;
70	unsigned	 gc_flags;
71	void		(*gc_func)(struct gctl_req *, unsigned);
72	struct g_option	gc_options[G_OPT_MAX];
73	const char	*gc_usage;
74};
75#endif	/* !_GEOM_H_ */
76