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 52016Sbasabi * Common Development and Distribution License (the "License"). 62016Sbasabi * 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*12986SJohn.Zolnowsky@Sun.COM * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. 230Sstevel@tonic-gate * 240Sstevel@tonic-gate * logadm/opts.h -- public definitions for opts module 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate #ifndef _LOGADM_OPTS_H 280Sstevel@tonic-gate #define _LOGADM_OPTS_H 290Sstevel@tonic-gate 300Sstevel@tonic-gate #ifdef __cplusplus 310Sstevel@tonic-gate extern "C" { 320Sstevel@tonic-gate #endif 330Sstevel@tonic-gate 340Sstevel@tonic-gate /* various types of options we allow */ 350Sstevel@tonic-gate enum opttype { 360Sstevel@tonic-gate OPTTYPE_BOOLEAN, /* simple boolean flag */ 370Sstevel@tonic-gate OPTTYPE_INT, /* simple number */ 380Sstevel@tonic-gate OPTTYPE_STRING /* string (like a pathname) */ 390Sstevel@tonic-gate }; 400Sstevel@tonic-gate 410Sstevel@tonic-gate struct opts; 420Sstevel@tonic-gate 430Sstevel@tonic-gate /* info that drives option parsing (table of these is passed to opts_init()) */ 440Sstevel@tonic-gate struct optinfo { 450Sstevel@tonic-gate char *oi_o; /* the option */ 460Sstevel@tonic-gate enum opttype oi_t; /* the type of this option */ 470Sstevel@tonic-gate /* parser, if set, is called to parse optarg */ 482016Sbasabi off_t (*oi_parser)(const char *o, const char *optarg); 490Sstevel@tonic-gate int oi_flags; 500Sstevel@tonic-gate }; 510Sstevel@tonic-gate 520Sstevel@tonic-gate /* flags for struct optinfo */ 530Sstevel@tonic-gate #define OPTF_CLI 1 540Sstevel@tonic-gate #define OPTF_CONF 2 550Sstevel@tonic-gate 560Sstevel@tonic-gate void opts_init(struct optinfo *table, int numentries); 57*12986SJohn.Zolnowsky@Sun.COM struct opts *opts_parse(struct opts *, char **args, int flags); 580Sstevel@tonic-gate void opts_free(struct opts *opts); 590Sstevel@tonic-gate void opts_set(struct opts *opts, const char *o, const char *optarg); 600Sstevel@tonic-gate int opts_count(struct opts *opts, const char *options); 610Sstevel@tonic-gate const char *opts_optarg(struct opts *opts, const char *o); 622016Sbasabi off_t opts_optarg_int(struct opts *opts, const char *o); 630Sstevel@tonic-gate struct fn_list *opts_cmdargs(struct opts *opts); 640Sstevel@tonic-gate struct opts *opts_merge(struct opts *back, struct opts *front); 650Sstevel@tonic-gate 660Sstevel@tonic-gate #define OPTP_NOW (-1) 670Sstevel@tonic-gate #define OPTP_NEVER (-2) 680Sstevel@tonic-gate 690Sstevel@tonic-gate void opts_print(struct opts *opts, FILE *stream, char *exclude); 700Sstevel@tonic-gate void opts_printword(const char *word, FILE *stream); 710Sstevel@tonic-gate 72*12986SJohn.Zolnowsky@Sun.COM extern struct optinfo Opttable[]; 73*12986SJohn.Zolnowsky@Sun.COM extern int Opttable_cnt; 74*12986SJohn.Zolnowsky@Sun.COM 750Sstevel@tonic-gate #ifdef __cplusplus 760Sstevel@tonic-gate } 770Sstevel@tonic-gate #endif 780Sstevel@tonic-gate 790Sstevel@tonic-gate #endif /* _LOGADM_OPTS_H */ 80