]> git.ipfire.org Git - thirdparty/bash.git/blob - lib/readline/histlib.h
Bash-5.2 patch 26: fix typo when specifying readline's custom color prefix
[thirdparty/bash.git] / lib / readline / histlib.h
1 /* histlib.h -- internal definitions for the history library. */
2
3 /* Copyright (C) 1989-2009,2021-2022 Free Software Foundation, Inc.
4
5 This file contains the GNU History Library (History), a set of
6 routines for managing the text of previously typed lines.
7
8 History is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 History is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with History. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22 #if !defined (_HISTLIB_H_)
23 #define _HISTLIB_H_
24
25 #if defined (HAVE_STRING_H)
26 # include <string.h>
27 #else
28 # include <strings.h>
29 #endif /* !HAVE_STRING_H */
30
31 #if !defined (STREQ)
32 #define STREQ(a, b) (((a)[0] == (b)[0]) && (strcmp ((a), (b)) == 0))
33 #define STREQN(a, b, n) (((n) == 0) ? (1) \
34 : ((a)[0] == (b)[0]) && (strncmp ((a), (b), (n)) == 0))
35 #endif
36
37 #ifndef savestring
38 #define savestring(x) strcpy (xmalloc (1 + strlen (x)), (x))
39 #endif
40
41 #ifndef whitespace
42 #define whitespace(c) (((c) == ' ') || ((c) == '\t'))
43 #endif
44
45 #ifndef _rl_digit_p
46 #define _rl_digit_p(c) ((c) >= '0' && (c) <= '9')
47 #endif
48
49 #ifndef _rl_digit_value
50 #define _rl_digit_value(c) ((c) - '0')
51 #endif
52
53 #ifndef member
54 # if !defined (strchr) && !defined (__STDC__)
55 extern char *strchr ();
56 # endif /* !strchr && !__STDC__ */
57 #define member(c, s) ((c) ? ((char *)strchr ((s), (c)) != (char *)NULL) : 0)
58 #endif
59
60 #ifndef FREE
61 # define FREE(x) if (x) free (x)
62 #endif
63
64 /* Possible history errors passed to hist_error. */
65 #define EVENT_NOT_FOUND 0
66 #define BAD_WORD_SPEC 1
67 #define SUBST_FAILED 2
68 #define BAD_MODIFIER 3
69 #define NO_PREV_SUBST 4
70
71 /* Possible definitions for history starting point specification. */
72 #define NON_ANCHORED_SEARCH 0
73 #define ANCHORED_SEARCH 0x01
74 #define PATTERN_SEARCH 0x02
75
76 /* Possible definitions for what style of writing the history file we want. */
77 #define HISTORY_APPEND 0
78 #define HISTORY_OVERWRITE 1
79
80 /* internal extern function declarations used by other parts of the library */
81
82 /* histsearch.c */
83 extern int _hs_history_patsearch (const char *, int, int);
84
85 /* history.c */
86 extern void _hs_replace_history_data (int, histdata_t *, histdata_t *);
87 extern int _hs_at_end_of_history (void);
88
89 /* histfile.c */
90 extern void _hs_append_history_line (int, const char *);
91
92 #endif /* !_HISTLIB_H_ */