1122237Simp/*-
2131807Sru * Copyright (c) 2004 Pawel Jakub Dawidek <pjd@FreeBSD.org>
3122237Simp * All rights reserved.
4122237Simp *
5122237Simp * Redistribution and use in source and binary forms, with or without
6122237Simp * modification, are permitted provided that the following conditions
7122237Simp * are met:
8122237Simp * 1. Redistributions of source code must retain the above copyright
9122237Simp *    notice, this list of conditions and the following disclaimer.
10122237Simp * 2. Redistributions in binary form must reproduce the above copyright
11122237Simp *    notice, this list of conditions and the following disclaimer in the
12122237Simp *    documentation and/or other materials provided with the distribution.
13204790Sjoel *
14122237Simp * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
15122237Simp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16204790Sjoel * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17204790Sjoel * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
18204790Sjoel * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19204790Sjoel * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20204790Sjoel * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21204790Sjoel * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22204790Sjoel * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23204790Sjoel * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24122237Simp * SUCH DAMAGE.
25141580Sru *
26122237Simp * $FreeBSD$
27164524Sbrueffer */
28122237Simp
29122237Simp#ifndef _GEOM_H_
30122237Simp#define	_GEOM_H_
31122237Simp#define	G_LIB_VERSION	5
32122238Simp
33122237Simp#define	G_FLAG_NONE	0x0000
34164524Sbrueffer#define	G_FLAG_VERBOSE	0x0001
35164524Sbrueffer#define	G_FLAG_LOADKLD	0x0002
36164524Sbrueffer
37164524Sbrueffer#define	G_TYPE_NONE	0x00
38122237Simp#define	G_TYPE_BOOL	0x01
39164524Sbrueffer#define	G_TYPE_STRING	0x02
40164524Sbrueffer#define	G_TYPE_NUMBER	0x03
41164524Sbrueffer#define	G_TYPE_MASK	0x0f
42164524Sbrueffer#define	G_TYPE_DONE	0x10
43164524Sbrueffer#define	G_TYPE_MULTI	0x20
44164524Sbrueffer#define	G_TYPE_NUMMASK	0xff00
45164524Sbrueffer#define	G_TYPE_NUMSHIFT	8
46164524Sbrueffer
47122237Simp#define	G_OPT_MAX	16
48122237Simp#define	G_OPT_DONE(opt)		do { (opt)->go_type |= G_TYPE_DONE; } while (0)
49122237Simp#define	G_OPT_ISDONE(opt)	((opt)->go_type & G_TYPE_DONE)
50122238Simp#define	G_OPT_ISMULTI(opt)	((opt)->go_type & G_TYPE_MULTI)
51122238Simp#define	G_OPT_TYPE(opt)		((opt)->go_type & G_TYPE_MASK)
52122238Simp#define	G_OPT_NUM(opt)		(((opt)->go_type & G_TYPE_NUMMASK) >> G_TYPE_NUMSHIFT)
53122238Simp#define	G_OPT_NUMINC(opt)	((opt)->go_type += (1 << G_TYPE_NUMSHIFT))
54122238Simp
55122238Simp#define	G_VAL_OPTIONAL	((void *)-1)
56122237Simp
57122237Simp#define G_OPT_SENTINEL	{ '\0', NULL, NULL, G_TYPE_NONE }
58122237Simp#define G_NULL_OPTS	{ G_OPT_SENTINEL }
59131807Sru#define	G_CMD_SENTINEL	{ NULL, 0, NULL, G_NULL_OPTS, NULL }
60122237Simp
61131807Srustruct g_option {
62122237Simp	char		 go_char;
63131807Sru	const char	*go_name;
64122237Simp	const void	*go_val;
65122237Simp	unsigned	 go_type;
66122237Simp};
67122237Simp
68122237Simpstruct g_command {
69122237Simp	const char	*gc_name;
70131807Sru	unsigned	 gc_flags;
71122237Simp	void		(*gc_func)(struct gctl_req *, unsigned);
72122237Simp	struct g_option	gc_options[G_OPT_MAX];
73122237Simp	const char	*gc_usage;
74122240Shmp};
75122240Shmp#endif	/* !_GEOM_H_ */
76122240Shmp