14ecbd6dmarkm/*
233f661cstas * Copyright (c) 1997 - 2002 Kungliga Tekniska H��gskolan
333f661cstas * (Royal Institute of Technology, Stockholm, Sweden).
433f661cstas * All rights reserved.
54ecbd6dmarkm *
633f661cstas * Redistribution and use in source and binary forms, with or without
733f661cstas * modification, are permitted provided that the following conditions
833f661cstas * are met:
94ecbd6dmarkm *
1033f661cstas * 1. Redistributions of source code must retain the above copyright
1133f661cstas *    notice, this list of conditions and the following disclaimer.
124ecbd6dmarkm *
1333f661cstas * 2. Redistributions in binary form must reproduce the above copyright
1433f661cstas *    notice, this list of conditions and the following disclaimer in the
1533f661cstas *    documentation and/or other materials provided with the distribution.
164ecbd6dmarkm *
1733f661cstas * 3. Neither the name of the Institute nor the names of its contributors
1833f661cstas *    may be used to endorse or promote products derived from this software
1933f661cstas *    without specific prior written permission.
204ecbd6dmarkm *
2133f661cstas * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
2233f661cstas * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2333f661cstas * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2433f661cstas * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
2533f661cstas * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2633f661cstas * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2733f661cstas * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2833f661cstas * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2933f661cstas * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3033f661cstas * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3133f661cstas * SUCH DAMAGE.
324ecbd6dmarkm */
334ecbd6dmarkm
3433f661cstas/* $Id$ */
354ecbd6dmarkm
364ecbd6dmarkm#ifndef __GETARG_H__
374ecbd6dmarkm#define __GETARG_H__
384ecbd6dmarkm
394ecbd6dmarkm#include <stddef.h>
404ecbd6dmarkm
4151b6601dfr#ifndef ROKEN_LIB_FUNCTION
4251b6601dfr#ifdef _WIN32
4333f661cstas#define ROKEN_LIB_FUNCTION
4433f661cstas#define ROKEN_LIB_CALL     __cdecl
4551b6601dfr#else
4651b6601dfr#define ROKEN_LIB_FUNCTION
4733f661cstas#define ROKEN_LIB_CALL
4851b6601dfr#endif
4951b6601dfr#endif
5051b6601dfr
514ecbd6dmarkmstruct getargs{
524ecbd6dmarkm    const char *long_name;
534ecbd6dmarkm    char short_name;
5433f661cstas    enum { arg_integer,
5533f661cstas	   arg_string,
5633f661cstas	   arg_flag,
5733f661cstas	   arg_negative_flag,
584ecbd6dmarkm	   arg_strings,
594ecbd6dmarkm	   arg_double,
604ecbd6dmarkm	   arg_collect,
614ecbd6dmarkm	   arg_counter
624ecbd6dmarkm    } type;
634ecbd6dmarkm    void *value;
644ecbd6dmarkm    const char *help;
654ecbd6dmarkm    const char *arg_help;
664ecbd6dmarkm};
674ecbd6dmarkm
684ecbd6dmarkmenum {
694ecbd6dmarkm    ARG_ERR_NO_MATCH  = 1,
704ecbd6dmarkm    ARG_ERR_BAD_ARG,
714ecbd6dmarkm    ARG_ERR_NO_ARG
724ecbd6dmarkm};
734ecbd6dmarkm
744ecbd6dmarkmtypedef struct getarg_strings {
754ecbd6dmarkm    int num_strings;
764ecbd6dmarkm    char **strings;
774ecbd6dmarkm} getarg_strings;
784ecbd6dmarkm
794ecbd6dmarkmtypedef int (*getarg_collect_func)(int short_opt,
804ecbd6dmarkm				   int argc,
814ecbd6dmarkm				   char **argv,
82a77dba0nectar				   int *goptind,
83a77dba0nectar				   int *goptarg,
844ecbd6dmarkm				   void *data);
854ecbd6dmarkm
864ecbd6dmarkmtypedef struct getarg_collect_info {
874ecbd6dmarkm    getarg_collect_func func;
884ecbd6dmarkm    void *data;
894ecbd6dmarkm} getarg_collect_info;
904ecbd6dmarkm
9133f661cstasROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
9233f661cstasgetarg(struct getargs *args, size_t num_args,
9351b6601dfr       int argc, char **argv, int *goptind);
944ecbd6dmarkm
9533f661cstasROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
9651b6601dfrarg_printusage (struct getargs *args,
9751b6601dfr		size_t num_args,
9851b6601dfr		const char *progname,
9951b6601dfr		const char *extra_string);
1004ecbd6dmarkm
10133f661cstasROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
10233f661cstasarg_printusage_i18n (struct getargs *args,
10333f661cstas		     size_t num_args,
10433f661cstas		     const char *usage,
10533f661cstas		     const char *progname,
10633f661cstas		     const char *extra_string,
10733f661cstas		     char *(*i18n)(const char *));
10833f661cstas
10933f661cstasROKEN_LIB_FUNCTION void ROKEN_LIB_CALL
11051b6601dfrfree_getarg_strings (getarg_strings *);
1110c8fa35assar
1124ecbd6dmarkm#endif /* __GETARG_H__ */
113