1 /* histlib.h -- internal definitions for the history library. */
2 /* Copyright (C) 1989, 1992 Free Software Foundation, Inc.
3
4 This file contains the GNU History Library (the Library), a set of
5 routines for managing the text of previously typed lines.
6
7 The Library 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 The Library is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
16
17 The GNU General Public License is often shipped with GNU software, and
18 is generally kept in a file called COPYING or LICENSE. If you do not
19 have a copy of the license, write to the Free Software Foundation,
20 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
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 #if !defined (savestring)
38 #include <stdio.h>
39 static char *
xstrdup(const char * s)40 xstrdup(const char *s)
41 {
42 char * cp;
43 cp = strdup(s);
44 if (cp == NULL) {
45 fprintf (stderr, "xstrdup: out of virtual memory\n");
46 exit (2);
47 }
48 return(cp);
49 }
50 #define savestring(x) xstrdup(x)
51 #endif /* !savestring */
52
53 #ifndef whitespace
54 #define whitespace(c) (((c) == ' ') || ((c) == '\t'))
55 #endif
56
57 #ifndef _rl_digit_p
58 #define _rl_digit_p(c) ((c) >= '0' && (c) <= '9')
59 #endif
60
61 #ifndef _rl_digit_value
62 #define _rl_digit_value(c) ((c) - '0')
63 #endif
64
65 #ifndef member
66 # ifndef strchr
67 extern char *strchr ();
68 # endif
69 #define member(c, s) ((c) ? ((char *)strchr ((s), (c)) != (char *)NULL) : 0)
70 #endif
71
72 #ifndef FREE
73 # define FREE(x) if (x) free (x)
74 #endif
75
76 /* Possible history errors passed to hist_error. */
77 #define EVENT_NOT_FOUND 0
78 #define BAD_WORD_SPEC 1
79 #define SUBST_FAILED 2
80 #define BAD_MODIFIER 3
81 #define NO_PREV_SUBST 4
82
83 /* Possible definitions for history starting point specification. */
84 #define ANCHORED_SEARCH 1
85 #define NON_ANCHORED_SEARCH 0
86
87 /* Possible definitions for what style of writing the history file we want. */
88 #define HISTORY_APPEND 0
89 #define HISTORY_OVERWRITE 1
90
91 /* Some variable definitions shared across history source files. */
92 extern int history_offset;
93
94 #endif /* !_HISTLIB_H_ */
95