xref: /titanic_51/usr/src/cmd/logadm/opts.h (revision 404720a7c203c35b93512f0f6eb5886c4273815f)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*404720a7Sbasabi  * Common Development and Distribution License (the "License").
6*404720a7Sbasabi  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*404720a7Sbasabi  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23*404720a7Sbasabi  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  *
257c478bd9Sstevel@tonic-gate  * logadm/opts.h -- public definitions for opts module
267c478bd9Sstevel@tonic-gate  */
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate #ifndef	_LOGADM_OPTS_H
297c478bd9Sstevel@tonic-gate #define	_LOGADM_OPTS_H
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
347c478bd9Sstevel@tonic-gate extern "C" {
357c478bd9Sstevel@tonic-gate #endif
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate /* various types of options we allow */
387c478bd9Sstevel@tonic-gate enum opttype {
397c478bd9Sstevel@tonic-gate 	OPTTYPE_BOOLEAN,	/* simple boolean flag */
407c478bd9Sstevel@tonic-gate 	OPTTYPE_INT,		/* simple number */
417c478bd9Sstevel@tonic-gate 	OPTTYPE_STRING		/* string (like a pathname) */
427c478bd9Sstevel@tonic-gate };
437c478bd9Sstevel@tonic-gate 
447c478bd9Sstevel@tonic-gate struct opts;
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate /* info that drives option parsing (table of these is passed to opts_init()) */
477c478bd9Sstevel@tonic-gate struct optinfo {
487c478bd9Sstevel@tonic-gate 	char *oi_o;	/* the option */
497c478bd9Sstevel@tonic-gate 	enum opttype oi_t;	/* the type of this option */
507c478bd9Sstevel@tonic-gate 	/* parser, if set, is called to parse optarg */
51*404720a7Sbasabi 	off_t (*oi_parser)(const char *o, const char *optarg);
527c478bd9Sstevel@tonic-gate 	int oi_flags;
537c478bd9Sstevel@tonic-gate };
547c478bd9Sstevel@tonic-gate 
557c478bd9Sstevel@tonic-gate /* flags for struct optinfo */
567c478bd9Sstevel@tonic-gate #define	OPTF_CLI	1
577c478bd9Sstevel@tonic-gate #define	OPTF_CONF	2
587c478bd9Sstevel@tonic-gate 
597c478bd9Sstevel@tonic-gate void opts_init(struct optinfo *table, int numentries);
607c478bd9Sstevel@tonic-gate struct opts *opts_parse(char **args, int flags);
617c478bd9Sstevel@tonic-gate void opts_free(struct opts *opts);
627c478bd9Sstevel@tonic-gate void opts_set(struct opts *opts, const char *o, const char *optarg);
637c478bd9Sstevel@tonic-gate int opts_count(struct opts *opts, const char *options);
647c478bd9Sstevel@tonic-gate const char *opts_optarg(struct opts *opts, const char *o);
65*404720a7Sbasabi off_t opts_optarg_int(struct opts *opts, const char *o);
667c478bd9Sstevel@tonic-gate struct fn_list *opts_cmdargs(struct opts *opts);
677c478bd9Sstevel@tonic-gate struct opts *opts_merge(struct opts *back, struct opts *front);
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate #define	OPTP_NOW (-1)
707c478bd9Sstevel@tonic-gate #define	OPTP_NEVER (-2)
717c478bd9Sstevel@tonic-gate 
72*404720a7Sbasabi off_t opts_parse_ctime(const char *o, const char *optarg);
73*404720a7Sbasabi off_t opts_parse_bytes(const char *o, const char *optarg);
74*404720a7Sbasabi off_t opts_parse_atopi(const char *o, const char *optarg);
75*404720a7Sbasabi off_t opts_parse_seconds(const char *o, const char *optarg);
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate void opts_print(struct opts *opts, FILE *stream, char *exclude);
787c478bd9Sstevel@tonic-gate void opts_printword(const char *word, FILE *stream);
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
817c478bd9Sstevel@tonic-gate }
827c478bd9Sstevel@tonic-gate #endif
837c478bd9Sstevel@tonic-gate 
847c478bd9Sstevel@tonic-gate #endif	/* _LOGADM_OPTS_H */
85