10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*2016Sbasabi * Common Development and Distribution License (the "License"). 6*2016Sbasabi * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*2016Sbasabi * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 23*2016Sbasabi * Use is subject to license terms. 240Sstevel@tonic-gate * 250Sstevel@tonic-gate * logadm/opts.h -- public definitions for opts module 260Sstevel@tonic-gate */ 270Sstevel@tonic-gate 280Sstevel@tonic-gate #ifndef _LOGADM_OPTS_H 290Sstevel@tonic-gate #define _LOGADM_OPTS_H 300Sstevel@tonic-gate 310Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 320Sstevel@tonic-gate 330Sstevel@tonic-gate #ifdef __cplusplus 340Sstevel@tonic-gate extern "C" { 350Sstevel@tonic-gate #endif 360Sstevel@tonic-gate 370Sstevel@tonic-gate /* various types of options we allow */ 380Sstevel@tonic-gate enum opttype { 390Sstevel@tonic-gate OPTTYPE_BOOLEAN, /* simple boolean flag */ 400Sstevel@tonic-gate OPTTYPE_INT, /* simple number */ 410Sstevel@tonic-gate OPTTYPE_STRING /* string (like a pathname) */ 420Sstevel@tonic-gate }; 430Sstevel@tonic-gate 440Sstevel@tonic-gate struct opts; 450Sstevel@tonic-gate 460Sstevel@tonic-gate /* info that drives option parsing (table of these is passed to opts_init()) */ 470Sstevel@tonic-gate struct optinfo { 480Sstevel@tonic-gate char *oi_o; /* the option */ 490Sstevel@tonic-gate enum opttype oi_t; /* the type of this option */ 500Sstevel@tonic-gate /* parser, if set, is called to parse optarg */ 51*2016Sbasabi off_t (*oi_parser)(const char *o, const char *optarg); 520Sstevel@tonic-gate int oi_flags; 530Sstevel@tonic-gate }; 540Sstevel@tonic-gate 550Sstevel@tonic-gate /* flags for struct optinfo */ 560Sstevel@tonic-gate #define OPTF_CLI 1 570Sstevel@tonic-gate #define OPTF_CONF 2 580Sstevel@tonic-gate 590Sstevel@tonic-gate void opts_init(struct optinfo *table, int numentries); 600Sstevel@tonic-gate struct opts *opts_parse(char **args, int flags); 610Sstevel@tonic-gate void opts_free(struct opts *opts); 620Sstevel@tonic-gate void opts_set(struct opts *opts, const char *o, const char *optarg); 630Sstevel@tonic-gate int opts_count(struct opts *opts, const char *options); 640Sstevel@tonic-gate const char *opts_optarg(struct opts *opts, const char *o); 65*2016Sbasabi off_t opts_optarg_int(struct opts *opts, const char *o); 660Sstevel@tonic-gate struct fn_list *opts_cmdargs(struct opts *opts); 670Sstevel@tonic-gate struct opts *opts_merge(struct opts *back, struct opts *front); 680Sstevel@tonic-gate 690Sstevel@tonic-gate #define OPTP_NOW (-1) 700Sstevel@tonic-gate #define OPTP_NEVER (-2) 710Sstevel@tonic-gate 72*2016Sbasabi off_t opts_parse_ctime(const char *o, const char *optarg); 73*2016Sbasabi off_t opts_parse_bytes(const char *o, const char *optarg); 74*2016Sbasabi off_t opts_parse_atopi(const char *o, const char *optarg); 75*2016Sbasabi off_t opts_parse_seconds(const char *o, const char *optarg); 760Sstevel@tonic-gate 770Sstevel@tonic-gate void opts_print(struct opts *opts, FILE *stream, char *exclude); 780Sstevel@tonic-gate void opts_printword(const char *word, FILE *stream); 790Sstevel@tonic-gate 800Sstevel@tonic-gate #ifdef __cplusplus 810Sstevel@tonic-gate } 820Sstevel@tonic-gate #endif 830Sstevel@tonic-gate 840Sstevel@tonic-gate #endif /* _LOGADM_OPTS_H */ 85