2
* Generic Options Support Header File
4
* Copyright (c) 2001 Stanislav Karchebny <berk@madfire.net>
6
* Redistribution and use in source and binary forms, with or without
7
* modification, are permitted provided that the following conditions
9
* 1. Redistributions of source code must retain the above copyright
10
* notice, this list of conditions and the following disclaimer.
11
* 2. Redistributions in binary form must reproduce the above copyright
12
* notice, this list of conditions and the following disclaimer in the
13
* documentation and/or other materials provided with the distribution.
15
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND OTHER CONTRIBUTORS ``AS IS''
16
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR OTHER CONTRIBUTORS BE
19
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25
* POSSIBILITY OF SUCH DAMAGE.
27
#ifndef TASM_OPTIONS_H
28
#define TASM_OPTIONS_H
30
/* an option structure
31
* operate on either -sopt, --lopt, -sopt <val> or --lopt=<val>
33
typedef struct opt_option_s
38
/* !=0 if option requires parameter, 0 if not */
41
int (*handler) (char *cmd, /*@null@*/ char *param, int extra);
42
int extra; /* extra value for handler */
44
/* description to use in help_msg() */
45
/*@observer@*/ const char *description;
47
/* optional description for the param taken (NULL if not present) */
48
/* (short - will be printed after option sopt/lopt) */
49
/*@observer@*/ /*@null@*/ const char *param_desc;
52
/* handle everything that is not an option */
53
int not_an_option_handler(char *param);
55
/* parse command line calling handlers when appropriate
56
* argc, argv - pass directly from main(argc,argv)
57
* options - array of options
58
* nopts - options count
60
int parse_cmdline(int argc, char **argv, opt_option *options, size_t nopts,
61
void (*print_error) (const char *fmt, ...));
63
/* display help message msg followed by list of options in options and followed
66
void help_msg(const char *msg, const char *tail, opt_option *options,