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 5404720a7Sbasabi * Common Development and Distribution License (the "License"). 6404720a7Sbasabi * 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*e9a193fcSJohn.Zolnowsky@Sun.COM * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. 237c478bd9Sstevel@tonic-gate * 247c478bd9Sstevel@tonic-gate * logadm/opts.h -- public definitions for opts module 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #ifndef _LOGADM_OPTS_H 287c478bd9Sstevel@tonic-gate #define _LOGADM_OPTS_H 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #ifdef __cplusplus 317c478bd9Sstevel@tonic-gate extern "C" { 327c478bd9Sstevel@tonic-gate #endif 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate /* various types of options we allow */ 357c478bd9Sstevel@tonic-gate enum opttype { 367c478bd9Sstevel@tonic-gate OPTTYPE_BOOLEAN, /* simple boolean flag */ 377c478bd9Sstevel@tonic-gate OPTTYPE_INT, /* simple number */ 387c478bd9Sstevel@tonic-gate OPTTYPE_STRING /* string (like a pathname) */ 397c478bd9Sstevel@tonic-gate }; 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate struct opts; 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate /* info that drives option parsing (table of these is passed to opts_init()) */ 447c478bd9Sstevel@tonic-gate struct optinfo { 457c478bd9Sstevel@tonic-gate char *oi_o; /* the option */ 467c478bd9Sstevel@tonic-gate enum opttype oi_t; /* the type of this option */ 477c478bd9Sstevel@tonic-gate /* parser, if set, is called to parse optarg */ 48404720a7Sbasabi off_t (*oi_parser)(const char *o, const char *optarg); 497c478bd9Sstevel@tonic-gate int oi_flags; 507c478bd9Sstevel@tonic-gate }; 517c478bd9Sstevel@tonic-gate 527c478bd9Sstevel@tonic-gate /* flags for struct optinfo */ 537c478bd9Sstevel@tonic-gate #define OPTF_CLI 1 547c478bd9Sstevel@tonic-gate #define OPTF_CONF 2 557c478bd9Sstevel@tonic-gate 567c478bd9Sstevel@tonic-gate void opts_init(struct optinfo *table, int numentries); 57*e9a193fcSJohn.Zolnowsky@Sun.COM struct opts *opts_parse(struct opts *, char **args, int flags); 587c478bd9Sstevel@tonic-gate void opts_free(struct opts *opts); 597c478bd9Sstevel@tonic-gate void opts_set(struct opts *opts, const char *o, const char *optarg); 607c478bd9Sstevel@tonic-gate int opts_count(struct opts *opts, const char *options); 617c478bd9Sstevel@tonic-gate const char *opts_optarg(struct opts *opts, const char *o); 62404720a7Sbasabi off_t opts_optarg_int(struct opts *opts, const char *o); 637c478bd9Sstevel@tonic-gate struct fn_list *opts_cmdargs(struct opts *opts); 647c478bd9Sstevel@tonic-gate struct opts *opts_merge(struct opts *back, struct opts *front); 657c478bd9Sstevel@tonic-gate 667c478bd9Sstevel@tonic-gate #define OPTP_NOW (-1) 677c478bd9Sstevel@tonic-gate #define OPTP_NEVER (-2) 687c478bd9Sstevel@tonic-gate 697c478bd9Sstevel@tonic-gate void opts_print(struct opts *opts, FILE *stream, char *exclude); 707c478bd9Sstevel@tonic-gate void opts_printword(const char *word, FILE *stream); 717c478bd9Sstevel@tonic-gate 72*e9a193fcSJohn.Zolnowsky@Sun.COM extern struct optinfo Opttable[]; 73*e9a193fcSJohn.Zolnowsky@Sun.COM extern int Opttable_cnt; 74*e9a193fcSJohn.Zolnowsky@Sun.COM 757c478bd9Sstevel@tonic-gate #ifdef __cplusplus 767c478bd9Sstevel@tonic-gate } 777c478bd9Sstevel@tonic-gate #endif 787c478bd9Sstevel@tonic-gate 797c478bd9Sstevel@tonic-gate #endif /* _LOGADM_OPTS_H */ 80