11acd27e7Smillert /* histlib.h -- internal definitions for the history library. */
21acd27e7Smillert /* Copyright (C) 1989, 1992 Free Software Foundation, Inc.
31acd27e7Smillert
41acd27e7Smillert This file contains the GNU History Library (the Library), a set of
51acd27e7Smillert routines for managing the text of previously typed lines.
61acd27e7Smillert
71acd27e7Smillert The Library is free software; you can redistribute it and/or modify
81acd27e7Smillert it under the terms of the GNU General Public License as published by
91acd27e7Smillert the Free Software Foundation; either version 2, or (at your option)
101acd27e7Smillert any later version.
111acd27e7Smillert
121acd27e7Smillert The Library is distributed in the hope that it will be useful, but
131acd27e7Smillert WITHOUT ANY WARRANTY; without even the implied warranty of
141acd27e7Smillert MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
151acd27e7Smillert General Public License for more details.
161acd27e7Smillert
171acd27e7Smillert The GNU General Public License is often shipped with GNU software, and
181acd27e7Smillert is generally kept in a file called COPYING or LICENSE. If you do not
191acd27e7Smillert have a copy of the license, write to the Free Software Foundation,
201acd27e7Smillert 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
211acd27e7Smillert
221acd27e7Smillert #if !defined (_HISTLIB_H_)
231acd27e7Smillert #define _HISTLIB_H_
241acd27e7Smillert
25*af70c2dfSkettenis #if defined (HAVE_STRING_H)
26*af70c2dfSkettenis # include <string.h>
27*af70c2dfSkettenis #else
28*af70c2dfSkettenis # include <strings.h>
29*af70c2dfSkettenis #endif /* !HAVE_STRING_H */
301acd27e7Smillert
311acd27e7Smillert #if !defined (STREQ)
321acd27e7Smillert #define STREQ(a, b) (((a)[0] == (b)[0]) && (strcmp ((a), (b)) == 0))
331acd27e7Smillert #define STREQN(a, b, n) (((n) == 0) ? (1) \
341acd27e7Smillert : ((a)[0] == (b)[0]) && (strncmp ((a), (b), (n)) == 0))
351acd27e7Smillert #endif
361acd27e7Smillert
3763bef317Sbeck #if !defined (savestring)
3863bef317Sbeck #include <stdio.h>
3963bef317Sbeck static char *
xstrdup(const char * s)40*af70c2dfSkettenis xstrdup(const char *s)
4163bef317Sbeck {
4263bef317Sbeck char * cp;
4363bef317Sbeck cp = strdup(s);
4463bef317Sbeck if (cp == NULL) {
4563bef317Sbeck fprintf (stderr, "xstrdup: out of virtual memory\n");
4663bef317Sbeck exit (2);
4763bef317Sbeck }
4863bef317Sbeck return(cp);
4963bef317Sbeck }
5063bef317Sbeck #define savestring(x) xstrdup(x)
5163bef317Sbeck #endif /* !savestring */
521acd27e7Smillert
531acd27e7Smillert #ifndef whitespace
541acd27e7Smillert #define whitespace(c) (((c) == ' ') || ((c) == '\t'))
551acd27e7Smillert #endif
561acd27e7Smillert
571acd27e7Smillert #ifndef _rl_digit_p
581acd27e7Smillert #define _rl_digit_p(c) ((c) >= '0' && (c) <= '9')
591acd27e7Smillert #endif
601acd27e7Smillert
611acd27e7Smillert #ifndef _rl_digit_value
621acd27e7Smillert #define _rl_digit_value(c) ((c) - '0')
631acd27e7Smillert #endif
641acd27e7Smillert
651acd27e7Smillert #ifndef member
661acd27e7Smillert # ifndef strchr
671acd27e7Smillert extern char *strchr ();
681acd27e7Smillert # endif
691acd27e7Smillert #define member(c, s) ((c) ? ((char *)strchr ((s), (c)) != (char *)NULL) : 0)
701acd27e7Smillert #endif
711acd27e7Smillert
721acd27e7Smillert #ifndef FREE
731acd27e7Smillert # define FREE(x) if (x) free (x)
741acd27e7Smillert #endif
751acd27e7Smillert
761acd27e7Smillert /* Possible history errors passed to hist_error. */
771acd27e7Smillert #define EVENT_NOT_FOUND 0
781acd27e7Smillert #define BAD_WORD_SPEC 1
791acd27e7Smillert #define SUBST_FAILED 2
801acd27e7Smillert #define BAD_MODIFIER 3
811acd27e7Smillert #define NO_PREV_SUBST 4
821acd27e7Smillert
831acd27e7Smillert /* Possible definitions for history starting point specification. */
841acd27e7Smillert #define ANCHORED_SEARCH 1
851acd27e7Smillert #define NON_ANCHORED_SEARCH 0
861acd27e7Smillert
871acd27e7Smillert /* Possible definitions for what style of writing the history file we want. */
881acd27e7Smillert #define HISTORY_APPEND 0
891acd27e7Smillert #define HISTORY_OVERWRITE 1
901acd27e7Smillert
911acd27e7Smillert /* Some variable definitions shared across history source files. */
921acd27e7Smillert extern int history_offset;
931acd27e7Smillert
941acd27e7Smillert #endif /* !_HISTLIB_H_ */
95