Merge commit 'b1e7e97d3b60469b243b3b2e22c7d8cbd11c7c90'
[unleashed.git] / usr / src / cmd / logadm / opts.h
blobd28581bc492a44b1a3556d10529cb4fae95eed52
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
22 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
24 * logadm/opts.h -- public definitions for opts module
27 #ifndef _LOGADM_OPTS_H
28 #define _LOGADM_OPTS_H
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
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) */
41 struct opts;
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;
52 /* flags for struct optinfo */
53 #define OPTF_CLI 1
54 #define OPTF_CONF 2
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);
66 #define OPTP_NOW (-1)
67 #define OPTP_NEVER (-2)
69 void opts_print(struct opts *opts, FILE *stream, char *exclude);
70 void opts_printword(const char *word, FILE *stream);
72 extern struct optinfo Opttable[];
73 extern int Opttable_cnt;
75 #ifdef __cplusplus
77 #endif
79 #endif /* _LOGADM_OPTS_H */