source: git/src/cmdline.h @ d8dbdff

add-show-splaysline_contentsstereosvn/github/mastersvn/origin/mastersvn/tags/1.2.1svn/tags/1.2.2svn/tags/1.2.3svn/tags/1.2.4svn/tags/1.2.5svn/trunktravis-osx
Last change on this file since d8dbdff was d8dbdff, checked in by Olly Betts <olly@…>, 8 years ago

lib/codes.po,src/: cmdline_set_syntax_message() now takes message
numbers, plus an optional string argument.

git-svn-id: file:///home/survex-svn/survex/trunk@3746 4b37db11-9a0c-4f06-9ece-9ab7cdaee568

  • Property mode set to 100644
File size: 2.5 KB
Line 
1/* cmdline.h
2 * Wrapper for GNU getopt which deals with standard options
3 * Copyright (C) 1998-2001,2003,2011 Olly Betts
4 *
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.
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
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU General Public License for more details.
14 *
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
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18 */
19
20#ifndef CMDLINE_H
21# define CMDLINE_H
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27/* Duplicate these from getopt.h to avoid problems
28 * with trying to compile getopt.h with C++ on MacOS X */
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;
49#endif
50
51struct help_msg {
52   int opt;
53   int msg_no;
54   const char * arg;
55};
56
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_,
61                  int min_args_, int max_args_);
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);
66int cmdline_getopt(void);
67void cmdline_help(void);
68void cmdline_version(void);
69void cmdline_syntax(void);
70void cmdline_too_few_args(void);
71void cmdline_too_many_args(void);
72int cmdline_int_arg(void);
73double cmdline_double_arg(void);
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
80
81#ifdef __cplusplus
82}
83#endif
84
85#endif
Note: See TracBrowser for help on using the repository browser.