source: git/src/cmdline.h @ 559cd60

RELEASE/1.2debug-cidebug-ci-sanitiserswalls-data
Last change on this file since 559cd60 was 559cd60, checked in by Olly Betts <olly@…>, 5 years ago

Consistently refer to macOS not OS X, etc

Apple renamed it yet again.

  • Property mode set to 100644
File size: 2.5 KB
RevLine 
[6974a34]1/* cmdline.h
[aadc86e]2 * Wrapper for GNU getopt which deals with standard options
[45af761]3 * Copyright (C) 1998-2001,2003,2011 Olly Betts
[846746e]4 *
[89231c4]5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
[846746e]9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
[89231c4]12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU General Public License for more details.
[846746e]14 *
[89231c4]15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
[ecbc6c18]17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
[aadc86e]18 */
19
[d07944e]20#ifndef CMDLINE_H
21# define CMDLINE_H
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
[be97baf]27/* Duplicate these from getopt.h to avoid problems
[559cd60]28 * with trying to compile getopt.h with C++ on macOS */
[be97baf]29#ifndef no_argument
30/* These values are definitely correct since getopt.h says 0, 1, 2 work */
31# define no_argument            0
32# define required_argument      1
33# define optional_argument      2
34
35/* FIXME: struct definition needs to match getopt.h */
36struct option {
37   const char *name;
38   /* has_arg can't be an enum because some compilers complain about
39    * type mismatches in all the code that assumes it is an int.  */
40   int has_arg;
41   int *flag;
42   int val;
43};
44
45extern char *optarg;
46extern int optind;
47extern int opterr;
48extern int optopt;
[3451fc5]49#endif
[aadc86e]50
[cb3d1e2]51struct help_msg {
[3b9ec3f]52   int opt;
[45af761]53   int msg_no;
54   const char * arg;
[3b9ec3f]55};
[aadc86e]56
[3b9ec3f]57/* give -1 for max_args_ if there's no limit */
58void cmdline_init(int argc_, char *const *argv_, const char *shortopts_,
59                  const struct option *longopts_, int *longind_,
60                  const struct help_msg *help_,
[acc20b1]61                  int min_args_, int max_args_);
[d8dbdff]62/* if args not 0, use instead of auto-generated FILE args */
63/* if extra not 0, display as extra blurb at end */
64/* if arg not NULL, extra must be a printf format with one %s */
65void cmdline_set_syntax_message(int msg_args, int msg_extra, const char * arg);
[3b9ec3f]66int cmdline_getopt(void);
67void cmdline_help(void);
68void cmdline_version(void);
69void cmdline_syntax(void);
[66711f2]70void cmdline_too_few_args(void);
71void cmdline_too_many_args(void);
[3b9ec3f]72int cmdline_int_arg(void);
[acc20b1]73double cmdline_double_arg(void);
[aadc86e]74
75#define HLP_ENCODELONG(N) (-(N + 1))
76#define HLP_DECODELONG(N) (-(N + 1))
77#define HLP_ISLONG(N) ((N) <= 0)
78#define HLP_HELP 30000
79#define HLP_VERSION 30001
[d07944e]80
81#ifdef __cplusplus
82}
83#endif
84
85#endif
Note: See TracBrowser for help on using the repository browser.