1/***********************************************************************
2*                                                                      *
3*               This software is part of the ast package               *
4*          Copyright (c) 1982-2011 AT&T Intellectual Property          *
5*                      and is licensed under the                       *
6*                  Common Public License, Version 1.0                  *
7*                    by AT&T Intellectual Property                     *
8*                                                                      *
9*                A copy of the License is available at                 *
10*            http://www.opensource.org/licenses/cpl1.0.txt             *
11*         (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9)         *
12*                                                                      *
13*              Information and Software Systems Research               *
14*                            AT&T Research                             *
15*                           Florham Park NJ                            *
16*                                                                      *
17*                  David Korn <dgk@research.att.com>                   *
18*                                                                      *
19***********************************************************************/
20#pragma prototyped
21#ifndef HIST_VERSION
22/*
23 *	Interface for history mechanism
24 *	written by David Korn
25 *
26 */
27
28#include	<ast.h>
29
30#define HIST_CHAR	'!'
31#define HIST_VERSION	1		/* history file format version no. */
32
33typedef struct
34{
35	Sfdisc_t	histdisc;	/* discipline for history */
36	Sfio_t		*histfp;	/* history file stream pointer */
37	char		*histname;	/* name of history file */
38	int32_t		histind;	/* current command number index */
39	int		histsize;	/* number of accessible history lines */
40#ifdef _HIST_PRIVATE
41	_HIST_PRIVATE
42#endif /* _HIST_PRIVATE */
43} History_t;
44
45typedef struct
46{
47	int hist_command;
48	int hist_line;
49	int hist_char;
50} Histloc_t;
51
52/* the following are readonly */
53extern const char	hist_fname[];
54
55extern int _Hist;
56#define	hist_min(hp)	((_Hist=((int)((hp)->histind-(hp)->histsize)))>=0?_Hist:0)
57#define	hist_max(hp)	((int)((hp)->histind))
58/* these are the history interface routines */
59extern int		sh_histinit(void *);
60extern void 		hist_cancel(History_t*);
61extern void 		hist_close(History_t*);
62extern int		hist_copy(char*, int, int, int);
63extern void 		hist_eof(History_t*);
64extern Histloc_t	hist_find(History_t*,char*,int, int, int);
65extern void 		hist_flush(History_t*);
66extern void 		hist_list(History_t*,Sfio_t*, off_t, int, char*);
67extern int		hist_match(History_t*,off_t, char*, int*);
68extern off_t		hist_tell(History_t*,int);
69extern off_t		hist_seek(History_t*,int);
70extern char 		*hist_word(char*, int, int);
71#if SHOPT_ESH
72    extern Histloc_t	hist_locate(History_t*,int, int, int);
73#endif	/* SHOPT_ESH */
74
75#endif /* HIST_VERSION */
76