* sim-options.c, sim-options.h: New files.
[external/binutils.git] / sim / common / sim-options.h
1 /* Header file for simulator argument handling.
2    Copyright (C) 1997 Free Software Foundation, Inc.
3    Contributed by Cygnus Support.
4
5 This file is part of GDB, the GNU debugger.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License along
18 with this program; if not, write to the Free Software Foundation, Inc.,
19 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
20
21 #ifndef SIM_OPTIONS_H
22 #define SIM_OPTIONS_H
23
24 #include "getopt.h"
25
26 /* ARGV option support.
27
28    Options for the standalone simulator are parsed by sim_open since
29    sim_open handles the large majority of them and it also parses the
30    options when invoked by gdb [or any external program].  */
31
32 typedef SIM_RC (OPTION_HANDLER) PARAMS ((SIM_DESC, int, char *));
33
34 /* Declare option handlers with a macro so it's usable on k&r systems.  */
35 #define DECLARE_OPTION_HANDLER(fn) SIM_RC fn PARAMS ((SIM_DESC, int, char *))
36
37 typedef struct {
38   /* The long option information.  */
39   struct option opt;
40   /* The short option with the same meaning ('\0' if none).  */
41   char shortopt;
42   /* The name of the argument (NULL if none).  */
43   const char *arg;
44   /* The documentation string.  If this is NULL, this is a synonym for
45      the previous option.  */
46   const char *doc;
47   /* A function to process the option.  */
48   OPTION_HANDLER *handler;
49 } OPTION;
50
51 /* All options that don't have a short form equivalent begin with this for
52    `val'.  130 isn't special, just some non-ASCII value to begin at.
53    Modules needn't worry about collisions here, the code dynamically assigned
54    the actual numbers used and then passes the original value to the option
55    handler.  */
56 #define OPTION_START 130
57
58 /* Non-zero if an option whose `val' entry is O is using OPTION_START.  */
59 #define OPTION_LONG_ONLY_P(o) ((unsigned char) (o) >= OPTION_START)
60
61 /* List of options added by various modules.  */
62 typedef struct option_list {
63   struct option_list *next;
64   const OPTION *options;
65 } OPTION_LIST;
66
67 /* Add a set of options to the simulator.
68    TABLE is an array of OPTIONS terminated by a NULL `opt.name' entry.  */
69 SIM_RC sim_add_option_table PARAMS ((SIM_DESC sd, const OPTION *table));
70
71 /* Initialize common parts before argument processing.
72    Called by sim_open.  */
73 SIM_RC sim_pre_argv_init PARAMS ((SIM_DESC sd, const char *myname));
74
75 /* Called by sim_open to parse the arguments.  */
76 SIM_RC sim_parse_args PARAMS ((SIM_DESC sd, char **argv));
77
78 /* Print help messages for the options.  */
79 void sim_print_help PARAMS ((SIM_DESC sd));
80
81 #endif /* SIM_OPTIONS_H */