histlib.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* histlib.h -- internal definitions for the history library. */
  2. /* Copyright (C) 1989-2009 Free Software Foundation, Inc.
  3. This file contains the GNU History Library (History), a set of
  4. routines for managing the text of previously typed lines.
  5. History is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. History is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with History. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #if !defined (_HISTLIB_H_)
  17. #define _HISTLIB_H_
  18. #if defined (HAVE_STRING_H)
  19. # include <string.h>
  20. #else
  21. # include <strings.h>
  22. #endif /* !HAVE_STRING_H */
  23. #if !defined (STREQ)
  24. #define STREQ(a, b) (((a)[0] == (b)[0]) && (strcmp ((a), (b)) == 0))
  25. #define STREQN(a, b, n) (((n) == 0) ? (1) \
  26. : ((a)[0] == (b)[0]) && (strncmp ((a), (b), (n)) == 0))
  27. #endif
  28. #ifndef savestring
  29. #define savestring(x) strcpy (xmalloc (1 + strlen (x)), (x))
  30. #endif
  31. #ifndef whitespace
  32. #define whitespace(c) (((c) == ' ') || ((c) == '\t'))
  33. #endif
  34. #ifndef _rl_digit_p
  35. #define _rl_digit_p(c) ((c) >= '0' && (c) <= '9')
  36. #endif
  37. #ifndef _rl_digit_value
  38. #define _rl_digit_value(c) ((c) - '0')
  39. #endif
  40. #ifndef member
  41. # ifndef strchr
  42. extern char *strchr ();
  43. # endif
  44. #define member(c, s) ((c) ? ((char *)strchr ((s), (c)) != (char *)NULL) : 0)
  45. #endif
  46. #ifndef FREE
  47. # define FREE(x) if (x) free (x)
  48. #endif
  49. /* Possible history errors passed to hist_error. */
  50. #define EVENT_NOT_FOUND 0
  51. #define BAD_WORD_SPEC 1
  52. #define SUBST_FAILED 2
  53. #define BAD_MODIFIER 3
  54. #define NO_PREV_SUBST 4
  55. /* Possible definitions for history starting point specification. */
  56. #define ANCHORED_SEARCH 1
  57. #define NON_ANCHORED_SEARCH 0
  58. /* Possible definitions for what style of writing the history file we want. */
  59. #define HISTORY_APPEND 0
  60. #define HISTORY_OVERWRITE 1
  61. /* Some variable definitions shared across history source files. */
  62. extern int history_offset;
  63. #endif /* !_HISTLIB_H_ */