150880Smarkm/* 250880Smarkm * Copyright (c) 1997 Kungliga Tekniska H�gskolan 350880Smarkm * (Royal Institute of Technology, Stockholm, Sweden). 450880Smarkm * All rights reserved. 550880Smarkm * 650880Smarkm * Redistribution and use in source and binary forms, with or without 750880Smarkm * modification, are permitted provided that the following conditions 850880Smarkm * are met: 950880Smarkm * 1050880Smarkm * 1. Redistributions of source code must retain the above copyright 1150880Smarkm * notice, this list of conditions and the following disclaimer. 1250880Smarkm * 1350880Smarkm * 2. Redistributions in binary form must reproduce the above copyright 1450880Smarkm * notice, this list of conditions and the following disclaimer in the 1550880Smarkm * documentation and/or other materials provided with the distribution. 1650880Smarkm * 1750880Smarkm * 3. All advertising materials mentioning features or use of this software 1850880Smarkm * must display the following acknowledgement: 1950880Smarkm * This product includes software developed by Kungliga Tekniska 2050880Smarkm * H�gskolan and its contributors. 2150880Smarkm * 2250880Smarkm * 4. Neither the name of the Institute nor the names of its contributors 2350880Smarkm * may be used to endorse or promote products derived from this software 2450880Smarkm * without specific prior written permission. 2550880Smarkm * 2650880Smarkm * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 2750880Smarkm * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2850880Smarkm * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2950880Smarkm * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 3050880Smarkm * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 3150880Smarkm * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3250880Smarkm * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3350880Smarkm * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3450880Smarkm * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3550880Smarkm * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3650880Smarkm * SUCH DAMAGE. 3750880Smarkm */ 3850880Smarkm 3950880Smarkm/* $Id: getarg.h,v 1.5 1998/08/18 20:26:11 assar Exp $ */ 4050880Smarkm 4150880Smarkm#ifndef __GETARG_H__ 4250880Smarkm#define __GETARG_H__ 4350880Smarkm 4450880Smarkm#include <stddef.h> 4550880Smarkm 4650880Smarkm#define max(a,b) (((a)>(b))?(a):(b)) 4750880Smarkm 4850880Smarkmstruct getargs{ 4950880Smarkm const char *long_name; 5050880Smarkm char short_name; 5150880Smarkm enum { arg_integer, arg_string, arg_flag, arg_negative_flag, arg_strings } type; 5250880Smarkm void *value; 5350880Smarkm const char *help; 5450880Smarkm const char *arg_help; 5550880Smarkm}; 5650880Smarkm 5750880Smarkmenum { 5850880Smarkm ARG_ERR_NO_MATCH = 1, 5950880Smarkm ARG_ERR_BAD_ARG, 6050880Smarkm ARG_ERR_NO_ARG 6150880Smarkm}; 6250880Smarkm 6350880Smarkmtypedef struct getarg_strings { 6450880Smarkm int num_strings; 6550880Smarkm char **strings; 6650880Smarkm} getarg_strings; 6750880Smarkm 6850880Smarkmint getarg(struct getargs *args, size_t num_args, 6950880Smarkm int argc, char **argv, int *optind); 7050880Smarkm 7150880Smarkmvoid arg_printusage (struct getargs *args, 7250880Smarkm size_t num_args, 7350880Smarkm const char *progname, 7450880Smarkm const char *extra_string); 7550880Smarkm 7650880Smarkm#endif /* __GETARG_H__ */ 77