xref: /titanic_50/usr/src/cmd/mdb/common/mdb/mdb_argvec.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_MDB_ARGVEC_H
28 #define	_MDB_ARGVEC_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/types.h>
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 struct mdb_arg;
39 
40 typedef struct mdb_argvec {
41 	struct mdb_arg *a_data;		/* Array of arguments */
42 	size_t a_nelems;		/* Number of valid elements */
43 	size_t a_size;			/* Array size */
44 } mdb_argvec_t;
45 
46 /* see mdb_modapi.h for 1-6 */
47 #define	MDB_OPT_SUBOPTS	7		/* Option requires a mdb_subopt_t */
48 					/* list and a value argument */
49 
50 typedef struct mdb_subopt {
51 	uint_t sop_flag;		/* Option flag */
52 	const char *sop_str;		/* Sub-option name */
53 	int sop_index;			/* Index of subopt in argument */
54 } mdb_subopt_t;
55 
56 typedef struct mdb_opt {
57 	char opt_char;			/* Option name */
58 	void *opt_valp;			/* Value storage pointer */
59 	uint_t opt_bits;		/* Bits to set or clear for booleans */
60 	boolean_t *opt_flag;		/* pointer to flag (uintptr_set) */
61 	mdb_subopt_t *opt_subopts;	/* List of mdb_subopt_t */
62 	uint_t opt_type;		/* Option type (see above) */
63 } mdb_opt_t;
64 
65 #ifdef _MDB
66 
67 #ifdef	_BIG_ENDIAN
68 #ifdef	_LP64
69 #define	MDB_INIT_CHAR(x)	((const char *)((uintptr_t)(uchar_t)(x) << 56))
70 #else	/* _LP64 */
71 #define	MDB_INIT_CHAR(x)	((const char *)((uintptr_t)(uchar_t)(x) << 24))
72 #endif	/* _LP64 */
73 #else	/* _BIG_ENDIAN */
74 #define	MDB_INIT_CHAR(x)	((const char *)(uchar_t)(x))
75 #endif	/* _BIG_ENDIAN */
76 #define	MDB_INIT_STRING(x)	((const char *)(x))
77 
78 extern void mdb_argvec_create(mdb_argvec_t *);
79 extern void mdb_argvec_destroy(mdb_argvec_t *);
80 extern void mdb_argvec_append(mdb_argvec_t *, const struct mdb_arg *);
81 extern void mdb_argvec_reset(mdb_argvec_t *);
82 extern void mdb_argvec_zero(mdb_argvec_t *);
83 extern void mdb_argvec_copy(mdb_argvec_t *, const mdb_argvec_t *);
84 
85 extern char *mdb_argv_to_str(int, const struct mdb_arg *);
86 
87 #endif	/* _MDB */
88 
89 #ifdef	__cplusplus
90 }
91 #endif
92 
93 #endif	/* _MDB_ARGVEC_H */
94