3 Copyright (C) 2011-2016 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/>. */
23 /* *PP is a string denoting a number. Get the number. Advance *PP
24 after the string and any trailing whitespace.
26 The string can either be a number, or "$" followed by the name of a
27 convenience variable, or ("$" or "$$") followed by digits.
29 TRAILER is a character which can be found after the number; most
30 commonly this is `-'. If you don't want a trailer, use \0. */
32 extern int get_number_trailer (const char **pp, int trailer);
34 /* Convenience. Like get_number_trailer, but with no TRAILER. */
36 extern int get_number_const (const char **);
38 /* Like get_number_const, but takes a non-const "char **". */
40 extern int get_number (char **);
42 /* An object of this type is passed to get_number_or_range. It must
43 be initialized by calling init_number_or_range. This type is
44 defined here so that it can be stack-allocated, but all members
45 other than `finished' and `string' should be treated as opaque. */
47 struct get_number_or_range_state
49 /* Non-zero if parsing has completed. */
52 /* The string being parsed. When parsing has finished, this points
53 past the last parsed token. */
56 /* Last value returned. */
59 /* When parsing a range, the final value in the range. */
62 /* When parsing a range, a pointer past the final token in the
66 /* Non-zero when parsing a range. */
70 /* Initialize a get_number_or_range_state for use with
71 get_number_or_range_state. STRING is the string to be parsed. */
73 extern void init_number_or_range (struct get_number_or_range_state *state,
76 /* Parse a number or a range.
77 A number will be of the form handled by get_number.
78 A range will be of the form <number1> - <number2>, and
79 will represent all the integers between number1 and number2,
82 While processing a range, this fuction is called iteratively;
83 At each call it will return the next value in the range.
85 At the beginning of parsing a range, the char pointer STATE->string will
86 be advanced past <number1> and left pointing at the '-' token.
87 Subsequent calls will not advance the pointer until the range
88 is completed. The call that completes the range will advance
89 the pointer past <number2>. */
91 extern int get_number_or_range (struct get_number_or_range_state *state);
93 /* Accept a number and a string-form list of numbers such as is
94 accepted by get_number_or_range. Return TRUE if the number is
97 By definition, an empty list includes all numbers. This is to
98 be interpreted as typing a command such as "delete break" with
101 extern int number_is_in_list (const char *list, int number);
103 /* Reverse S to the last non-whitespace character without skipping past
106 extern char *remove_trailing_whitespace (const char *start, char *s);
108 /* A helper function to extract an argument from *ARG. An argument is
109 delimited by whitespace. The return value is either NULL if no
110 argument was found, or an xmalloc'd string. */
112 extern char *extract_arg (char **arg);
114 /* A const-correct version of "extract_arg".
116 Since the returned value is xmalloc'd, it eventually needs to be
117 xfree'ed, which prevents us from making it const as well. */
119 extern char *extract_arg_const (const char **arg);
121 /* A helper function that looks for an argument at the start of a
122 string. The argument must also either be at the end of the string,
123 or be followed by whitespace. Returns 1 if it finds the argument,
124 0 otherwise. If the argument is found, it updates *STR. */
125 extern int check_for_argument (char **str, char *arg, int arg_len);
127 #endif /* CLI_UTILS_H */