* ppc-opc.c (powerpc_opcodes) <"lswx">: Use RAX for the second and
[binutils-gdb.git] / gdb / cli / cli-utils.h
blob9fb12ba962e49c6ba89f6bd3fb0f1b011783ae02
1 /* CLI utilities.
3 Copyright (c) 2011-2012 Free Software Foundation, Inc.
5 This file is part of GDB.
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 3 of the License, or
10 (at your option) any later version.
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.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 #ifndef CLI_UTILS_H
21 #define CLI_UTILS_H
23 /* *PP is a string denoting a number. Get the number of the. Advance
24 *PP after the string and any trailing whitespace.
26 Currently the string can either be a number, or "$" followed by the
27 name of a convenience variable, or ("$" or "$$") followed by digits. */
29 extern int get_number (char **);
31 /* An object of this type is passed to get_number_or_range. It must
32 be initialized by calling init_number_or_range. This type is
33 defined here so that it can be stack-allocated, but all members
34 other than `finished' and `string' should be treated as opaque. */
36 struct get_number_or_range_state
38 /* Non-zero if parsing has completed. */
39 int finished;
41 /* The string being parsed. When parsing has finished, this points
42 past the last parsed token. */
43 char *string;
45 /* Last value returned. */
46 int last_retval;
48 /* When parsing a range, the final value in the range. */
49 int end_value;
51 /* When parsing a range, a pointer past the final token in the
52 range. */
53 char *end_ptr;
55 /* Non-zero when parsing a range. */
56 int in_range;
59 /* Initialize a get_number_or_range_state for use with
60 get_number_or_range_state. STRING is the string to be parsed. */
62 extern void init_number_or_range (struct get_number_or_range_state *state,
63 char *string);
65 /* Parse a number or a range.
66 A number will be of the form handled by get_number.
67 A range will be of the form <number1> - <number2>, and
68 will represent all the integers between number1 and number2,
69 inclusive.
71 While processing a range, this fuction is called iteratively;
72 At each call it will return the next value in the range.
74 At the beginning of parsing a range, the char pointer STATE->string will
75 be advanced past <number1> and left pointing at the '-' token.
76 Subsequent calls will not advance the pointer until the range
77 is completed. The call that completes the range will advance
78 the pointer past <number2>. */
80 extern int get_number_or_range (struct get_number_or_range_state *state);
82 /* Accept a number and a string-form list of numbers such as is
83 accepted by get_number_or_range. Return TRUE if the number is
84 in the list.
86 By definition, an empty list includes all numbers. This is to
87 be interpreted as typing a command such as "delete break" with
88 no arguments. */
90 extern int number_is_in_list (char *list, int number);
92 /* Skip leading whitespace characters in INP, returning an updated
93 pointer. If INP is NULL, return NULL. */
95 extern char *skip_spaces (char *inp);
97 /* A const-correct version of the above. */
99 extern const char *skip_spaces_const (const char *inp);
101 /* Skip leading non-whitespace characters in INP, returning an updated
102 pointer. If INP is NULL, return NULL. */
104 extern char *skip_to_space (char *inp);
106 /* Reverse S to the last non-whitespace character without skipping past
107 START. */
109 extern char *remove_trailing_whitespace (const char *start, char *s);
111 /* A helper function to extract an argument from *ARG. An argument is
112 delimited by whitespace. The return value is either NULL if no
113 argument was found, or an xmalloc'd string. */
115 extern char *extract_arg (char **arg);
117 /* A helper function that looks for an argument at the start of a
118 string. The argument must also either be at the end of the string,
119 or be followed by whitespace. Returns 1 if it finds the argument,
120 0 otherwise. If the argument is found, it updates *STR. */
121 extern int check_for_argument (char **str, char *arg, int arg_len);
123 #endif /* CLI_UTILS_H */