Commit | Line | Data |
---|---|---|
4ede3a83 DE |
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 | |
43c53e07 AC |
30 | options when invoked by gdb [or any external program]. |
31 | ||
50a2a691 AC |
32 | arg#2 is the option index; arg#3 is the option's argument, NULL if |
33 | optional and missing; arg#4 is nonzero if being called as a | |
34 | command. */ | |
4ede3a83 | 35 | |
50a2a691 | 36 | typedef SIM_RC (OPTION_HANDLER) PARAMS ((SIM_DESC, int, char *, int)); |
4ede3a83 DE |
37 | |
38 | /* Declare option handlers with a macro so it's usable on k&r systems. */ | |
50a2a691 | 39 | #define DECLARE_OPTION_HANDLER(fn) SIM_RC fn PARAMS ((SIM_DESC, int, char *, int)) |
4ede3a83 DE |
40 | |
41 | typedef struct { | |
42 | /* The long option information. */ | |
43 | struct option opt; | |
44 | /* The short option with the same meaning ('\0' if none). */ | |
45 | char shortopt; | |
46 | /* The name of the argument (NULL if none). */ | |
47 | const char *arg; | |
48 | /* The documentation string. If this is NULL, this is a synonym for | |
49 | the previous option. */ | |
50 | const char *doc; | |
51 | /* A function to process the option. */ | |
52 | OPTION_HANDLER *handler; | |
50a2a691 AC |
53 | /* The documented name of the option. If this is NULL, opt.name is |
54 | listed; otherwize this is listed as the name of the option. | |
55 | Ex: given the options --set-pc, set-sp, et.al. the first option | |
56 | would have doc_opt set to `--set-REGNAME' with the others set to | |
57 | "". Only --set-REGNAME would then be listed. */ | |
58 | const char *doc_name; | |
4ede3a83 DE |
59 | } OPTION; |
60 | ||
61 | /* All options that don't have a short form equivalent begin with this for | |
62 | `val'. 130 isn't special, just some non-ASCII value to begin at. | |
63 | Modules needn't worry about collisions here, the code dynamically assigned | |
64 | the actual numbers used and then passes the original value to the option | |
65 | handler. */ | |
66 | #define OPTION_START 130 | |
67 | ||
68 | /* Non-zero if an option whose `val' entry is O is using OPTION_START. */ | |
69 | #define OPTION_LONG_ONLY_P(o) ((unsigned char) (o) >= OPTION_START) | |
70 | ||
71 | /* List of options added by various modules. */ | |
72 | typedef struct option_list { | |
73 | struct option_list *next; | |
74 | const OPTION *options; | |
75 | } OPTION_LIST; | |
76 | ||
77 | /* Add a set of options to the simulator. | |
78 | TABLE is an array of OPTIONS terminated by a NULL `opt.name' entry. */ | |
79 | SIM_RC sim_add_option_table PARAMS ((SIM_DESC sd, const OPTION *table)); | |
80 | ||
43c53e07 AC |
81 | /* Install handler for the standard options. */ |
82 | MODULE_INSTALL_FN standard_install; | |
4ede3a83 DE |
83 | |
84 | /* Called by sim_open to parse the arguments. */ | |
85 | SIM_RC sim_parse_args PARAMS ((SIM_DESC sd, char **argv)); | |
86 | ||
87 | /* Print help messages for the options. */ | |
88 | void sim_print_help PARAMS ((SIM_DESC sd)); | |
89 | ||
43c53e07 AC |
90 | /* Try to parse the command as if it is an option, Only fail when |
91 | totally unsuccessful */ | |
92 | SIM_RC sim_args_command PARAMS ((SIM_DESC sd, char *cmd)); | |
93 | ||
4ede3a83 | 94 | #endif /* SIM_OPTIONS_H */ |