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 *                 Eclipse Public License, Version 1.0                  *
7 *                    by AT&T Intellectual Property                     *
8 *                                                                      *
9 *                A copy of the License is available at                 *
10 *          http://www.eclipse.org/org/documents/epl-v10.html           *
11 *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         *
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 
33 typedef 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 
45 typedef struct
46 {
47 	int hist_command;
48 	int hist_line;
49 	int hist_char;
50 } Histloc_t;
51 
52 /* the following are readonly */
53 extern const char	hist_fname[];
54 
55 extern 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 */
59 extern int		sh_histinit(void *);
60 extern void 		hist_cancel(History_t*);
61 extern void 		hist_close(History_t*);
62 extern int		hist_copy(char*, int, int, int);
63 extern void 		hist_eof(History_t*);
64 extern Histloc_t	hist_find(History_t*,char*,int, int, int);
65 extern void 		hist_flush(History_t*);
66 extern void 		hist_list(History_t*,Sfio_t*, off_t, int, char*);
67 extern int		hist_match(History_t*,off_t, char*, int*);
68 extern off_t		hist_tell(History_t*,int);
69 extern off_t		hist_seek(History_t*,int);
70 extern 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