105c91076SPawel Jakub Dawidek /*- 2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 31de7b4b8SPedro F. Giffuni * 405c91076SPawel Jakub Dawidek * Copyright (c) 2004 Pawel Jakub Dawidek <pjd@FreeBSD.org> 505c91076SPawel Jakub Dawidek * All rights reserved. 605c91076SPawel Jakub Dawidek * 705c91076SPawel Jakub Dawidek * Redistribution and use in source and binary forms, with or without 805c91076SPawel Jakub Dawidek * modification, are permitted provided that the following conditions 905c91076SPawel Jakub Dawidek * are met: 1005c91076SPawel Jakub Dawidek * 1. Redistributions of source code must retain the above copyright 1105c91076SPawel Jakub Dawidek * notice, this list of conditions and the following disclaimer. 1205c91076SPawel Jakub Dawidek * 2. Redistributions in binary form must reproduce the above copyright 1305c91076SPawel Jakub Dawidek * notice, this list of conditions and the following disclaimer in the 1405c91076SPawel Jakub Dawidek * documentation and/or other materials provided with the distribution. 1505c91076SPawel Jakub Dawidek * 1605c91076SPawel Jakub Dawidek * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND 1705c91076SPawel Jakub Dawidek * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1805c91076SPawel Jakub Dawidek * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1905c91076SPawel Jakub Dawidek * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE 2005c91076SPawel Jakub Dawidek * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2105c91076SPawel Jakub Dawidek * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2205c91076SPawel Jakub Dawidek * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2305c91076SPawel Jakub Dawidek * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2405c91076SPawel Jakub Dawidek * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2505c91076SPawel Jakub Dawidek * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2605c91076SPawel Jakub Dawidek * SUCH DAMAGE. 2705c91076SPawel Jakub Dawidek */ 2805c91076SPawel Jakub Dawidek 2905c91076SPawel Jakub Dawidek #ifndef _GEOM_H_ 3005c91076SPawel Jakub Dawidek #define _GEOM_H_ 31946e2f35SPawel Jakub Dawidek #define G_LIB_VERSION 5 3205c91076SPawel Jakub Dawidek 3368bff4a0SKirk McKusick /* 3468bff4a0SKirk McKusick * The G_FLAG_VERBOSE flag on a command specification means that the 35407a0eacSGordon Bergling * command will accept a -v option and the GEOM framework will print 3668bff4a0SKirk McKusick * out status information after the command when it is run with -v. 3768bff4a0SKirk McKusick * Additionally a GEOM command can explicitly specify a -v option and 3868bff4a0SKirk McKusick * handle it as it would any other option. If both a -v option and 3968bff4a0SKirk McKusick * G_FLAG_VERBOSE are specified for a command then both types of verbose 4068bff4a0SKirk McKusick * information will be output when that command is run with -v. 4168bff4a0SKirk McKusick * 4268bff4a0SKirk McKusick * When the G_FLAG_LOADKLD is specified for a command, the GEOM kernel 4368bff4a0SKirk McKusick * module will be loaded when that command is run if it has not yet been 4468bff4a0SKirk McKusick * loaded. This flag is typically specified for the `create' command. 4568bff4a0SKirk McKusick */ 4605c91076SPawel Jakub Dawidek #define G_FLAG_NONE 0x0000 4705c91076SPawel Jakub Dawidek #define G_FLAG_VERBOSE 0x0001 4805c91076SPawel Jakub Dawidek #define G_FLAG_LOADKLD 0x0002 4905c91076SPawel Jakub Dawidek 506fc60008SPawel Jakub Dawidek #define G_TYPE_NONE 0x00 516fc60008SPawel Jakub Dawidek #define G_TYPE_BOOL 0x01 526fc60008SPawel Jakub Dawidek #define G_TYPE_STRING 0x02 536fc60008SPawel Jakub Dawidek #define G_TYPE_NUMBER 0x03 54dc344ca5SMarcel Moolenaar #define G_TYPE_MASK 0x0f 556fc60008SPawel Jakub Dawidek #define G_TYPE_DONE 0x10 56315fcbf7SPawel Jakub Dawidek #define G_TYPE_MULTI 0x20 57315fcbf7SPawel Jakub Dawidek #define G_TYPE_NUMMASK 0xff00 58315fcbf7SPawel Jakub Dawidek #define G_TYPE_NUMSHIFT 8 5905c91076SPawel Jakub Dawidek 6005c91076SPawel Jakub Dawidek #define G_OPT_MAX 16 616fc60008SPawel Jakub Dawidek #define G_OPT_DONE(opt) do { (opt)->go_type |= G_TYPE_DONE; } while (0) 626fc60008SPawel Jakub Dawidek #define G_OPT_ISDONE(opt) ((opt)->go_type & G_TYPE_DONE) 63315fcbf7SPawel Jakub Dawidek #define G_OPT_ISMULTI(opt) ((opt)->go_type & G_TYPE_MULTI) 646fc60008SPawel Jakub Dawidek #define G_OPT_TYPE(opt) ((opt)->go_type & G_TYPE_MASK) 65315fcbf7SPawel Jakub Dawidek #define G_OPT_NUM(opt) (((opt)->go_type & G_TYPE_NUMMASK) >> G_TYPE_NUMSHIFT) 66315fcbf7SPawel Jakub Dawidek #define G_OPT_NUMINC(opt) ((opt)->go_type += (1 << G_TYPE_NUMSHIFT)) 6705c91076SPawel Jakub Dawidek 687648b1e9SPawel Jakub Dawidek #define G_VAL_OPTIONAL ((void *)-1) 697648b1e9SPawel Jakub Dawidek 7005c91076SPawel Jakub Dawidek #define G_OPT_SENTINEL { '\0', NULL, NULL, G_TYPE_NONE } 7105c91076SPawel Jakub Dawidek #define G_NULL_OPTS { G_OPT_SENTINEL } 72946e2f35SPawel Jakub Dawidek #define G_CMD_SENTINEL { NULL, 0, NULL, G_NULL_OPTS, NULL } 7305c91076SPawel Jakub Dawidek 7405c91076SPawel Jakub Dawidek struct g_option { 7505c91076SPawel Jakub Dawidek char go_char; 7605c91076SPawel Jakub Dawidek const char *go_name; 77a478ea74SPawel Jakub Dawidek const void *go_val; 7805c91076SPawel Jakub Dawidek unsigned go_type; 7905c91076SPawel Jakub Dawidek }; 8005c91076SPawel Jakub Dawidek 8105c91076SPawel Jakub Dawidek struct g_command { 8205c91076SPawel Jakub Dawidek const char *gc_name; 8305c91076SPawel Jakub Dawidek unsigned gc_flags; 8405c91076SPawel Jakub Dawidek void (*gc_func)(struct gctl_req *, unsigned); 8505c91076SPawel Jakub Dawidek struct g_option gc_options[G_OPT_MAX]; 86c979e206SPawel Jakub Dawidek const char *gc_usage; 8705c91076SPawel Jakub Dawidek }; 8805c91076SPawel Jakub Dawidek #endif /* !_GEOM_H_ */ 89