xref: /titanic_41/usr/src/cmd/logadm/opts.h (revision 6a634c9dca3093f3922e4b7ab826d7bdf17bf78e)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
23  *
24  * logadm/opts.h -- public definitions for opts module
25  */
26 
27 #ifndef	_LOGADM_OPTS_H
28 #define	_LOGADM_OPTS_H
29 
30 #ifdef	__cplusplus
31 extern "C" {
32 #endif
33 
34 /* various types of options we allow */
35 enum opttype {
36 	OPTTYPE_BOOLEAN,	/* simple boolean flag */
37 	OPTTYPE_INT,		/* simple number */
38 	OPTTYPE_STRING		/* string (like a pathname) */
39 };
40 
41 struct opts;
42 
43 /* info that drives option parsing (table of these is passed to opts_init()) */
44 struct optinfo {
45 	char *oi_o;	/* the option */
46 	enum opttype oi_t;	/* the type of this option */
47 	/* parser, if set, is called to parse optarg */
48 	off_t (*oi_parser)(const char *o, const char *optarg);
49 	int oi_flags;
50 };
51 
52 /* flags for struct optinfo */
53 #define	OPTF_CLI	1
54 #define	OPTF_CONF	2
55 
56 void opts_init(struct optinfo *table, int numentries);
57 struct opts *opts_parse(struct opts *, char **args, int flags);
58 void opts_free(struct opts *opts);
59 void opts_set(struct opts *opts, const char *o, const char *optarg);
60 int opts_count(struct opts *opts, const char *options);
61 const char *opts_optarg(struct opts *opts, const char *o);
62 off_t opts_optarg_int(struct opts *opts, const char *o);
63 struct fn_list *opts_cmdargs(struct opts *opts);
64 struct opts *opts_merge(struct opts *back, struct opts *front);
65 
66 #define	OPTP_NOW (-1)
67 #define	OPTP_NEVER (-2)
68 
69 void opts_print(struct opts *opts, FILE *stream, char *exclude);
70 void opts_printword(const char *word, FILE *stream);
71 
72 extern struct optinfo Opttable[];
73 extern int Opttable_cnt;
74 
75 #ifdef	__cplusplus
76 }
77 #endif
78 
79 #endif	/* _LOGADM_OPTS_H */
80